From c1ce9a5d36dcc07bd734b307e7a3a3fb39ebd61d Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 11 Jan 2024 12:59:30 +0530 Subject: [PATCH 01/83] removed registerInArgo multiple impls --- Wire.go | 2 - .../argocdServer/ArgoClientWrapperService.go | 37 ++++++++---- internal/util/ChartDeploymentService.go | 38 ------------ .../AppStoreDeploymentFullModeService.go | 17 +----- .../gitops/AppStoreDeploymentArgoCdService.go | 8 +-- pkg/chart/ChartService.go | 15 ----- pkg/chart/mocks/ChartService.go | 13 ----- .../DeploymentPipelineConfigService.go | 58 +++++++------------ wire_gen.go | 5 +- 9 files changed, 55 insertions(+), 138 deletions(-) delete mode 100644 internal/util/ChartDeploymentService.go diff --git a/Wire.go b/Wire.go index 9cc5e42f2f..6918016d1f 100644 --- a/Wire.go +++ b/Wire.go @@ -264,8 +264,6 @@ func InitializeApp() (*App, error) { wire.Bind(new(restHandler.MigrateDbRestHandler), new(*restHandler.MigrateDbRestHandlerImpl)), util.NewChartTemplateServiceImpl, wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - util.NewChartDeploymentServiceImpl, - wire.Bind(new(util.ChartDeploymentService), new(*util.ChartDeploymentServiceImpl)), //scoped variables start variables.NewScopedVariableServiceImpl, diff --git a/client/argocdServer/ArgoClientWrapperService.go b/client/argocdServer/ArgoClientWrapperService.go index 3cd2cf7380..add0a58122 100644 --- a/client/argocdServer/ArgoClientWrapperService.go +++ b/client/argocdServer/ArgoClientWrapperService.go @@ -3,10 +3,12 @@ package argocdServer import ( "context" application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/caarlos0/env" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/bean" + "github.com/devtron-labs/devtron/client/argocdServer/repository" "go.uber.org/zap" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -34,22 +36,25 @@ type ArgoClientWrapperService interface { // UpdateArgoCDSyncModeIfNeeded - if ARGO_AUTO_SYNC_ENABLED=true and app is in manual sync mode or vice versa update app UpdateArgoCDSyncModeIfNeeded(ctx context.Context, argoApplication *v1alpha1.Application) (err error) + + //RegisterGitOpsRepoInArgo - register a repository in argo-cd + RegisterGitOpsRepoInArgo(ctx context.Context, repoUrl string) (err error) } type ArgoClientWrapperServiceImpl struct { - logger *zap.SugaredLogger - acdClient application.ServiceClient - ACDConfig *ACDConfig + logger *zap.SugaredLogger + acdClient application.ServiceClient + ACDConfig *ACDConfig + repositoryService repository.ServiceClient } -func NewArgoClientWrapperServiceImpl(logger *zap.SugaredLogger, - acdClient application.ServiceClient, - ACDConfig *ACDConfig, -) *ArgoClientWrapperServiceImpl { +func NewArgoClientWrapperServiceImpl(logger *zap.SugaredLogger, acdClient application.ServiceClient, + ACDConfig *ACDConfig, repositoryService repository.ServiceClient) *ArgoClientWrapperServiceImpl { return &ArgoClientWrapperServiceImpl{ - logger: logger, - acdClient: acdClient, - ACDConfig: ACDConfig, + logger: logger, + acdClient: acdClient, + ACDConfig: ACDConfig, + repositoryService: repositoryService, } } @@ -130,3 +135,15 @@ func (impl *ArgoClientWrapperServiceImpl) CreateRequestForArgoCDSyncModeUpdateRe Retry: argoApplication.Spec.SyncPolicy.Retry, }}} } + +func (impl *ArgoClientWrapperServiceImpl) RegisterGitOpsRepoInArgo(ctx context.Context, repoUrl string) (err error) { + repo := &v1alpha1.Repository{ + Repo: repoUrl, + } + repo, err = impl.repositoryService.Create(ctx, &repository2.RepoCreateRequest{Repo: repo, Upsert: true}) + if err != nil { + impl.logger.Errorw("error in creating argo Repository ", "err", err) + } + impl.logger.Infow("gitOps repo registered in argo", "name", repoUrl) + return err +} diff --git a/internal/util/ChartDeploymentService.go b/internal/util/ChartDeploymentService.go deleted file mode 100644 index 53dd03deb1..0000000000 --- a/internal/util/ChartDeploymentService.go +++ /dev/null @@ -1,38 +0,0 @@ -package util - -import ( - "context" - repository3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - repository4 "github.com/devtron-labs/devtron/client/argocdServer/repository" - "go.uber.org/zap" -) - -type ChartDeploymentService interface { - RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) error -} - -type ChartDeploymentServiceImpl struct { - logger *zap.SugaredLogger - repositoryService repository4.ServiceClient -} - -func NewChartDeploymentServiceImpl(logger *zap.SugaredLogger, repositoryService repository4.ServiceClient) *ChartDeploymentServiceImpl { - return &ChartDeploymentServiceImpl{ - logger: logger, - repositoryService: repositoryService, - } -} - -func (impl *ChartDeploymentServiceImpl) RegisterInArgo(chartGitAttribute *ChartGitAttribute, ctx context.Context) error { - repo := &v1alpha1.Repository{ - Repo: chartGitAttribute.RepoUrl, - } - repo, err := impl.repositoryService.Create(ctx, &repository3.RepoCreateRequest{Repo: repo, Upsert: true}) - if err != nil { - impl.logger.Errorw("error in creating argo Repository ", "err", err) - return err - } - impl.logger.Infow("repo registered in argo", "name", chartGitAttribute.RepoUrl) - return err -} diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 0899e6d7d0..179c59463b 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -45,8 +45,6 @@ import ( "github.com/go-pg/pg" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/util" @@ -64,7 +62,6 @@ const ( type AppStoreDeploymentFullModeService interface { AppStoreDeployOperationGIT(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, *util.ChartGitAttribute, error) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error SyncACD(acdAppName string, ctx context.Context) UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error @@ -323,7 +320,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(ins ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() //STEP 4: registerInArgo - err := impl.RegisterInArgo(chartGitAttr, ctx) + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error in argo registry", "err", err) return nil, err @@ -366,18 +363,6 @@ func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(ins return installAppVersionRequest, nil } -func (impl AppStoreDeploymentFullModeServiceImpl) RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error { - repo := &v1alpha1.Repository{ - Repo: chartGitAttribute.RepoUrl, - } - repo, err := impl.repositoryService.Create(ctx, &repository2.RepoCreateRequest{Repo: repo, Upsert: true}) - if err != nil { - impl.logger.Errorw("error in creating argo Repository ", "err", err) - } - impl.logger.Debugw("repo registered in argo", "name", chartGitAttribute.RepoUrl) - return err -} - func (impl AppStoreDeploymentFullModeServiceImpl) SyncACD(acdAppName string, ctx context.Context) { req := new(application.ApplicationSyncRequest) req.Name = &acdAppName diff --git a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go index 143a4e437b..3b39254642 100644 --- a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go @@ -74,9 +74,9 @@ type AppStoreDeploymentArgoCdServiceImpl struct { helmAppService client.HelmAppService gitOpsConfigRepository repository3.GitOpsConfigRepository appStatusService appStatus.AppStatusService - pipelineStatusTimelineService status.PipelineStatusTimelineService - userService user.UserService - pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository + pipelineStatusTimelineService status.PipelineStatusTimelineService + userService user.UserService + pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig @@ -662,7 +662,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() //registerInArgo - err := impl.appStoreDeploymentFullModeService.RegisterInArgo(chartGitAttr, ctx) + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.Logger.Errorw("error in argo registry", "err", err) return nil, err diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index a728aef48a..c95a5d05ec 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -50,8 +50,6 @@ import ( "github.com/devtron-labs/devtron/pkg/sql" dirCopy "github.com/otiai10/copy" - repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/sql/models" repository3 "github.com/devtron-labs/devtron/internal/sql/repository" @@ -91,7 +89,6 @@ type ChartService interface { FormatChartName(chartName string) string ValidateUploadedFileFormat(fileName string) error ReadChartMetaDataForLocation(chartDir string, fileName string) (*ChartYamlStruct, error) - RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error FetchCustomChartsInfo() ([]*ChartDto, error) CheckCustomChartByAppId(id int) (bool, error) CheckCustomChartByChartId(id int) (bool, error) @@ -587,18 +584,6 @@ func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest Template return chartVal, err } -func (impl ChartServiceImpl) RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error { - repo := &v1alpha1.Repository{ - Repo: chartGitAttribute.RepoUrl, - } - repo, err := impl.repositoryService.Create(ctx, &repository2.RepoCreateRequest{Repo: repo, Upsert: true}) - if err != nil { - impl.logger.Errorw("error in creating argo Repository ", "err", err) - } - impl.logger.Infow("repo registered in argo", "name", chartGitAttribute.RepoUrl) - return err -} - // converts db object to bean func (impl ChartServiceImpl) chartAdaptor(chart *chartRepoRepository.Chart, appLevelMetrics *repository3.AppLevelMetrics) (*TemplateRequest, error) { var appMetrics bool diff --git a/pkg/chart/mocks/ChartService.go b/pkg/chart/mocks/ChartService.go index 1c58d68537..3cf2e392d6 100644 --- a/pkg/chart/mocks/ChartService.go +++ b/pkg/chart/mocks/ChartService.go @@ -680,19 +680,6 @@ func (_m *ChartService) ReadChartMetaDataForLocation(chartDir string, fileName s return r0, r1 } -// RegisterInArgo provides a mock function with given fields: chartGitAttribute, ctx -func (_m *ChartService) RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error { - ret := _m.Called(chartGitAttribute, ctx) - - var r0 error - if rf, ok := ret.Get(0).(func(*util.ChartGitAttribute, context.Context) error); ok { - r0 = rf(chartGitAttribute, ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} // UpdateAppOverride provides a mock function with given fields: ctx, templateRequest func (_m *ChartService) UpdateAppOverride(ctx context.Context, templateRequest *chart.TemplateRequest) (*chart.TemplateRequest, error) { diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 865dc9c82e..ca0c9df270 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -26,6 +26,7 @@ import ( bean2 "github.com/devtron-labs/devtron/api/bean" client "github.com/devtron-labs/devtron/api/helm-app" models2 "github.com/devtron-labs/devtron/api/helm-app/models" + "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository" @@ -132,7 +133,6 @@ type CdPipelineConfigServiceImpl struct { pipelineStrategyHistoryService history.PipelineStrategyHistoryService chartRepository chartRepoRepository.ChartRepository resourceGroupService resourceGroup2.ResourceGroupService - chartDeploymentService util.ChartDeploymentService chartTemplateService util.ChartTemplateService propertiesConfigService PropertiesConfigService appLevelMetricsRepository repository.AppLevelMetricsRepository @@ -145,42 +145,26 @@ type CdPipelineConfigServiceImpl struct { devtronAppCMCSService DevtronAppCMCSService ciPipelineConfigService CiPipelineConfigService buildPipelineSwitchService BuildPipelineSwitchService + argoClientWrapperService argocdServer.ArgoClientWrapperService } -func NewCdPipelineConfigServiceImpl( - logger *zap.SugaredLogger, - pipelineRepository pipelineConfig.PipelineRepository, - environmentRepository repository2.EnvironmentRepository, - pipelineConfigRepository chartConfig.PipelineConfigRepository, - appWorkflowRepository appWorkflow.AppWorkflowRepository, - pipelineStageService PipelineStageService, - appRepo app2.AppRepository, - appService app.AppService, - deploymentGroupRepository repository.DeploymentGroupRepository, - ciCdPipelineOrchestrator CiCdPipelineOrchestrator, - appStatusRepository appStatus.AppStatusRepository, - ciPipelineRepository pipelineConfig.CiPipelineRepository, - prePostCdScriptHistoryService history.PrePostCdScriptHistoryService, - clusterRepository repository2.ClusterRepository, - helmAppService client.HelmAppService, - enforcerUtil rbac.EnforcerUtil, - gitOpsRepository repository.GitOpsConfigRepository, +func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, + environmentRepository repository2.EnvironmentRepository, pipelineConfigRepository chartConfig.PipelineConfigRepository, + appWorkflowRepository appWorkflow.AppWorkflowRepository, pipelineStageService PipelineStageService, + appRepo app2.AppRepository, appService app.AppService, deploymentGroupRepository repository.DeploymentGroupRepository, + ciCdPipelineOrchestrator CiCdPipelineOrchestrator, appStatusRepository appStatus.AppStatusRepository, + ciPipelineRepository pipelineConfig.CiPipelineRepository, prePostCdScriptHistoryService history.PrePostCdScriptHistoryService, + clusterRepository repository2.ClusterRepository, helmAppService client.HelmAppService, + enforcerUtil rbac.EnforcerUtil, gitOpsRepository repository.GitOpsConfigRepository, pipelineStrategyHistoryService history.PipelineStrategyHistoryService, - chartRepository chartRepoRepository.ChartRepository, - resourceGroupService resourceGroup2.ResourceGroupService, - chartDeploymentService util.ChartDeploymentService, - chartTemplateService util.ChartTemplateService, - propertiesConfigService PropertiesConfigService, - appLevelMetricsRepository repository.AppLevelMetricsRepository, - deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, - scopedVariableManager variables.ScopedVariableManager, - deploymentConfig *DeploymentServiceTypeConfig, - application application.ServiceClient, - customTagService CustomTagService, - pipelineConfigListenerService PipelineConfigListenerService, - devtronAppCMCSService DevtronAppCMCSService, - ciPipelineConfigService CiPipelineConfigService, - buildPipelineSwitchService BuildPipelineSwitchService) *CdPipelineConfigServiceImpl { + chartRepository chartRepoRepository.ChartRepository, resourceGroupService resourceGroup2.ResourceGroupService, + chartTemplateService util.ChartTemplateService, propertiesConfigService PropertiesConfigService, + appLevelMetricsRepository repository.AppLevelMetricsRepository, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, + scopedVariableManager variables.ScopedVariableManager, deploymentConfig *DeploymentServiceTypeConfig, + application application.ServiceClient, customTagService CustomTagService, + pipelineConfigListenerService PipelineConfigListenerService, devtronAppCMCSService DevtronAppCMCSService, + ciPipelineConfigService CiPipelineConfigService, buildPipelineSwitchService BuildPipelineSwitchService, + argoClientWrapperService argocdServer.ArgoClientWrapperService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -202,7 +186,6 @@ func NewCdPipelineConfigServiceImpl( pipelineStrategyHistoryService: pipelineStrategyHistoryService, chartRepository: chartRepository, resourceGroupService: resourceGroupService, - chartDeploymentService: chartDeploymentService, chartTemplateService: chartTemplateService, propertiesConfigService: propertiesConfigService, appLevelMetricsRepository: appLevelMetricsRepository, @@ -215,6 +198,7 @@ func NewCdPipelineConfigServiceImpl( customTagService: customTagService, ciPipelineConfigService: ciPipelineConfigService, buildPipelineSwitchService: buildPipelineSwitchService, + argoClientWrapperService: argoClientWrapperService, } } @@ -1616,7 +1600,7 @@ func (impl *CdPipelineConfigServiceImpl) ValidateCDPipelineRequest(pipelineCreat func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, chartGitAttr *util.ChartGitAttribute, userId int32, ctx context.Context) error { - err := impl.chartDeploymentService.RegisterInArgo(chartGitAttr, ctx) + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error while register git repo in argo", "err", err) emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "remote repository is empty"} @@ -1628,7 +1612,7 @@ func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, ch return err } // - retry register in argo - err = impl.chartDeploymentService.RegisterInArgo(chartGitAttr, ctx) + err = impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error in re-try register in argo", "err", err) return err diff --git a/wire_gen.go b/wire_gen.go index 1ec6b644e1..600ede7536 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -415,7 +415,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig) + argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, refChartProxyDir, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, applicationServiceClientImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, globalEnvVariables, installedAppRepositoryImpl, tokenCache, argoUserServiceImpl, gitOpsConfigRepositoryImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, chartTemplateServiceImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, gitOpsConfigRepositoryImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) deploymentServiceTypeConfig, err := service.GetDeploymentServiceTypeConfig() @@ -499,14 +499,13 @@ func InitializeApp() (*App, error) { ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) imageTaggingRepositoryImpl := repository13.NewImageTaggingRepositoryImpl(db) imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) - chartDeploymentServiceImpl := util.NewChartDeploymentServiceImpl(sugaredLogger, repositoryServiceClientImpl) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl) pipelineDeploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartDeploymentServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, pipelineDeploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, pipelineDeploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) From b8fa93b0fdc71242c618a8486413448c1df8fc93 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 11 Jan 2024 15:18:45 +0530 Subject: [PATCH 02/83] extracted app metrics code --- Wire.go | 4 + api/restHandler/CoreAppRestHandler.go | 19 +- .../app/DeploymentPipelineRestHandler.go | 44 ---- api/router/PipelineConfigRouter.go | 1 - pkg/app/AppService.go | 13 +- pkg/chart/ChartService.go | 197 ++++-------------- .../deployedAppMetrics/DeployedAppMetrics.go | 117 +++++++++++ .../manifest/deployedAppMetrics/bean/bean.go | 9 + .../DeploymentTemplateService.go | 16 ++ pkg/pipeline/DeploymentConfigService.go | 18 +- .../DeploymentPipelineConfigService.go | 20 +- pkg/pipeline/WorkflowDagExecutor.go | 20 +- .../DeploymentTemplateHistoryService.go | 15 +- wire_gen.go | 18 +- 14 files changed, 235 insertions(+), 276 deletions(-) create mode 100644 pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go create mode 100644 pkg/deployment/manifest/deployedAppMetrics/bean/bean.go create mode 100644 pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go diff --git a/Wire.go b/Wire.go index 6918016d1f..b4ef34b994 100644 --- a/Wire.go +++ b/Wire.go @@ -97,6 +97,7 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -289,6 +290,9 @@ func InitializeApp() (*App, error) { //end + deployedAppMetrics.NewDeployedAppMetricsServiceImpl, + wire.Bind(new(deployedAppMetrics.DeployedAppMetricsService), new(*deployedAppMetrics.DeployedAppMetricsServiceImpl)), + chart.NewChartServiceImpl, wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)), bulkAction.NewBulkUpdateServiceImpl, diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 20566db8c4..6d7f20171f 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -75,9 +75,9 @@ type CoreAppRestHandler interface { } type CoreAppRestHandlerImpl struct { - logger *zap.SugaredLogger - userAuthService user.UserService - validator *validator.Validate + logger *zap.SugaredLogger + userAuthService user.UserService + validator *validator.Validate enforcerUtil rbac.EnforcerUtil enforcer casbin.Enforcer appCrudOperationService app.AppCrudOperationService @@ -1391,19 +1391,6 @@ func (handler CoreAppRestHandlerImpl) createDeploymentTemplate(ctx context.Conte handler.logger.Errorw("service err, Create in CreateDeploymentTemplate", "err", err, "createRequest", createDeploymentTemplateRequest) return err, http.StatusInternalServerError } - - //updating app metrics - appMetricsRequest := chart.AppMetricEnableDisableRequest{ - AppId: appId, - UserId: userId, - IsAppMetricsEnabled: deploymentTemplate.ShowAppMetrics, - } - _, err = handler.chartService.AppMetricsEnableDisable(appMetricsRequest) - if err != nil { - handler.logger.Errorw("service err, AppMetricsEnableDisable in createDeploymentTemplate", "err", err, "appId", appId, "payload", appMetricsRequest) - return err, http.StatusInternalServerError - } - return nil, http.StatusOK } diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 8eedcc34b5..c7dc4f7da6 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -80,7 +80,6 @@ type DevtronAppDeploymentConfigRestHandler interface { GetDeploymentPipelineStrategy(w http.ResponseWriter, r *http.Request) GetDefaultDeploymentPipelineStrategy(w http.ResponseWriter, r *http.Request) - AppMetricsEnableDisable(w http.ResponseWriter, r *http.Request) EnvMetricsEnableDisable(w http.ResponseWriter, r *http.Request) EnvConfigOverrideCreateNamespace(w http.ResponseWriter, r *http.Request) @@ -1700,49 +1699,6 @@ func (handler PipelineConfigRestHandlerImpl) EnvConfigOverrideReset(w http.Respo common.WriteJsonResp(w, err, isSuccess, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) AppMetricsEnableDisable(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := handler.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - token := r.Header.Get("token") - vars := mux.Vars(r) - appId, err := strconv.Atoi(vars["appId"]) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - var appMetricEnableDisableRequest chart.AppMetricEnableDisableRequest - err = decoder.Decode(&appMetricEnableDisableRequest) - appMetricEnableDisableRequest.AppId = appId - appMetricEnableDisableRequest.UserId = userId - if err != nil { - handler.Logger.Errorw("request err, AppMetricsEnableDisable", "err", err, "appId", appId, "payload", appMetricEnableDisableRequest) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.Logger.Infow("request payload, AppMetricsEnableDisable", "err", err, "appId", appId, "payload", appMetricEnableDisableRequest) - app, err := handler.pipelineBuilder.GetApp(appId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - resourceName := handler.enforcerUtil.GetAppRBACName(app.AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - createResp, err := handler.chartService.AppMetricsEnableDisable(appMetricEnableDisableRequest) - if err != nil { - handler.Logger.Errorw("service err, AppMetricsEnableDisable", "err", err, "appId", appId, "payload", appMetricEnableDisableRequest) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, createResp, http.StatusOK) -} - func (handler PipelineConfigRestHandlerImpl) EnvMetricsEnableDisable(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { diff --git a/api/router/PipelineConfigRouter.go b/api/router/PipelineConfigRouter.go index 54bc7613ec..2fb48b3d8d 100644 --- a/api/router/PipelineConfigRouter.go +++ b/api/router/PipelineConfigRouter.go @@ -134,7 +134,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/env/reset/{appId}/{environmentId}/{id}").HandlerFunc(router.restHandler.EnvConfigOverrideReset).Methods("DELETE") configRouter.Path("/env/namespace/{appId}/{environmentId}").HandlerFunc(router.restHandler.EnvConfigOverrideCreateNamespace).Methods("POST") - configRouter.Path("/template/metrics/{appId}").HandlerFunc(router.restHandler.AppMetricsEnableDisable).Methods("POST") configRouter.Path("/env/metrics/{appId}/{environmentId}").HandlerFunc(router.restHandler.EnvMetricsEnableDisable).Methods("POST") configRouter.Path("/app-wf"). diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 29e9c8e826..5148a4279d 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -118,17 +118,14 @@ type AppServiceImpl struct { tokenCache *util3.TokenCache acdAuthConfig *util3.ACDAuthConfig enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - user user.UserService - appListingRepository repository.AppListingRepository + enforcerUtil rbac.EnforcerUtil + user user.UserService + appListingRepository repository.AppListingRepository appRepository app.AppRepository envRepository repository2.EnvironmentRepository pipelineConfigRepository chartConfig.PipelineConfigRepository configMapRepository chartConfig.ConfigMapRepository chartRepository chartRepoRepository.ChartRepository - appRepo app.AppRepository - appLevelMetricsRepository repository.AppLevelMetricsRepository - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository cdWorkflowRepository pipelineConfig.CdWorkflowRepository commonService commonService.CommonService @@ -211,8 +208,6 @@ func NewAppService( envRepository repository2.EnvironmentRepository, pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository, - appLevelMetricsRepository repository.AppLevelMetricsRepository, - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, chartRepository chartRepoRepository.ChartRepository, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, @@ -275,8 +270,6 @@ func NewAppService( pipelineConfigRepository: pipelineConfigRepository, configMapRepository: configMapRepository, chartRepository: chartRepository, - appLevelMetricsRepository: appLevelMetricsRepository, - envLevelMetricsRepository: envLevelMetricsRepository, ciPipelineMaterialRepository: ciPipelineMaterialRepository, cdWorkflowRepository: cdWorkflowRepository, commonService: commonService, diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index c95a5d05ec..ca6397f113 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -22,6 +22,8 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/variables/parsers" @@ -78,7 +80,6 @@ type ChartService interface { ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*ChartRefResponse, error) FindPreviousChartByAppId(appId int) (chartTemplate *TemplateRequest, err error) UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) - AppMetricsEnableDisable(appMetricRequest AppMetricEnableDisableRequest) (*AppMetricEnableDisableRequest, error) DeploymentTemplateValidate(ctx context.Context, templatejson interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) (schema []byte, readme []byte, err error) @@ -115,11 +116,11 @@ type ChartServiceImpl struct { configMapRepository chartConfig.ConfigMapRepository environmentRepository repository4.EnvironmentRepository pipelineRepository pipelineConfig.PipelineRepository - appLevelMetricsRepository repository3.AppLevelMetricsRepository envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository client *http.Client deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, @@ -137,12 +138,11 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, configMapRepository chartConfig.ConfigMapRepository, environmentRepository repository4.EnvironmentRepository, pipelineRepository pipelineConfig.PipelineRepository, - appLevelMetricsRepository repository3.AppLevelMetricsRepository, envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository, client *http.Client, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, -) *ChartServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *ChartServiceImpl { // cache devtron reference charts list devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) @@ -164,11 +164,11 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, configMapRepository: configMapRepository, environmentRepository: environmentRepository, pipelineRepository: pipelineRepository, - appLevelMetricsRepository: appLevelMetricsRepository, envLevelAppMetricsRepository: envLevelAppMetricsRepository, client: client, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -443,28 +443,19 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context return nil, err } - var appLevelMetrics *repository3.AppLevelMetrics - isAppMetricsSupported, err := impl.CheckIsAppMetricsSupported(templateRequest.ChartRefId) + appLevelMetricsUpdateReq := &bean.DeployedAppMetricsRequest{ + EnableMetrics: templateRequest.IsAppMetricsEnabled, + AppId: templateRequest.AppId, + ChartRefId: templateRequest.ChartRefId, + UserId: templateRequest.UserId, + } + err = impl.deployedAppMetricsService.CheckAndUpdateAppLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { + impl.logger.Errorw("error, CheckAndUpdateAppLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err } - if !(isAppMetricsSupported) { - appMetricsRequest := AppMetricEnableDisableRequest{UserId: templateRequest.UserId, AppId: templateRequest.AppId, IsAppMetricsEnabled: false} - appLevelMetrics, err = impl.updateAppLevelMetrics(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while disable app metrics for lower versions", "err", err) - return nil, err - } - } else { - appMetricsRequest := AppMetricEnableDisableRequest{UserId: templateRequest.UserId, AppId: templateRequest.AppId, IsAppMetricsEnabled: templateRequest.IsAppMetricsEnabled} - appLevelMetrics, err = impl.updateAppLevelMetrics(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while updating app metrics", "err", err) - return nil, err - } - } - chartVal, err := impl.chartAdaptor(chart, appLevelMetrics) + chartVal, err := impl.chartAdaptor(chart, appLevelMetricsUpdateReq.EnableMetrics) return chartVal, err } @@ -580,19 +571,15 @@ func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest Template return nil, err } - chartVal, err := impl.chartAdaptor(chart, nil) + chartVal, err := impl.chartAdaptor(chart, false) return chartVal, err } // converts db object to bean -func (impl ChartServiceImpl) chartAdaptor(chart *chartRepoRepository.Chart, appLevelMetrics *repository3.AppLevelMetrics) (*TemplateRequest, error) { - var appMetrics bool +func (impl ChartServiceImpl) chartAdaptor(chart *chartRepoRepository.Chart, isAppMetricsEnabled bool) (*TemplateRequest, error) { if chart == nil || chart.Id == 0 { return &TemplateRequest{}, &util.ApiError{UserMessage: "no chart found"} } - if appLevelMetrics != nil { - appMetrics = appLevelMetrics.AppMetrics - } return &TemplateRequest{ RefChartTemplate: chart.ReferenceTemplate, Id: chart.Id, @@ -602,7 +589,7 @@ func (impl ChartServiceImpl) chartAdaptor(chart *chartRepoRepository.Chart, appL RefChartTemplateVersion: impl.getParentChartVersion(chart.ChartVersion), Latest: chart.Latest, ChartRefId: chart.ChartRefId, - IsAppMetricsEnabled: appMetrics, + IsAppMetricsEnabled: isAppMetricsEnabled, IsBasicViewLocked: chart.IsBasicViewLocked, CurrentViewEditor: chart.CurrentViewEditor, }, nil @@ -745,14 +732,12 @@ func (impl ChartServiceImpl) FindLatestChartForAppByAppId(appId int) (chartTempl impl.logger.Errorw("error in fetching chart ", "appId", appId, "err", err) return nil, err } - - appMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && !util.IsErrNoRows(err) { + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + if err != nil { impl.logger.Errorw("error in fetching app-metrics", "appId", appId, "err", err) return nil, err } - - chartTemplate, err = impl.chartAdaptor(chart, appMetrics) + chartTemplate, err = impl.chartAdaptor(chart, isAppMetricsEnabled) return chartTemplate, err } @@ -762,12 +747,12 @@ func (impl ChartServiceImpl) GetByAppIdAndChartRefId(appId int, chartRefId int) impl.logger.Errorw("error in fetching chart ", "appId", appId, "err", err) return nil, err } - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("error in fetching app metrics flag", "err", err) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + if err != nil { + impl.logger.Errorw("error in fetching app-metrics", "appId", appId, "err", err) return nil, err } - chartTemplate, err = impl.chartAdaptor(chart, appLevelMetrics) + chartTemplate, err = impl.chartAdaptor(chart, isAppMetricsEnabled) return chartTemplate, err } @@ -855,30 +840,17 @@ func (impl ChartServiceImpl) UpdateAppOverride(ctx context.Context, templateRequ return nil, err } - appMetrics := templateRequest.IsAppMetricsEnabled - isAppMetricsSupported, err := impl.CheckIsAppMetricsSupported(templateRequest.ChartRefId) + appLevelMetricsUpdateReq := &bean.DeployedAppMetricsRequest{ + EnableMetrics: templateRequest.IsAppMetricsEnabled, + AppId: templateRequest.AppId, + ChartRefId: templateRequest.ChartRefId, + UserId: templateRequest.UserId, + } + err = impl.deployedAppMetricsService.CheckAndUpdateAppLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { + impl.logger.Errorw("error, CheckAndUpdateAppLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err } - if appMetrics && !(isAppMetricsSupported) { - appMetricRequest := AppMetricEnableDisableRequest{UserId: templateRequest.UserId, AppId: templateRequest.AppId, IsAppMetricsEnabled: false} - _, span = otel.Tracer("orchestrator").Start(ctx, "updateAppLevelMetrics") - _, err = impl.updateAppLevelMetrics(&appMetricRequest) - span.End() - if err != nil { - impl.logger.Errorw("error in disable app metric flag", "error", err) - return nil, err - } - } else { - appMetricsRequest := AppMetricEnableDisableRequest{UserId: templateRequest.UserId, AppId: templateRequest.AppId, IsAppMetricsEnabled: templateRequest.IsAppMetricsEnabled} - _, span = otel.Tracer("orchestrator").Start(ctx, "updateAppLevelMetrics") - _, err = impl.updateAppLevelMetrics(&appMetricsRequest) - span.End() - if err != nil { - impl.logger.Errorw("err while updating app metrics", "err", err) - return nil, err - } - } _, span = otel.Tracer("orchestrator").Start(ctx, "CreateDeploymentTemplateHistoryFromGlobalTemplate") //creating history entry for deployment template err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromGlobalTemplate(template, nil, templateRequest.IsAppMetricsEnabled) @@ -921,41 +893,6 @@ func (impl ChartServiceImpl) handleChartTypeChange(currentLatestChart *chartRepo return updatedOverride, nil } -func (impl ChartServiceImpl) updateAppLevelMetrics(appMetricRequest *AppMetricEnableDisableRequest) (*repository3.AppLevelMetrics, error) { - existingAppLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appMetricRequest.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in app metrics app level flag", "error", err) - return nil, err - } - if existingAppLevelMetrics != nil && existingAppLevelMetrics.Id != 0 { - existingAppLevelMetrics.AppMetrics = appMetricRequest.IsAppMetricsEnabled - err := impl.appLevelMetricsRepository.Update(existingAppLevelMetrics) - if err != nil { - impl.logger.Errorw("failed to update app level metrics flag", "error", err) - return nil, err - } - return existingAppLevelMetrics, nil - } else { - appLevelMetricsNew := &repository3.AppLevelMetrics{ - AppId: appMetricRequest.AppId, - AppMetrics: appMetricRequest.IsAppMetricsEnabled, - InfraMetrics: true, - AuditLog: sql.AuditLog{ - CreatedOn: time.Now(), - UpdatedOn: time.Now(), - CreatedBy: appMetricRequest.UserId, - UpdatedBy: appMetricRequest.UserId, - }, - } - err = impl.appLevelMetricsRepository.Save(appLevelMetricsNew) - if err != nil { - impl.logger.Errorw("error in saving app level metrics flag", "error", err) - return appLevelMetricsNew, err - } - return appLevelMetricsNew, nil - } -} - type IsReady struct { Flag bool `json:"flag"` Message string `json:"message"` @@ -1129,7 +1066,7 @@ func (impl ChartServiceImpl) FindPreviousChartByAppId(appId int) (chartTemplate impl.logger.Errorw("error in fetching chart ", "appId", appId, "err", err) return nil, err } - chartTemplate, err = impl.chartAdaptor(chart, nil) + chartTemplate, err = impl.chartAdaptor(chart, false) return chartTemplate, err } @@ -1207,13 +1144,12 @@ func (impl ChartServiceImpl) UpgradeForApp(appId int, chartRefId int, newAppOver impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envOverrideNew.TargetEnvironment) return false, err } else if err == pg.ErrNoRows { - appLevelAppMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting app level app metrics", "err", err, "appId", appId) + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) return false, err - } else if err == nil { - isAppMetricsEnabled = appLevelAppMetrics.AppMetrics } + isAppMetricsEnabled = isAppLevelMetricsEnabled } else { isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics } @@ -1232,65 +1168,6 @@ func (impl ChartServiceImpl) UpgradeForApp(appId int, chartRefId int, newAppOver return true, nil } -// below method is deprecated - -func (impl ChartServiceImpl) AppMetricsEnableDisable(appMetricRequest AppMetricEnableDisableRequest) (*AppMetricEnableDisableRequest, error) { - currentChart, err := impl.chartRepository.FindLatestChartForAppByAppId(appMetricRequest.AppId) - if err != nil && pg.ErrNoRows != err { - impl.logger.Error(err) - return nil, err - } - if pg.ErrNoRows == err { - impl.logger.Errorw("no chart configured for this app", "appId", appMetricRequest.AppId) - err = &util.ApiError{ - HttpStatusCode: http.StatusNotFound, - InternalMessage: "no chart configured for this app", - UserMessage: "no chart configured for this app", - } - return nil, err - } - // validate app metrics compatibility - refChart, err := impl.chartRefRepository.FindById(currentChart.ChartRefId) - if err != nil { - impl.logger.Error(err) - return nil, err - } - if appMetricRequest.IsAppMetricsEnabled == true { - chartMajorVersion, chartMinorVersion, err := util2.ExtractChartVersion(currentChart.ChartVersion) - if err != nil { - impl.logger.Errorw("chart version parsing", "err", err) - return nil, err - } - - if !refChart.UserUploaded && !(chartMajorVersion >= 3 && chartMinorVersion >= 7) { - err = &util.ApiError{ - InternalMessage: "chart version in not compatible for app metrics", - UserMessage: "chart version in not compatible for app metrics", - } - return nil, err - } - } - //update or create app level app metrics - appLevelMetrics, err := impl.updateAppLevelMetrics(&appMetricRequest) - if err != nil { - impl.logger.Errorw("error in saving app level metrics flag", "error", err) - return nil, err - } - //updating audit log details of chart as history service uses it - currentChart.UpdatedOn = time.Now() - currentChart.UpdatedBy = appMetricRequest.UserId - //creating history entry for deployment template - err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromGlobalTemplate(currentChart, nil, appMetricRequest.IsAppMetricsEnabled) - if err != nil { - impl.logger.Errorw("error in creating entry for deployment template history", "err", err, "chart", currentChart) - return nil, err - } - if appLevelMetrics.Id > 0 { - return &appMetricRequest, nil - } - return nil, err -} - const memoryPattern = `"1000Mi" or "1Gi"` const cpuPattern = `"50m" or "0.05"` const cpu = "cpu" diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go new file mode 100644 index 0000000000..2dcf0096d3 --- /dev/null +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -0,0 +1,117 @@ +package deployedAppMetrics + +import ( + "context" + interalRepo "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internal/util" + chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" + "github.com/devtron-labs/devtron/pkg/sql" + "github.com/go-pg/pg" + "go.opentelemetry.io/otel" + "go.uber.org/zap" + "time" +) + +type DeployedAppMetricsService interface { + GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) + CheckAndUpdateAppLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error +} + +type DeployedAppMetricsServiceImpl struct { + logger *zap.SugaredLogger + chartRefRepository chartRepoRepository.ChartRefRepository + appLevelMetricsRepository interalRepo.AppLevelMetricsRepository + envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository +} + +func NewDeployedAppMetricsServiceImpl(logger *zap.SugaredLogger, + chartRefRepository chartRepoRepository.ChartRefRepository, + appLevelMetricsRepository interalRepo.AppLevelMetricsRepository, + envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository) *DeployedAppMetricsServiceImpl { + return &DeployedAppMetricsServiceImpl{ + logger: logger, + chartRefRepository: chartRefRepository, + appLevelMetricsRepository: appLevelMetricsRepository, + envLevelMetricsRepository: envLevelMetricsRepository, + } +} + +func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) { + isAppMetricsEnabled := false + appMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Errorw("error in fetching app level metrics", "appId", appId, "err", err) + return isAppMetricsEnabled, err + } + if appMetrics != nil { + isAppMetricsEnabled = appMetrics.AppMetrics + } + return isAppMetricsEnabled, nil +} + +// CheckAndUpdateAppLevelMetrics - this method checks whether chart being used supports metrics or not and update accordingly +func (impl *DeployedAppMetricsServiceImpl) CheckAndUpdateAppLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error { + isAppMetricsSupported, err := impl.checkIsAppMetricsSupported(req.ChartRefId) + if err != nil { + return err + } + if !(isAppMetricsSupported) { + //chart does not have metrics support, disabling + req.EnableMetrics = false + } + _, span := otel.Tracer("orchestrator").Start(ctx, "updateAppLevelMetrics") + _, err = impl.updateAppLevelMetrics(req) + span.End() + if err != nil { + impl.logger.Errorw("error in disable app metric flag", "error", err) + return err + } + return nil +} + +func (impl *DeployedAppMetricsServiceImpl) checkIsAppMetricsSupported(chartRefId int) (bool, error) { + chartRefValue, err := impl.chartRefRepository.FindById(chartRefId) + if err != nil { + impl.logger.Errorw("error in finding reference chart by id", "err", err) + return false, nil + } + return chartRefValue.IsAppMetricsSupported, nil +} + +func (impl *DeployedAppMetricsServiceImpl) updateAppLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.AppLevelMetrics, error) { + existingAppLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(req.AppId) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in app metrics app level flag", "error", err) + return nil, err + } + if existingAppLevelMetrics != nil && existingAppLevelMetrics.Id != 0 { + existingAppLevelMetrics.AppMetrics = req.EnableMetrics + existingAppLevelMetrics.UpdatedBy = req.UserId + existingAppLevelMetrics.UpdatedOn = time.Now() + err := impl.appLevelMetricsRepository.Update(existingAppLevelMetrics) + if err != nil { + impl.logger.Errorw("error in to updating app level metrics", "error", err, "model", existingAppLevelMetrics) + return nil, err + } + return existingAppLevelMetrics, nil + } else { + appLevelMetricsNew := &interalRepo.AppLevelMetrics{ + AppId: req.AppId, + AppMetrics: req.EnableMetrics, + InfraMetrics: true, + AuditLog: sql.AuditLog{ + CreatedOn: time.Now(), + UpdatedOn: time.Now(), + CreatedBy: req.UserId, + UpdatedBy: req.UserId, + }, + } + err = impl.appLevelMetricsRepository.Save(appLevelMetricsNew) + if err != nil { + impl.logger.Errorw("error in saving app level metrics flag", "error", err, "model", appLevelMetricsNew) + return appLevelMetricsNew, err + } + return appLevelMetricsNew, nil + } +} diff --git a/pkg/deployment/manifest/deployedAppMetrics/bean/bean.go b/pkg/deployment/manifest/deployedAppMetrics/bean/bean.go new file mode 100644 index 0000000000..42761fdc48 --- /dev/null +++ b/pkg/deployment/manifest/deployedAppMetrics/bean/bean.go @@ -0,0 +1,9 @@ +package bean + +type DeployedAppMetricsRequest struct { + EnableMetrics bool + AppId int + EnvId int // if not zero then request for override + ChartRefId int + UserId int32 +} diff --git a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go new file mode 100644 index 0000000000..2c43ce535a --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go @@ -0,0 +1,16 @@ +package deploymentTemplate + +import "go.uber.org/zap" + +type DeploymentTemplateService interface { +} + +type DeploymentTemplateServiceImpl struct { + logger *zap.SugaredLogger +} + +func NewDeploymentTemplateServiceImpl(logger *zap.SugaredLogger) *DeploymentTemplateServiceImpl { + return &DeploymentTemplateServiceImpl{ + logger: logger, + } +} diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index fa7a7a8972..673bc39365 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -8,6 +8,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/pipeline/history" repository2 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" @@ -29,12 +30,12 @@ type DeploymentConfigServiceImpl struct { chartRepository chartRepoRepository.ChartRepository pipelineRepository pipelineConfig.PipelineRepository envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository - appLevelMetricsRepository repository.AppLevelMetricsRepository pipelineConfigRepository chartConfig.PipelineConfigRepository configMapRepository chartConfig.ConfigMapRepository configMapHistoryService history.ConfigMapHistoryService chartRefRepository chartRepoRepository.ChartRefRepository scopedVariableManager variables.ScopedVariableCMCSManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, @@ -42,25 +43,24 @@ func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, chartRepository chartRepoRepository.ChartRepository, pipelineRepository pipelineConfig.PipelineRepository, envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository, - appLevelMetricsRepository repository.AppLevelMetricsRepository, pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository, configMapHistoryService history.ConfigMapHistoryService, chartRefRepository chartRepoRepository.ChartRefRepository, scopedVariableManager variables.ScopedVariableCMCSManager, -) *DeploymentConfigServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentConfigServiceImpl { return &DeploymentConfigServiceImpl{ logger: logger, envConfigOverrideRepository: envConfigOverrideRepository, chartRepository: chartRepository, pipelineRepository: pipelineRepository, envLevelAppMetricsRepository: envLevelAppMetricsRepository, - appLevelMetricsRepository: appLevelMetricsRepository, pipelineConfigRepository: pipelineConfigRepository, configMapRepository: configMapRepository, configMapHistoryService: configMapHistoryService, chartRefRepository: chartRefRepository, scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -102,12 +102,12 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx c if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) } else if err == pg.ErrNoRows { - appLevelAppMetrics, err := impl.appLevelMetricsRepository.FindByAppId(pipeline.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting app level app metrics", "err", err, "appId", pipeline.AppId) - } else if err == nil { - isAppMetricsEnabled = appLevelAppMetrics.AppMetrics + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(pipeline.AppId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", pipeline.AppId) + return nil, err } + isAppMetricsEnabled = isAppLevelMetricsEnabled } else { isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics } diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index ca0c9df270..8a80c10bd3 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -41,6 +41,7 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" repository4 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" @@ -135,7 +136,6 @@ type CdPipelineConfigServiceImpl struct { resourceGroupService resourceGroup2.ResourceGroupService chartTemplateService util.ChartTemplateService propertiesConfigService PropertiesConfigService - appLevelMetricsRepository repository.AppLevelMetricsRepository deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager deploymentConfig *DeploymentServiceTypeConfig @@ -146,6 +146,7 @@ type CdPipelineConfigServiceImpl struct { ciPipelineConfigService CiPipelineConfigService buildPipelineSwitchService BuildPipelineSwitchService argoClientWrapperService argocdServer.ArgoClientWrapperService + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -159,12 +160,13 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor pipelineStrategyHistoryService history.PipelineStrategyHistoryService, chartRepository chartRepoRepository.ChartRepository, resourceGroupService resourceGroup2.ResourceGroupService, chartTemplateService util.ChartTemplateService, propertiesConfigService PropertiesConfigService, - appLevelMetricsRepository repository.AppLevelMetricsRepository, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, + deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, deploymentConfig *DeploymentServiceTypeConfig, application application.ServiceClient, customTagService CustomTagService, pipelineConfigListenerService PipelineConfigListenerService, devtronAppCMCSService DevtronAppCMCSService, ciPipelineConfigService CiPipelineConfigService, buildPipelineSwitchService BuildPipelineSwitchService, - argoClientWrapperService argocdServer.ArgoClientWrapperService) *CdPipelineConfigServiceImpl { + argoClientWrapperService argocdServer.ArgoClientWrapperService, + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -188,7 +190,6 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor resourceGroupService: resourceGroupService, chartTemplateService: chartTemplateService, propertiesConfigService: propertiesConfigService, - appLevelMetricsRepository: appLevelMetricsRepository, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, deploymentConfig: deploymentConfig, @@ -199,6 +200,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor ciPipelineConfigService: ciPipelineConfigService, buildPipelineSwitchService: buildPipelineSwitchService, argoClientWrapperService: argoClientWrapperService, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -1733,12 +1735,12 @@ func (impl *CdPipelineConfigServiceImpl) createCdPipeline(ctx context.Context, a } //getting global app metrics for cd pipeline create because env level metrics is not created yet appLevelAppMetricsEnabled := false - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(app.Id) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting app level metrics app level", "error", err) - } else if err == nil { - appLevelAppMetricsEnabled = appLevelMetrics.AppMetrics + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(app.Id) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", app.Id) + return 0, err } + appLevelAppMetricsEnabled = isAppLevelMetricsEnabled err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(envOverride, tx, appLevelAppMetricsEnabled, pipelineId) if err != nil { impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", envOverride) diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 342bbab976..1391bc5ce6 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -22,6 +22,7 @@ import ( "encoding/json" errors3 "errors" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "path" "strconv" "strings" @@ -188,7 +189,6 @@ type WorkflowDagExecutorImpl struct { helmAppClient client2.HelmAppClient chartRefRepository chartRepoRepository.ChartRefRepository environmentConfigRepository chartConfig.EnvConfigOverrideRepository - appLevelMetricsRepository repository.AppLevelMetricsRepository envLevelMetricsRepository repository.EnvLevelAppMetricsRepository dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil @@ -199,6 +199,7 @@ type WorkflowDagExecutorImpl struct { pipelineConfigListenerService PipelineConfigListenerService customTagService CustomTagService ACDConfig *argocdServer.ACDConfig + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } const kedaAutoscaling = "kedaAutoscaling" @@ -296,7 +297,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi helmAppClient client2.HelmAppClient, chartRefRepository chartRepoRepository.ChartRefRepository, environmentConfigRepository chartConfig.EnvConfigOverrideRepository, - appLevelMetricsRepository repository.AppLevelMetricsRepository, envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, @@ -307,7 +307,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi pipelineConfigListenerService PipelineConfigListenerService, customTagService CustomTagService, ACDConfig *argocdServer.ACDConfig, -) *WorkflowDagExecutorImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, @@ -373,7 +373,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi helmAppClient: helmAppClient, chartRefRepository: chartRefRepository, environmentConfigRepository: environmentConfigRepository, - appLevelMetricsRepository: appLevelMetricsRepository, envLevelMetricsRepository: envLevelMetricsRepository, dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, @@ -384,6 +383,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi pipelineConfigListenerService: pipelineConfigListenerService, customTagService: customTagService, ACDConfig: ACDConfig, + deployedAppMetricsService: deployedAppMetricsService, } config, err := types.GetCdConfig() if err != nil { @@ -3810,14 +3810,12 @@ func (impl *WorkflowDagExecutorImpl) GetAppMetricsByTriggerType(overrideRequest } else if overrideRequest.DeploymentWithConfig == bean.DEPLOYMENT_CONFIG_TYPE_LAST_SAVED { _, span := otel.Tracer("orchestrator").Start(ctx, "appLevelMetricsRepository.FindByAppId") - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(overrideRequest.AppId) - span.End() - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("err", err) - return appMetrics, &util.ApiError{InternalMessage: "unable to fetch app level metrics flag"} + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(overrideRequest.AppId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", overrideRequest.AppId) + return appMetrics, err } - appMetrics = appLevelMetrics.AppMetrics - + appMetrics = isAppLevelMetricsEnabled _, span = otel.Tracer("orchestrator").Start(ctx, "envLevelMetricsRepository.FindByAppIdAndEnvId") envLevelMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(overrideRequest.AppId, overrideRequest.EnvId) span.End() diff --git a/pkg/pipeline/history/DeploymentTemplateHistoryService.go b/pkg/pipeline/history/DeploymentTemplateHistoryService.go index 645d42c1cf..1d41cf373d 100644 --- a/pkg/pipeline/history/DeploymentTemplateHistoryService.go +++ b/pkg/pipeline/history/DeploymentTemplateHistoryService.go @@ -2,6 +2,7 @@ package history import ( "context" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "time" repository2 "github.com/devtron-labs/devtron/internal/sql/repository" @@ -40,10 +41,10 @@ type DeploymentTemplateHistoryServiceImpl struct { chartRepository chartRepoRepository.ChartRepository chartRefRepository chartRepoRepository.ChartRefRepository envLevelAppMetricsRepository repository2.EnvLevelAppMetricsRepository - appLevelMetricsRepository repository2.AppLevelMetricsRepository userService user.UserService cdWorkflowRepository pipelineConfig.CdWorkflowRepository scopedVariableManager variables.ScopedVariableManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deploymentTemplateHistoryRepository repository.DeploymentTemplateHistoryRepository, @@ -51,11 +52,10 @@ func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deployme chartRepository chartRepoRepository.ChartRepository, chartRefRepository chartRepoRepository.ChartRefRepository, envLevelAppMetricsRepository repository2.EnvLevelAppMetricsRepository, - appLevelMetricsRepository repository2.AppLevelMetricsRepository, userService user.UserService, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, scopedVariableManager variables.ScopedVariableManager, -) *DeploymentTemplateHistoryServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentTemplateHistoryServiceImpl { return &DeploymentTemplateHistoryServiceImpl{ logger: logger, deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, @@ -63,10 +63,10 @@ func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deployme chartRepository: chartRepository, chartRefRepository: chartRefRepository, envLevelAppMetricsRepository: envLevelAppMetricsRepository, - appLevelMetricsRepository: appLevelMetricsRepository, userService: userService, cdWorkflowRepository: cdWorkflowRepository, scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -214,13 +214,12 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) return nil, err } else if err == pg.ErrNoRows { - appLevelAppMetrics, err := impl.appLevelMetricsRepository.FindByAppId(pipeline.AppId) - if err != nil && err != pg.ErrNoRows { + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(pipeline.AppId) + if err != nil { impl.logger.Errorw("error in getting app level app metrics", "err", err, "appId", pipeline.AppId) return nil, err - } else if err == nil { - isAppMetricsEnabled = appLevelAppMetrics.AppMetrics } + isAppMetricsEnabled = isAppLevelMetricsEnabled } else { isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics } diff --git a/wire_gen.go b/wire_gen.go index 600ede7536..8520b05196 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -102,6 +102,7 @@ import ( "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -305,8 +306,6 @@ func InitializeApp() (*App, error) { appListingRepositoryImpl := repository.NewAppListingRepositoryImpl(sugaredLogger, db, appListingRepositoryQueryBuilder, environmentRepositoryImpl) pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) configMapRepositoryImpl := chartConfig.NewConfigMapRepositoryImpl(sugaredLogger, db) - appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) - envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) gitProviderRepositoryImpl := repository.NewGitProviderRepositoryImpl(db) @@ -355,11 +354,14 @@ func InitializeApp() (*App, error) { configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) deploymentTemplateHistoryRepositoryImpl := repository6.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) + envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) if err != nil { return nil, err } - deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl) + appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, chartRefRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl) + deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, envLevelAppMetricsRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) chartWorkingDir := _wireChartWorkingDirValue globalEnvVariables, err := util3.GetGlobalEnvVariables() if err != nil { @@ -373,7 +375,7 @@ func InitializeApp() (*App, error) { Logger: sugaredLogger, } repositoryServiceClientImpl := repository9.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) - chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl) + chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) devtronSecretConfig, err := util3.GetDevtronSecretName() if err != nil { return nil, err @@ -426,7 +428,7 @@ func InitializeApp() (*App, error) { k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) manifestPushConfigRepositoryImpl := repository11.NewManifestPushConfigRepository(sugaredLogger, db) gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, chartServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, dbMigrationConfigRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, dbMigrationConfigRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) validate, err := util.IntValidator() if err != nil { return nil, err @@ -467,10 +469,10 @@ func InitializeApp() (*App, error) { customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, envLevelAppMetricsRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) - deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl) + deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl) pipelineTriggerRestHandlerImpl := restHandler.NewPipelineRestHandler(appServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, workflowDagExecutorImpl, deploymentGroupServiceImpl, argoUserServiceImpl, deploymentConfigServiceImpl) sseSSE := sse.NewSSE() pipelineTriggerRouterImpl := router.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) @@ -505,7 +507,7 @@ func InitializeApp() (*App, error) { return nil, err } devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, pipelineDeploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, pipelineDeploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) From e42180bfd646a52b569ff86a7a45a41806c61e6f Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 11 Jan 2024 20:25:07 +0530 Subject: [PATCH 03/83] migrated envLevel app metrics code to new service --- api/restHandler/CoreAppRestHandler.go | 17 +- .../app/DeploymentPipelineRestHandler.go | 62 +---- .../app/PipelineConfigRestHandler.go | 6 +- api/router/PipelineConfigRouter.go | 2 - .../EnvLevelAppMetricsRepository.go | 3 +- pkg/app/AppListingService.go | 50 +--- pkg/bulkAction/BulkUpdateService.go | 41 +--- pkg/chart/ChartService.go | 31 +-- .../deployedAppMetrics/DeployedAppMetrics.go | 122 +++++++++- pkg/pipeline/DeploymentConfigService.go | 61 ++--- .../DeploymentPipelineConfigService.go | 22 +- pkg/pipeline/PropertiesConfig.go | 224 ++++-------------- pkg/pipeline/WorkflowDagExecutor.go | 20 +- .../DeploymentTemplateHistoryService.go | 29 +-- wire_gen.go | 18 +- 15 files changed, 251 insertions(+), 457 deletions(-) diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 6d7f20171f..5a0ccf43f4 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -1857,12 +1857,13 @@ func (handler CoreAppRestHandlerImpl) createEnvDeploymentTemplate(appId int, use appMetrics = *envConfigProperties.AppMetrics } chartEntry.GlobalOverride = string(envConfigProperties.EnvOverrideValues) - _, err = handler.propertiesConfigService.CreateIfRequired(chartEntry, envId, userId, envConfigProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, + _, updatedAppMetrics, err := handler.propertiesConfigService.CreateIfRequired(chartEntry, envId, userId, envConfigProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, true, appMetrics, envConfigProperties.Namespace, envConfigProperties.IsBasicViewLocked, envConfigProperties.CurrentViewEditor, nil) if err != nil { handler.logger.Errorw("service err, CreateIfRequired", "err", err, "appId", appId, "envId", envId, "chartRefId", chartRefId) return err } + envConfigProperties.AppMetrics = &updatedAppMetrics //getting environment properties for db table id(this properties get created when cd pipeline is created) env, err := handler.propertiesConfigService.GetEnvironmentProperties(appId, envId, deploymentTemplateOverride.ChartRefId) @@ -1879,20 +1880,6 @@ func (handler CoreAppRestHandlerImpl) createEnvDeploymentTemplate(appId int, use handler.logger.Errorw("service err, EnvConfigOverrideUpdate", "err", err, "appId", appId, "envId", envId) return err } - - //updating app metrics - appMetricsRequest := &chart.AppMetricEnableDisableRequest{ - AppId: appId, - UserId: userId, - EnvironmentId: envId, - IsAppMetricsEnabled: deploymentTemplateOverride.ShowAppMetrics, - } - _, err = handler.propertiesConfigService.EnvMetricsEnableDisable(appMetricsRequest) - if err != nil { - handler.logger.Errorw("service err, EnvMetricsEnableDisable", "err", err, "appId", appId, "envId", envId) - return err - } - return nil } diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index c7dc4f7da6..6516880e78 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -80,8 +80,6 @@ type DevtronAppDeploymentConfigRestHandler interface { GetDeploymentPipelineStrategy(w http.ResponseWriter, r *http.Request) GetDefaultDeploymentPipelineStrategy(w http.ResponseWriter, r *http.Request) - EnvMetricsEnableDisable(w http.ResponseWriter, r *http.Request) - EnvConfigOverrideCreateNamespace(w http.ResponseWriter, r *http.Request) } @@ -564,7 +562,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite } } - envMetrics, err := handler.propertiesConfigService.FindEnvLevelAppMetricsByAppIdAndEnvId(request.AppId, request.EnvId) + envMetrics, err := handler.deployedAppMetricsService.GetMetricsFlagByAppIdAndEnvId(request.AppId, request.EnvId) if err != nil { handler.Logger.Errorw("could not find envMetrics for, ChangeChartRef", "err", err, "payload", request) common.WriteJsonResp(w, err, "env metric could not be fetched", http.StatusBadRequest) @@ -573,7 +571,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite envConfigProperties.ChartRefId = request.TargetChartRefId envConfigProperties.UserId = userId envConfigProperties.EnvironmentId = request.EnvId - envConfigProperties.AppMetrics = envMetrics.AppMetrics + envConfigProperties.AppMetrics = &envMetrics token := r.Header.Get("token") handler.Logger.Infow("request payload, EnvConfigOverrideCreate", "payload", request) @@ -635,7 +633,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite ctx = context.WithValue(r.Context(), "token", acdToken) appMetrics := false if envConfigProperties.AppMetrics != nil { - appMetrics = *envMetrics.AppMetrics + appMetrics = envMetrics } templateRequest := chart.TemplateRequest{ AppId: request.AppId, @@ -1699,60 +1697,6 @@ func (handler PipelineConfigRestHandlerImpl) EnvConfigOverrideReset(w http.Respo common.WriteJsonResp(w, err, isSuccess, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) EnvMetricsEnableDisable(w http.ResponseWriter, r *http.Request) { - userId, err := handler.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - token := r.Header.Get("token") - vars := mux.Vars(r) - appId, err := strconv.Atoi(vars["appId"]) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - environmentId, err := strconv.Atoi(vars["environmentId"]) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - decoder := json.NewDecoder(r.Body) - var appMetricEnableDisableRequest chart.AppMetricEnableDisableRequest - err = decoder.Decode(&appMetricEnableDisableRequest) - appMetricEnableDisableRequest.UserId = userId - appMetricEnableDisableRequest.AppId = appId - appMetricEnableDisableRequest.EnvironmentId = environmentId - if err != nil { - handler.Logger.Errorw("request err, EnvMetricsEnableDisable", "err", err, "appId", appId, "environmentId", environmentId, "payload", appMetricEnableDisableRequest) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.Logger.Infow("request payload, EnvMetricsEnableDisable", "err", err, "appId", appId, "environmentId", environmentId, "payload", appMetricEnableDisableRequest) - app, err := handler.pipelineBuilder.GetApp(appId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - resourceName := handler.enforcerUtil.GetAppRBACNameByAppId(appId) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - object := handler.enforcerUtil.GetAppRBACByAppNameAndEnvId(app.AppName, appMetricEnableDisableRequest.EnvironmentId) - if ok := handler.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionCreate, object); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - createResp, err := handler.propertiesConfigService.EnvMetricsEnableDisable(&appMetricEnableDisableRequest) - if err != nil { - handler.Logger.Errorw("service err, EnvMetricsEnableDisable", "err", err, "appId", appId, "environmentId", environmentId, "payload", appMetricEnableDisableRequest) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, createResp, http.StatusOK) -} - func (handler *PipelineConfigRestHandlerImpl) ListDeploymentHistory(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/PipelineConfigRestHandler.go index cf88641e43..13ff4f3e37 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/PipelineConfigRestHandler.go @@ -22,6 +22,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "io" "net/http" "strconv" @@ -132,6 +133,7 @@ type PipelineConfigRestHandlerImpl struct { deploymentTemplateService generateManifest.DeploymentTemplateService pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig ciArtifactRepository repository.CiArtifactRepository + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger, @@ -156,7 +158,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger scanResultRepository security.ImageScanResultRepository, gitProviderRepo repository.GitProviderRepository, argoUserService argo.ArgoUserService, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, imageTaggingService pipeline.ImageTaggingService, - ciArtifactRepository repository.CiArtifactRepository) *PipelineConfigRestHandlerImpl { + ciArtifactRepository repository.CiArtifactRepository, + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *PipelineConfigRestHandlerImpl { envConfig := &PipelineRestHandlerEnvConfig{} err := env.Parse(envConfig) if err != nil { @@ -194,6 +197,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger deploymentTemplateService: deploymentTemplateService, pipelineRestHandlerEnvConfig: envConfig, ciArtifactRepository: ciArtifactRepository, + deployedAppMetricsService: deployedAppMetricsService, } } diff --git a/api/router/PipelineConfigRouter.go b/api/router/PipelineConfigRouter.go index 2fb48b3d8d..c28c2364ee 100644 --- a/api/router/PipelineConfigRouter.go +++ b/api/router/PipelineConfigRouter.go @@ -134,8 +134,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/env/reset/{appId}/{environmentId}/{id}").HandlerFunc(router.restHandler.EnvConfigOverrideReset).Methods("DELETE") configRouter.Path("/env/namespace/{appId}/{environmentId}").HandlerFunc(router.restHandler.EnvConfigOverrideCreateNamespace).Methods("POST") - configRouter.Path("/env/metrics/{appId}/{environmentId}").HandlerFunc(router.restHandler.EnvMetricsEnableDisable).Methods("POST") - configRouter.Path("/app-wf"). HandlerFunc(router.appWorkflowRestHandler.CreateAppWorkflow).Methods("POST") diff --git a/internal/sql/repository/EnvLevelAppMetricsRepository.go b/internal/sql/repository/EnvLevelAppMetricsRepository.go index c26ce4146e..f849212fab 100644 --- a/internal/sql/repository/EnvLevelAppMetricsRepository.go +++ b/internal/sql/repository/EnvLevelAppMetricsRepository.go @@ -57,7 +57,8 @@ func (impl *EnvLevelAppMetricsRepositoryImpl) Save(metrics *EnvLevelAppMetrics) func (impl *EnvLevelAppMetricsRepositoryImpl) FindByAppIdAndEnvId(appId int, envId int) (*EnvLevelAppMetrics, error) { envAppLevelMetrics := &EnvLevelAppMetrics{} - err := impl.dbConnection.Model(envAppLevelMetrics).Where("env_level_app_metrics.app_id = ? ", appId).Where("env_level_app_metrics.env_id = ? ", envId).Select() + err := impl.dbConnection.Model(envAppLevelMetrics).Where("env_level_app_metrics.app_id = ? ", appId). + Where("env_level_app_metrics.env_id = ? ", envId).Select() return envAppLevelMetrics, err } func (impl *EnvLevelAppMetricsRepositoryImpl) FindByAppId(appId int) ([]*EnvLevelAppMetrics, error) { diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index f93bd4408a..207bec1fd3 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -160,7 +160,6 @@ type AppListingServiceImpl struct { cdWorkflowRepository pipelineConfig.CdWorkflowRepository linkoutsRepository repository.LinkoutsRepository appLevelMetricsRepository repository.AppLevelMetricsRepository - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository pipelineOverrideRepository chartConfig.PipelineOverrideRepository environmentRepository repository2.EnvironmentRepository argoUserService argo.ArgoUserService @@ -175,7 +174,7 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re application application2.ServiceClient, appRepository app.AppRepository, appListingViewBuilder AppListingViewBuilder, pipelineRepository pipelineConfig.PipelineRepository, linkoutsRepository repository.LinkoutsRepository, appLevelMetricsRepository repository.AppLevelMetricsRepository, - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, + cdWorkflowRepository pipelineConfig.CdWorkflowRepository, pipelineOverrideRepository chartConfig.PipelineOverrideRepository, environmentRepository repository2.EnvironmentRepository, argoUserService argo.ArgoUserService, envOverrideRepository chartConfig.EnvConfigOverrideRepository, chartRepository chartRepoRepository.ChartRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, @@ -189,7 +188,6 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re pipelineRepository: pipelineRepository, linkoutsRepository: linkoutsRepository, appLevelMetricsRepository: appLevelMetricsRepository, - envLevelMetricsRepository: envLevelMetricsRepository, cdWorkflowRepository: cdWorkflowRepository, pipelineOverrideRepository: pipelineOverrideRepository, environmentRepository: environmentRepository, @@ -885,52 +883,6 @@ func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int return appDetailContainer, nil } -func (impl AppListingServiceImpl) fetchAppAndEnvLevelMatrics(ctx context.Context, appId int, appDetailContainer bean.AppDetailContainer) (bean.AppDetailContainer, error) { - var appMetrics bool - var infraMetrics bool - _, span := otel.Tracer("orchestrator").Start(ctx, "appLevelMetricsRepository.FindByAppId") - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - span.End() - if err != nil && err != pg.ErrNoRows { - impl.Logger.Errorw("error in app metrics app level flag", "error", err) - return bean.AppDetailContainer{}, err - } else if appLevelMetrics != nil { - appMetrics = appLevelMetrics.AppMetrics - infraMetrics = appLevelMetrics.InfraMetrics - } - i := 0 - var envIds []int - for _, env := range appDetailContainer.Environments { - envIds = append(envIds, env.EnvironmentId) - } - envLevelAppMetricsMap := make(map[int]*repository.EnvLevelAppMetrics) - _, span = otel.Tracer("orchestrator").Start(ctx, "appLevelMetricsRepository.FindByAppIdAndEnvIds") - envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvIds(appId, envIds) - span.End() - for _, envLevelAppMetric := range envLevelAppMetrics { - envLevelAppMetricsMap[envLevelAppMetric.EnvId] = envLevelAppMetric - } - for _, env := range appDetailContainer.Environments { - var envLevelMetrics *bool - var envLevelInfraMetrics *bool - envLevelAppMetrics := envLevelAppMetricsMap[env.EnvironmentId] - if envLevelAppMetrics != nil && envLevelAppMetrics.Id != 0 && envLevelAppMetrics.AppMetrics != nil { - envLevelMetrics = envLevelAppMetrics.AppMetrics - } else { - envLevelMetrics = &appMetrics - } - if envLevelAppMetrics != nil && envLevelAppMetrics.Id != 0 && envLevelAppMetrics.InfraMetrics != nil { - envLevelInfraMetrics = envLevelAppMetrics.InfraMetrics - } else { - envLevelInfraMetrics = &infraMetrics - } - appDetailContainer.Environments[i].AppMetrics = envLevelMetrics - appDetailContainer.Environments[i].InfraMetrics = envLevelInfraMetrics - i++ - } - return appDetailContainer, nil -} - func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, appDetailContainer bean.AppDetailContainer, clusterId int, isVirtualEnv bool) (bean.AppDetailContainer, error) { ciPipelineId := appDetailContainer.CiPipelineId if ciPipelineId > 0 { diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index c60c415a0b..9991ca32ee 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -14,7 +14,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/sql/models" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" @@ -26,6 +25,7 @@ import ( "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/pipeline" pipeline1 "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -77,8 +77,6 @@ type BulkUpdateServiceImpl struct { configMapRepository chartConfig.ConfigMapRepository environmentRepository repository2.EnvironmentRepository pipelineRepository pipelineConfig.PipelineRepository - appLevelMetricsRepository repository3.AppLevelMetricsRepository - envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository client *http.Client appRepository app.AppRepository deploymentTemplateHistoryService history.DeploymentTemplateHistoryService @@ -96,6 +94,7 @@ type BulkUpdateServiceImpl struct { pubsubClient *pubsub.PubSubClientServiceImpl argoUserService argo.ArgoUserService scopedVariableManager variables.ScopedVariableManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateRepository, @@ -112,8 +111,6 @@ func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateReposito configMapRepository chartConfig.ConfigMapRepository, environmentRepository repository2.EnvironmentRepository, pipelineRepository pipelineConfig.PipelineRepository, - appLevelMetricsRepository repository3.AppLevelMetricsRepository, - envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository, client *http.Client, appRepository app.AppRepository, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, @@ -127,7 +124,7 @@ func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateReposito pubsubClient *pubsub.PubSubClientServiceImpl, argoUserService argo.ArgoUserService, scopedVariableManager variables.ScopedVariableManager, -) (*BulkUpdateServiceImpl, error) { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) (*BulkUpdateServiceImpl, error) { impl := &BulkUpdateServiceImpl{ bulkUpdateRepository: bulkUpdateRepository, chartRepository: chartRepository, @@ -143,8 +140,6 @@ func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateReposito configMapRepository: configMapRepository, environmentRepository: environmentRepository, pipelineRepository: pipelineRepository, - appLevelMetricsRepository: appLevelMetricsRepository, - envLevelAppMetricsRepository: envLevelAppMetricsRepository, client: client, appRepository: appRepository, deploymentTemplateHistoryService: deploymentTemplateHistoryService, @@ -162,6 +157,7 @@ func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateReposito pubsubClient: pubsubClient, argoUserService: argoUserService, scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } err := impl.SubscribeToCdBulkTriggerTopic() @@ -457,12 +453,10 @@ func (impl BulkUpdateServiceImpl) BulkUpdateDeploymentTemplate(bulkUpdatePayload deploymentTemplateBulkUpdateResponse.Successful = append(deploymentTemplateBulkUpdateResponse.Successful, bulkUpdateSuccessResponse) //creating history entry for deployment template - appLevelAppMetricsEnabled := false - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(chart.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting app level metrics app level", "error", err) - } else if err == nil { - appLevelAppMetricsEnabled = appLevelMetrics.AppMetrics + appLevelAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(chart.AppId) + if err != nil { + impl.logger.Errorw("error in getting app level metrics app level", "error", err, "appId", chart.AppId) + return nil } chart.GlobalOverride = modified chart.Values = modified @@ -525,22 +519,13 @@ func (impl BulkUpdateServiceImpl) BulkUpdateDeploymentTemplate(bulkUpdatePayload deploymentTemplateBulkUpdateResponse.Successful = append(deploymentTemplateBulkUpdateResponse.Successful, bulkUpdateSuccessResponse) //creating history entry for deployment template - envLevelAppMetricsEnabled := false - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(chartEnv.Chart.AppId, chartEnv.TargetEnvironment) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", chartEnv.Chart.AppId, "envId", chartEnv.TargetEnvironment) - } else if err == pg.ErrNoRows { - appLevelAppMetrics, err := impl.appLevelMetricsRepository.FindByAppId(chartEnv.Chart.AppId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting app level app metrics", "err", err, "appId", chartEnv.Chart.AppId) - } else if err == nil { - envLevelAppMetricsEnabled = appLevelAppMetrics.AppMetrics - } - } else { - envLevelAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(chartEnv.Chart.AppId, chartEnv.TargetEnvironment) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", chartEnv.Chart.AppId, "envId", chartEnv.TargetEnvironment) + return nil } chartEnv.EnvOverrideValues = modified - err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(chartEnv, nil, envLevelAppMetricsEnabled, 0) + err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(chartEnv, nil, isAppMetricsEnabled, 0) if err != nil { impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", chartEnv) } diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index ca6397f113..ceb5956051 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -54,7 +54,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/sql/models" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" @@ -116,7 +115,6 @@ type ChartServiceImpl struct { configMapRepository chartConfig.ConfigMapRepository environmentRepository repository4.EnvironmentRepository pipelineRepository pipelineConfig.PipelineRepository - envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository client *http.Client deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager @@ -138,7 +136,6 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, configMapRepository chartConfig.ConfigMapRepository, environmentRepository repository4.EnvironmentRepository, pipelineRepository pipelineConfig.PipelineRepository, - envLevelAppMetricsRepository repository3.EnvLevelAppMetricsRepository, client *http.Client, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, @@ -147,7 +144,6 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, // cache devtron reference charts list devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) SetReservedChartList(devtronChartList) - return &ChartServiceImpl{ chartRepository: chartRepository, logger: logger, @@ -164,7 +160,6 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, configMapRepository: configMapRepository, environmentRepository: environmentRepository, pipelineRepository: pipelineRepository, - envLevelAppMetricsRepository: envLevelAppMetricsRepository, client: client, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, @@ -449,9 +444,9 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context ChartRefId: templateRequest.ChartRefId, UserId: templateRequest.UserId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppLevelMetrics(ctx, appLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { - impl.logger.Errorw("error, CheckAndUpdateAppLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) + impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err } @@ -846,14 +841,14 @@ func (impl ChartServiceImpl) UpdateAppOverride(ctx context.Context, templateRequ ChartRefId: templateRequest.ChartRefId, UserId: templateRequest.UserId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppLevelMetrics(ctx, appLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { - impl.logger.Errorw("error, CheckAndUpdateAppLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) + impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err } _, span = otel.Tracer("orchestrator").Start(ctx, "CreateDeploymentTemplateHistoryFromGlobalTemplate") //creating history entry for deployment template - err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromGlobalTemplate(template, nil, templateRequest.IsAppMetricsEnabled) + err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromGlobalTemplate(template, nil, appLevelMetricsUpdateReq.EnableMetrics) span.End() if err != nil { impl.logger.Errorw("error in creating entry for deployment template history", "err", err, "chart", template) @@ -1138,20 +1133,10 @@ func (impl ChartServiceImpl) UpgradeForApp(appId int, chartRefId int, newAppOver return false, err } //creating history entry for deployment template - isAppMetricsEnabled := false - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(appId, envOverrideNew.TargetEnvironment) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envOverrideNew.TargetEnvironment) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(appId, envOverrideNew.TargetEnvironment) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", appId, "envId", envOverrideNew.TargetEnvironment) return false, err - } else if err == pg.ErrNoRows { - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) - if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) - return false, err - } - isAppMetricsEnabled = isAppLevelMetricsEnabled - } else { - isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics } err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(envOverrideNew, nil, isAppMetricsEnabled, 0) if err != nil { diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index 2dcf0096d3..b04de22cff 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -15,7 +15,10 @@ import ( type DeployedAppMetricsService interface { GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) - CheckAndUpdateAppLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error + GetMetricsFlagByAppIdAndEnvId(appId, envId int) (bool, error) + GetMetricsFlagForAPipelineByAppIdAndEnvId(appId, envId int) (bool, error) + CheckAndUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error + DeleteEnvLevelMetricsIfPresent(appId, envId int) error } type DeployedAppMetricsServiceImpl struct { @@ -40,7 +43,7 @@ func NewDeployedAppMetricsServiceImpl(logger *zap.SugaredLogger, func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) { isAppMetricsEnabled := false appMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && !util.IsErrNoRows(err) { + if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in fetching app level metrics", "appId", appId, "err", err) return isAppMetricsEnabled, err } @@ -50,8 +53,41 @@ func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdEvenIfNotInDb(ap return isAppMetricsEnabled, nil } -// CheckAndUpdateAppLevelMetrics - this method checks whether chart being used supports metrics or not and update accordingly -func (impl *DeployedAppMetricsServiceImpl) CheckAndUpdateAppLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error { +func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdAndEnvId(appId, envId int) (bool, error) { + isAppMetricsEnabled := false + envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(appId, envId) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envId) + return isAppMetricsEnabled, err + } + if envLevelAppMetrics != nil { + isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + } + return isAppMetricsEnabled, nil +} + +// GetMetricsFlagForAPipelineByAppIdAndEnvId - this function returns metrics flag for pipeline after resolving override and app level values +func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagForAPipelineByAppIdAndEnvId(appId, envId int) (bool, error) { + isAppMetricsEnabled := false + envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(appId, envId) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envId) + return isAppMetricsEnabled, err + } else if err == pg.ErrNoRows { + isAppLevelMetricsEnabled, err := impl.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) + return false, err + } + isAppMetricsEnabled = isAppLevelMetricsEnabled + } else if envLevelAppMetrics != nil && envLevelAppMetrics.AppMetrics != nil { + isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + } + return isAppMetricsEnabled, nil +} + +// CheckAndUpdateAppOrEnvLevelMetrics - this method checks whether chart being used supports metrics or not, is app level or env level and updates accordingly +func (impl *DeployedAppMetricsServiceImpl) CheckAndUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error { isAppMetricsSupported, err := impl.checkIsAppMetricsSupported(req.ChartRefId) if err != nil { return err @@ -59,14 +95,41 @@ func (impl *DeployedAppMetricsServiceImpl) CheckAndUpdateAppLevelMetrics(ctx con if !(isAppMetricsSupported) { //chart does not have metrics support, disabling req.EnableMetrics = false + return nil } - _, span := otel.Tracer("orchestrator").Start(ctx, "updateAppLevelMetrics") - _, err = impl.updateAppLevelMetrics(req) - span.End() - if err != nil { - impl.logger.Errorw("error in disable app metric flag", "error", err) + if req.EnvId == 0 { + _, span := otel.Tracer("orchestrator").Start(ctx, "createOrUpdateAppLevelMetrics") + _, err = impl.createOrUpdateAppLevelMetrics(req) + span.End() + if err != nil { + impl.logger.Errorw("error in disable app metric flag", "error", err, "req", req) + return err + } + } else { + _, span := otel.Tracer("orchestrator").Start(ctx, "createOrUpdateEnvLevelMetrics") + _, err = impl.createOrUpdateEnvLevelMetrics(req) + span.End() + if err != nil { + impl.logger.Errorw("error in disable env level app metric flag", "error", err, "req", req) + return err + } + } + return nil +} + +func (impl *DeployedAppMetricsServiceImpl) DeleteEnvLevelMetricsIfPresent(appId, envId int) error { + envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(appId, envId) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Errorw("error while fetching env level app metric", "err", err, "appId", appId, "envId", envId) return err } + if envLevelAppMetrics != nil && envLevelAppMetrics.Id > 0 { + err = impl.envLevelMetricsRepository.Delete(envLevelAppMetrics) + if err != nil { + impl.logger.Errorw("error while deletion of app metric at env level", "err", err, "model", envLevelAppMetrics) + return err + } + } return nil } @@ -79,7 +142,7 @@ func (impl *DeployedAppMetricsServiceImpl) checkIsAppMetricsSupported(chartRefId return chartRefValue.IsAppMetricsSupported, nil } -func (impl *DeployedAppMetricsServiceImpl) updateAppLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.AppLevelMetrics, error) { +func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.AppLevelMetrics, error) { existingAppLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(req.AppId) if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in app metrics app level flag", "error", err) @@ -115,3 +178,42 @@ func (impl *DeployedAppMetricsServiceImpl) updateAppLevelMetrics(req *bean.Deplo return appLevelMetricsNew, nil } } + +func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.EnvLevelAppMetrics, error) { + // update and create env level app metrics + envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(req.AppId, req.EnvId) + if err != nil && err != pg.ErrNoRows { + impl.logger.Error("err", err) + return nil, err + } + if envLevelAppMetrics == nil || envLevelAppMetrics.Id == 0 { + infraMetrics := true + envLevelAppMetrics = &interalRepo.EnvLevelAppMetrics{ + AppId: req.AppId, + EnvId: req.EnvId, + AppMetrics: &req.EnableMetrics, + InfraMetrics: &infraMetrics, + AuditLog: sql.AuditLog{ + CreatedOn: time.Now(), + UpdatedOn: time.Now(), + CreatedBy: req.UserId, + UpdatedBy: req.UserId, + }, + } + err = impl.envLevelMetricsRepository.Save(envLevelAppMetrics) + if err != nil { + impl.logger.Error("err", err) + return nil, err + } + } else { + envLevelAppMetrics.AppMetrics = &req.EnableMetrics + envLevelAppMetrics.UpdatedOn = time.Now() + envLevelAppMetrics.UpdatedBy = req.UserId + err = impl.envLevelMetricsRepository.Update(envLevelAppMetrics) + if err != nil { + impl.logger.Error("err", err) + return nil, err + } + } + return envLevelAppMetrics, err +} diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index 673bc39365..1e5a57c615 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -3,7 +3,6 @@ package pipeline import ( "context" "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" @@ -25,24 +24,22 @@ type DeploymentConfigService interface { } type DeploymentConfigServiceImpl struct { - logger *zap.SugaredLogger - envConfigOverrideRepository chartConfig.EnvConfigOverrideRepository - chartRepository chartRepoRepository.ChartRepository - pipelineRepository pipelineConfig.PipelineRepository - envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository - pipelineConfigRepository chartConfig.PipelineConfigRepository - configMapRepository chartConfig.ConfigMapRepository - configMapHistoryService history.ConfigMapHistoryService - chartRefRepository chartRepoRepository.ChartRefRepository - scopedVariableManager variables.ScopedVariableCMCSManager - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + logger *zap.SugaredLogger + envConfigOverrideRepository chartConfig.EnvConfigOverrideRepository + chartRepository chartRepoRepository.ChartRepository + pipelineRepository pipelineConfig.PipelineRepository + pipelineConfigRepository chartConfig.PipelineConfigRepository + configMapRepository chartConfig.ConfigMapRepository + configMapHistoryService history.ConfigMapHistoryService + chartRefRepository chartRepoRepository.ChartRefRepository + scopedVariableManager variables.ScopedVariableCMCSManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, envConfigOverrideRepository chartConfig.EnvConfigOverrideRepository, chartRepository chartRepoRepository.ChartRepository, pipelineRepository pipelineConfig.PipelineRepository, - envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository, pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository, configMapHistoryService history.ConfigMapHistoryService, @@ -50,17 +47,16 @@ func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, scopedVariableManager variables.ScopedVariableCMCSManager, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentConfigServiceImpl { return &DeploymentConfigServiceImpl{ - logger: logger, - envConfigOverrideRepository: envConfigOverrideRepository, - chartRepository: chartRepository, - pipelineRepository: pipelineRepository, - envLevelAppMetricsRepository: envLevelAppMetricsRepository, - pipelineConfigRepository: pipelineConfigRepository, - configMapRepository: configMapRepository, - configMapHistoryService: configMapHistoryService, - chartRefRepository: chartRefRepository, - scopedVariableManager: scopedVariableManager, - deployedAppMetricsService: deployedAppMetricsService, + logger: logger, + envConfigOverrideRepository: envConfigOverrideRepository, + chartRepository: chartRepository, + pipelineRepository: pipelineRepository, + pipelineConfigRepository: pipelineConfigRepository, + configMapRepository: configMapRepository, + configMapHistoryService: configMapHistoryService, + chartRefRepository: chartRefRepository, + scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -97,19 +93,10 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentConfigurationByPipel } func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx context.Context, pipeline *pipelineConfig.Pipeline) (*history.HistoryDetailDto, error) { - isAppMetricsEnabled := false - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(pipeline.AppId, pipeline.EnvironmentId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) - } else if err == pg.ErrNoRows { - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(pipeline.AppId) - if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", pipeline.AppId) - return nil, err - } - isAppMetricsEnabled = isAppLevelMetricsEnabled - } else { - isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(pipeline.AppId, pipeline.EnvironmentId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) + return nil, err } envOverride, err := impl.envConfigOverrideRepository.ActiveEnvConfigOverride(pipeline.AppId, pipeline.EnvironmentId) if err != nil { diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 8a80c10bd3..d7a3dfd307 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -1672,11 +1672,20 @@ func (impl *CdPipelineConfigServiceImpl) createCdPipeline(ctx context.Context, a if err != nil { return 0, err } - envOverride, err := impl.propertiesConfigService.CreateIfRequired(chart, pipeline.EnvironmentId, userId, false, models.CHARTSTATUS_NEW, false, false, pipeline.Namespace, chart.IsBasicViewLocked, chart.CurrentViewEditor, tx) + //getting global app metrics for cd pipeline create because env level metrics is not created yet + appLevelAppMetricsEnabled := false + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(app.Id) if err != nil { + impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", app.Id) return 0, err } - + appLevelAppMetricsEnabled = isAppLevelMetricsEnabled + envOverride, updatedAppMetrics, err := impl.propertiesConfigService.CreateIfRequired(chart, pipeline.EnvironmentId, userId, false, + models.CHARTSTATUS_NEW, false, appLevelAppMetricsEnabled, pipeline.Namespace, chart.IsBasicViewLocked, chart.CurrentViewEditor, tx) + if err != nil { + return 0, err + } + appLevelAppMetricsEnabled = updatedAppMetrics // Get pipeline override based on Deployment strategy //TODO: mark as created in our db pipelineId, err = impl.ciCdPipelineOrchestrator.CreateCDPipelines(pipeline, app.Id, userId, tx, app.AppName) @@ -1733,14 +1742,7 @@ func (impl *CdPipelineConfigServiceImpl) createCdPipeline(ctx context.Context, a return 0, err } } - //getting global app metrics for cd pipeline create because env level metrics is not created yet - appLevelAppMetricsEnabled := false - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(app.Id) - if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", app.Id) - return 0, err - } - appLevelAppMetricsEnabled = isAppLevelMetricsEnabled + err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(envOverride, tx, appLevelAppMetricsEnabled, pipelineId) if err != nil { impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", envOverride) diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index e20aaae55d..686042bd65 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -18,8 +18,11 @@ package pipeline import ( + "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + bean2 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/variables" repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" @@ -33,7 +36,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/go-pg/pg" @@ -45,17 +47,15 @@ type PropertiesConfigService interface { CreateEnvironmentProperties(appId int, propertiesRequest *bean.EnvironmentProperties) (*bean.EnvironmentProperties, error) UpdateEnvironmentProperties(appId int, propertiesRequest *bean.EnvironmentProperties, userId int32) (*bean.EnvironmentProperties, error) //create environment entry for each new environment - CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, error) + CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, bool, error) GetEnvironmentProperties(appId, environmentId int, chartRefId int) (environmentPropertiesResponse *bean.EnvironmentPropertiesResponse, err error) GetEnvironmentPropertiesById(environmentId int) ([]bean.EnvironmentProperties, error) GetAppIdByChartEnvId(chartEnvId int) (*chartConfig.EnvConfigOverride, error) GetLatestEnvironmentProperties(appId, environmentId int) (*bean.EnvironmentProperties, error) - FindEnvLevelAppMetricsByAppIdAndEnvId(appId int, envId int) (*repository.EnvLevelAppMetrics, error) ResetEnvironmentProperties(id int) (bool, error) CreateEnvironmentPropertiesWithNamespace(appId int, propertiesRequest *bean.EnvironmentProperties) (*bean.EnvironmentProperties, error) - EnvMetricsEnableDisable(appMetricRequest *chartService.AppMetricEnableDisableRequest) (*chartService.AppMetricEnableDisableRequest, error) FetchEnvProperties(appId, envId, chartRefId int) (*chartConfig.EnvConfigOverride, error) } type PropertiesConfigServiceImpl struct { @@ -67,10 +67,9 @@ type PropertiesConfigServiceImpl struct { environmentRepository repository2.EnvironmentRepository ciCdPipelineOrchestrator CiCdPipelineOrchestrator application application.ServiceClient - envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository - appLevelMetricsRepository repository.AppLevelMetricsRepository deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewPropertiesConfigServiceImpl(logger *zap.SugaredLogger, @@ -81,11 +80,9 @@ func NewPropertiesConfigServiceImpl(logger *zap.SugaredLogger, environmentRepository repository2.EnvironmentRepository, ciCdPipelineOrchestrator CiCdPipelineOrchestrator, application application.ServiceClient, - envLevelAppMetricsRepository repository.EnvLevelAppMetricsRepository, - appLevelMetricsRepository repository.AppLevelMetricsRepository, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, -) *PropertiesConfigServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *PropertiesConfigServiceImpl { return &PropertiesConfigServiceImpl{ logger: logger, envConfigRepo: envConfigRepo, @@ -95,10 +92,9 @@ func NewPropertiesConfigServiceImpl(logger *zap.SugaredLogger, environmentRepository: environmentRepository, ciCdPipelineOrchestrator: ciCdPipelineOrchestrator, application: application, - envLevelAppMetricsRepository: envLevelAppMetricsRepository, - appLevelMetricsRepository: appLevelMetricsRepository, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, + deployedAppMetricsService: deployedAppMetricsService, } } @@ -191,27 +187,12 @@ func (impl PropertiesConfigServiceImpl) GetEnvironmentProperties(appId, environm environmentPropertiesResponse.EnvironmentConfig.CurrentViewEditor = chart.CurrentViewEditor } } - - envLevelMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(appId, environmentId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Error(err) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(appId, environmentId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", appId, "envId", environmentId) return nil, err } - if util.IsErrNoRows(err) { - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("error in app metrics app level flag", "error", err) - return nil, err - } - if util.IsErrNoRows(err) { - flag := false - environmentPropertiesResponse.AppMetrics = &flag - } else { - environmentPropertiesResponse.AppMetrics = &appLevelMetrics.AppMetrics - } - } else { - environmentPropertiesResponse.AppMetrics = envLevelMetrics.AppMetrics - } + environmentPropertiesResponse.AppMetrics = &isAppMetricsEnabled return environmentPropertiesResponse, nil } @@ -233,11 +214,11 @@ func (impl PropertiesConfigServiceImpl) CreateEnvironmentProperties(appId int, e if environmentProperties.AppMetrics != nil { appMetrics = *environmentProperties.AppMetrics } - envOverride, err := impl.CreateIfRequired(chart, environmentProperties.EnvironmentId, environmentProperties.UserId, environmentProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, true, appMetrics, environmentProperties.Namespace, environmentProperties.IsBasicViewLocked, environmentProperties.CurrentViewEditor, nil) + envOverride, appMetrics, err := impl.CreateIfRequired(chart, environmentProperties.EnvironmentId, environmentProperties.UserId, environmentProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, true, appMetrics, environmentProperties.Namespace, environmentProperties.IsBasicViewLocked, environmentProperties.CurrentViewEditor, nil) if err != nil { return nil, err } - + environmentProperties.AppMetrics = &appMetrics r := json.RawMessage{} err = r.UnmarshalJSON([]byte(envOverride.EnvOverrideValues)) if err != nil { @@ -260,31 +241,10 @@ func (impl PropertiesConfigServiceImpl) CreateEnvironmentProperties(appId int, e ChartRefId: environmentProperties.ChartRefId, IsOverride: envOverride.IsOverride, } - if err != nil { impl.logger.Errorw("chart version parsing", "err", err, "chartVersion", chart.ChartVersion) return nil, err } - chartRefValue, err := impl.chartRefRepository.FindById(environmentProperties.ChartRefId) - if err != nil { - impl.logger.Errorw("error in finding ref chart by id", "err", err) - return nil, err - } - if !(chartRefValue.IsAppMetricsSupported) { - appMetricsRequest := chartService.AppMetricEnableDisableRequest{UserId: environmentProperties.UserId, AppId: appId, EnvironmentId: environmentProperties.EnvironmentId, IsAppMetricsEnabled: false} - _, err = impl.EnvMetricsEnableDisable(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while disable app metrics", "err", err, "appId", appId, "chartVersion", chart.ChartVersion) - return nil, err - } - } else { - appMetricsRequest := chartService.AppMetricEnableDisableRequest{UserId: environmentProperties.UserId, AppId: appId, EnvironmentId: environmentProperties.EnvironmentId, IsAppMetricsEnabled: appMetrics} - _, err = impl.EnvMetricsEnableDisable(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while updating app metrics", "err", err) - return nil, err - } - } return environmentProperties, nil } @@ -357,26 +317,18 @@ func (impl PropertiesConfigServiceImpl) UpdateEnvironmentProperties(appId int, p if propertiesRequest.AppMetrics != nil { isAppMetricsEnabled = *propertiesRequest.AppMetrics } - chartRefValue, err := impl.chartRefRepository.FindById(oldEnvOverride.Chart.ChartRefId) + envLevelMetricsUpdateReq := &bean2.DeployedAppMetricsRequest{ + EnableMetrics: isAppMetricsEnabled, + AppId: appId, + EnvId: oldEnvOverride.TargetEnvironment, + ChartRefId: oldEnvOverride.Chart.ChartRefId, + UserId: propertiesRequest.UserId, + } + err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) if err != nil { - impl.logger.Errorw("error in finding ref chart by id", "err", err) + impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) return nil, err } - if !(chartRefValue.IsAppMetricsSupported) { - appMetricsRequest := chartService.AppMetricEnableDisableRequest{UserId: propertiesRequest.UserId, AppId: appId, EnvironmentId: oldEnvOverride.TargetEnvironment, IsAppMetricsEnabled: false} - _, err = impl.EnvMetricsEnableDisable(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while disable app metrics for lower versions", err) - return nil, err - } - } else { - appMetricsRequest := chartService.AppMetricEnableDisableRequest{UserId: propertiesRequest.UserId, AppId: appId, EnvironmentId: oldEnvOverride.TargetEnvironment, IsAppMetricsEnabled: isAppMetricsEnabled} - _, err = impl.EnvMetricsEnableDisable(&appMetricsRequest) - if err != nil { - impl.logger.Errorw("err while updating app metrics", "err", err) - return nil, err - } - } //creating history err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(override, nil, isAppMetricsEnabled, 0) @@ -405,10 +357,10 @@ func (impl PropertiesConfigServiceImpl) buildAppMetricsJson() ([]byte, error) { return appMetricsJson, nil } -func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, error) { +func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, bool, error) { env, err := impl.environmentRepository.FindById(environmentId) if err != nil { - return nil, err + return nil, isAppMetricsEnabled, err } if env != nil && len(env.Namespace) > 0 { @@ -417,14 +369,14 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit envOverride, err := impl.envConfigRepo.GetByChartAndEnvironment(chart.Id, environmentId) if err != nil && !errors.IsNotFound(err) { - return nil, err + return nil, isAppMetricsEnabled, err } if errors.IsNotFound(err) { if isOverride { // before creating new entry, remove previous one from latest tag envOverrideExisting, err := impl.envConfigRepo.FindLatestChartForAppByAppIdAndEnvId(chart.AppId, environmentId) if err != nil && !errors.IsNotFound(err) { - return nil, err + return nil, isAppMetricsEnabled, err } if envOverrideExisting != nil { envOverrideExisting.Latest = false @@ -440,7 +392,7 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit envOverrideExisting, err = impl.envConfigRepo.Update(envOverrideExisting) } if err != nil { - return nil, err + return nil, isAppMetricsEnabled, err } } } @@ -473,23 +425,37 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit } if err != nil { impl.logger.Errorw("error in creating envconfig", "data", envOverride, "error", err) - return nil, err + return nil, isAppMetricsEnabled, err } + envLevelMetricsUpdateReq := &bean2.DeployedAppMetricsRequest{ + EnableMetrics: isAppMetricsEnabled, + AppId: chart.AppId, + EnvId: environmentId, + ChartRefId: chart.ChartRefId, + UserId: userId, + } + err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) + if err != nil { + impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) + return nil, isAppMetricsEnabled, err + } + //updating metrics flag because it might be possible that the chartRef used was not supported and that could have override the metrics flag got in request + isAppMetricsEnabled = envLevelMetricsUpdateReq.EnableMetrics err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(envOverride, tx, isAppMetricsEnabled, 0) if err != nil { impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", envOverride) - return nil, err + return nil, isAppMetricsEnabled, err } //VARIABLE_MAPPING_UPDATE if envOverride.EnvOverrideValues != "{}" { err = impl.scopedVariableManager.ExtractAndMapVariables(envOverride.EnvOverrideValues, envOverride.Id, repository5.EntityTypeDeploymentTemplateEnvLevel, envOverride.CreatedBy, tx) if err != nil { - return nil, err + return nil, isAppMetricsEnabled, err } } } - return envOverride, nil + return envOverride, isAppMetricsEnabled, nil } func (impl PropertiesConfigServiceImpl) GetEnvironmentPropertiesById(envId int) ([]bean.EnvironmentProperties, error) { @@ -525,10 +491,6 @@ func (impl PropertiesConfigServiceImpl) GetAppIdByChartEnvId(chartEnvId int) (*c return envOverride, nil } -func (impl PropertiesConfigServiceImpl) FindEnvLevelAppMetricsByAppIdAndEnvId(appId int, envId int) (*repository.EnvLevelAppMetrics, error) { - return impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(appId, envId) -} - func (impl PropertiesConfigServiceImpl) GetLatestEnvironmentProperties(appId, environmentId int) (environmentProperties *bean.EnvironmentProperties, err error) { env, err := impl.environmentRepository.FindById(environmentId) if err != nil { @@ -583,18 +545,11 @@ func (impl PropertiesConfigServiceImpl) ResetEnvironmentProperties(id int) (bool if err != nil { impl.logger.Warnw("error in update envOverride", "envOverrideId", id) } - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(envOverride.Chart.AppId, envOverride.TargetEnvironment) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("error while fetching env level app metric", "err", err) + err = impl.deployedAppMetricsService.DeleteEnvLevelMetricsIfPresent(envOverride.Chart.AppId, envOverride.TargetEnvironment) + if err != nil { + impl.logger.Errorw("error, DeleteEnvLevelMetricsIfPresent", "err", err, "appId", envOverride.Chart.AppId, "envId", envOverride.TargetEnvironment) return false, err } - if envLevelAppMetrics.Id > 0 { - err = impl.envLevelAppMetricsRepository.Delete(envLevelAppMetrics) - if err != nil { - impl.logger.Errorw("error while deletion of app metric at env level", "err", err) - return false, err - } - } //VARIABLES err = impl.scopedVariableManager.RemoveMappedVariables(envOverride.Id, repository5.EntityTypeDeploymentTemplateEnvLevel, envOverride.UpdatedBy, nil) if err != nil { @@ -623,10 +578,11 @@ func (impl PropertiesConfigServiceImpl) CreateEnvironmentPropertiesWithNamespace if environmentProperties.AppMetrics != nil { appMetrics = *environmentProperties.AppMetrics } - envOverride, err = impl.CreateIfRequired(chart, environmentProperties.EnvironmentId, environmentProperties.UserId, environmentProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, false, appMetrics, environmentProperties.Namespace, environmentProperties.IsBasicViewLocked, environmentProperties.CurrentViewEditor, nil) + envOverride, appMetrics, err = impl.CreateIfRequired(chart, environmentProperties.EnvironmentId, environmentProperties.UserId, environmentProperties.ManualReviewed, models.CHARTSTATUS_SUCCESS, false, appMetrics, environmentProperties.Namespace, environmentProperties.IsBasicViewLocked, environmentProperties.CurrentViewEditor, nil) if err != nil { return nil, err } + environmentProperties.AppMetrics = &appMetrics } else { envOverride, err = impl.envConfigRepo.Get(environmentProperties.Id) if err != nil { @@ -666,83 +622,3 @@ func (impl PropertiesConfigServiceImpl) CreateEnvironmentPropertiesWithNamespace } return environmentProperties, nil } - -//below method is deprecated - -func (impl PropertiesConfigServiceImpl) EnvMetricsEnableDisable(appMetricRequest *chartService.AppMetricEnableDisableRequest) (*chartService.AppMetricEnableDisableRequest, error) { - // validate app metrics compatibility - var currentChart *chartConfig.EnvConfigOverride - var err error - currentChart, err = impl.envConfigRepo.FindLatestChartForAppByAppIdAndEnvId(appMetricRequest.AppId, appMetricRequest.EnvironmentId) - if err != nil && !errors.IsNotFound(err) { - impl.logger.Error(err) - return nil, err - } - if errors.IsNotFound(err) { - impl.logger.Errorw("no chart configured for this app", "appId", appMetricRequest.AppId) - err = &util.ApiError{ - InternalMessage: "no chart configured for this app", - UserMessage: "no chart configured for this app", - } - return nil, err - } - if appMetricRequest.IsAppMetricsEnabled == true { - chartRefValue, err := impl.chartRefRepository.FindById(currentChart.Chart.ChartRefId) - if err != nil { - impl.logger.Errorw("error in finding ref chart by id", "err", err) - return nil, err - } - if !(chartRefValue.IsAppMetricsSupported) { - err = &util.ApiError{ - InternalMessage: "chart version in not compatible for app metrics", - UserMessage: "chart version in not compatible for app metrics", - } - return nil, err - } - } - // update and create env level app metrics - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(appMetricRequest.AppId, appMetricRequest.EnvironmentId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Error("err", err) - return nil, err - } - if envLevelAppMetrics == nil || envLevelAppMetrics.Id == 0 { - infraMetrics := true - envLevelAppMetrics = &repository.EnvLevelAppMetrics{ - AppId: appMetricRequest.AppId, - EnvId: appMetricRequest.EnvironmentId, - AppMetrics: &appMetricRequest.IsAppMetricsEnabled, - InfraMetrics: &infraMetrics, - AuditLog: sql.AuditLog{ - CreatedOn: time.Now(), - UpdatedOn: time.Now(), - CreatedBy: appMetricRequest.UserId, - UpdatedBy: appMetricRequest.UserId, - }, - } - err = impl.envLevelAppMetricsRepository.Save(envLevelAppMetrics) - if err != nil { - impl.logger.Error("err", err) - return nil, err - } - } else { - envLevelAppMetrics.AppMetrics = &appMetricRequest.IsAppMetricsEnabled - envLevelAppMetrics.UpdatedOn = time.Now() - envLevelAppMetrics.UpdatedBy = appMetricRequest.UserId - err = impl.envLevelAppMetricsRepository.Update(envLevelAppMetrics) - if err != nil { - impl.logger.Error("err", err) - return nil, err - } - } - //updating audit log details of chart as history service uses it - currentChart.UpdatedOn = time.Now() - currentChart.UpdatedBy = appMetricRequest.UserId - //creating history entry - err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(currentChart, nil, appMetricRequest.IsAppMetricsEnabled, 0) - if err != nil { - impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", currentChart) - return nil, err - } - return appMetricRequest, err -} diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 1391bc5ce6..7a86482794 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -189,7 +189,6 @@ type WorkflowDagExecutorImpl struct { helmAppClient client2.HelmAppClient chartRefRepository chartRepoRepository.ChartRefRepository environmentConfigRepository chartConfig.EnvConfigOverrideRepository - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil gitOpsConfigRepository repository.GitOpsConfigRepository @@ -297,7 +296,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi helmAppClient client2.HelmAppClient, chartRefRepository chartRepoRepository.ChartRefRepository, environmentConfigRepository chartConfig.EnvConfigOverrideRepository, - envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, gitOpsConfigRepository repository.GitOpsConfigRepository, @@ -373,7 +371,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi helmAppClient: helmAppClient, chartRefRepository: chartRefRepository, environmentConfigRepository: environmentConfigRepository, - envLevelMetricsRepository: envLevelMetricsRepository, dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, gitOpsConfigRepository: gitOpsConfigRepository, @@ -3809,23 +3806,14 @@ func (impl *WorkflowDagExecutorImpl) GetAppMetricsByTriggerType(overrideRequest appMetrics = deploymentTemplateHistory.IsAppMetricsEnabled } else if overrideRequest.DeploymentWithConfig == bean.DEPLOYMENT_CONFIG_TYPE_LAST_SAVED { - _, span := otel.Tracer("orchestrator").Start(ctx, "appLevelMetricsRepository.FindByAppId") - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(overrideRequest.AppId) + _, span := otel.Tracer("orchestrator").Start(ctx, "deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId") + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(overrideRequest.AppId, overrideRequest.EnvId) if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", overrideRequest.AppId) + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId) return appMetrics, err } - appMetrics = isAppLevelMetricsEnabled - _, span = otel.Tracer("orchestrator").Start(ctx, "envLevelMetricsRepository.FindByAppIdAndEnvId") - envLevelMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(overrideRequest.AppId, overrideRequest.EnvId) span.End() - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("err", err) - return appMetrics, &util.ApiError{InternalMessage: "unable to fetch env level metrics flag"} - } - if envLevelMetrics.Id != 0 && envLevelMetrics.AppMetrics != nil { - appMetrics = *envLevelMetrics.AppMetrics - } + appMetrics = isAppMetricsEnabled } return appMetrics, nil } diff --git a/pkg/pipeline/history/DeploymentTemplateHistoryService.go b/pkg/pipeline/history/DeploymentTemplateHistoryService.go index 1d41cf373d..beeae5af84 100644 --- a/pkg/pipeline/history/DeploymentTemplateHistoryService.go +++ b/pkg/pipeline/history/DeploymentTemplateHistoryService.go @@ -5,7 +5,6 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "time" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -40,7 +39,6 @@ type DeploymentTemplateHistoryServiceImpl struct { pipelineRepository pipelineConfig.PipelineRepository chartRepository chartRepoRepository.ChartRepository chartRefRepository chartRepoRepository.ChartRefRepository - envLevelAppMetricsRepository repository2.EnvLevelAppMetricsRepository userService user.UserService cdWorkflowRepository pipelineConfig.CdWorkflowRepository scopedVariableManager variables.ScopedVariableManager @@ -48,13 +46,9 @@ type DeploymentTemplateHistoryServiceImpl struct { } func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deploymentTemplateHistoryRepository repository.DeploymentTemplateHistoryRepository, - pipelineRepository pipelineConfig.PipelineRepository, - chartRepository chartRepoRepository.ChartRepository, - chartRefRepository chartRepoRepository.ChartRefRepository, - envLevelAppMetricsRepository repository2.EnvLevelAppMetricsRepository, - userService user.UserService, - cdWorkflowRepository pipelineConfig.CdWorkflowRepository, - scopedVariableManager variables.ScopedVariableManager, + pipelineRepository pipelineConfig.PipelineRepository, chartRepository chartRepoRepository.ChartRepository, + chartRefRepository chartRepoRepository.ChartRefRepository, userService user.UserService, + cdWorkflowRepository pipelineConfig.CdWorkflowRepository, scopedVariableManager variables.ScopedVariableManager, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentTemplateHistoryServiceImpl { return &DeploymentTemplateHistoryServiceImpl{ logger: logger, @@ -62,7 +56,6 @@ func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deployme pipelineRepository: pipelineRepository, chartRepository: chartRepository, chartRefRepository: chartRefRepository, - envLevelAppMetricsRepository: envLevelAppMetricsRepository, userService: userService, cdWorkflowRepository: cdWorkflowRepository, scopedVariableManager: scopedVariableManager, @@ -208,20 +201,10 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory if len(chartRef.Name) == 0 { chartRef.Name = "Rollout Deployment" } - isAppMetricsEnabled := false - envLevelAppMetrics, err := impl.envLevelAppMetricsRepository.FindByAppIdAndEnvId(pipeline.AppId, pipeline.EnvironmentId) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(pipeline.AppId, pipeline.EnvironmentId) + if err != nil { + impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) return nil, err - } else if err == pg.ErrNoRows { - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(pipeline.AppId) - if err != nil { - impl.logger.Errorw("error in getting app level app metrics", "err", err, "appId", pipeline.AppId) - return nil, err - } - isAppMetricsEnabled = isAppLevelMetricsEnabled - } else { - isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics } historyModel := &repository.DeploymentTemplateHistory{ AppId: pipeline.AppId, diff --git a/wire_gen.go b/wire_gen.go index 8520b05196..d330b3674e 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -354,14 +354,14 @@ func InitializeApp() (*App, error) { configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) deploymentTemplateHistoryRepositoryImpl := repository6.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) - envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) if err != nil { return nil, err } appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, chartRefRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl) - deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, envLevelAppMetricsRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) + deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) chartWorkingDir := _wireChartWorkingDirValue globalEnvVariables, err := util3.GetGlobalEnvVariables() if err != nil { @@ -375,7 +375,7 @@ func InitializeApp() (*App, error) { Logger: sugaredLogger, } repositoryServiceClientImpl := repository9.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) - chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) + chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) devtronSecretConfig, err := util3.GetDevtronSecretName() if err != nil { return nil, err @@ -469,10 +469,10 @@ func InitializeApp() (*App, error) { customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, envLevelAppMetricsRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) - deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl) + deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl) pipelineTriggerRestHandlerImpl := restHandler.NewPipelineRestHandler(appServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, workflowDagExecutorImpl, deploymentGroupServiceImpl, argoUserServiceImpl, deploymentConfigServiceImpl) sseSSE := sse.NewSSE() pipelineTriggerRouterImpl := router.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) @@ -501,7 +501,7 @@ func InitializeApp() (*App, error) { ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) imageTaggingRepositoryImpl := repository13.NewImageTaggingRepositoryImpl(db) imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) - propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl) + propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) pipelineDeploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() if err != nil { return nil, err @@ -525,7 +525,7 @@ func InitializeApp() (*App, error) { gitRegistryConfigImpl := pipeline.NewGitRegistryConfigImpl(sugaredLogger, gitProviderRepositoryImpl, clientImpl) appListingViewBuilderImpl := app2.NewAppListingViewBuilderImpl(sugaredLogger) linkoutsRepositoryImpl := repository.NewLinkoutsRepositoryImpl(sugaredLogger, db) - appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, argoUserServiceImpl, envConfigOverrideRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl) + appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, appLevelMetricsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, argoUserServiceImpl, envConfigOverrideRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl) deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, userServiceImpl, cdWorkflowRepositoryImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, resourceGroupServiceImpl, imageTaggingServiceImpl, k8sUtil, workflowServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, customTagServiceImpl, argoClientWrapperServiceImpl, appServiceConfig, acdConfig) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) @@ -535,7 +535,7 @@ func InitializeApp() (*App, error) { imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciCdConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl) - pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl) + pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl) appWorkflowRestHandlerImpl := restHandler.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) webhookEventDataRepositoryImpl := repository.NewWebhookEventDataRepositoryImpl(db) webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) @@ -733,7 +733,7 @@ func InitializeApp() (*App, error) { telemetryRestHandlerImpl := restHandler.NewTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImplExtended, enforcerImpl, userServiceImpl) telemetryRouterImpl := router.NewTelemetryRouterImpl(sugaredLogger, telemetryRestHandlerImpl) bulkUpdateRepositoryImpl := bulkUpdate.NewBulkUpdateRepository(db, sugaredLogger) - bulkUpdateServiceImpl, err := bulkAction.NewBulkUpdateServiceImpl(bulkUpdateRepositoryImpl, chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, httpClient, appRepositoryImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, workflowDagExecutorImpl, cdWorkflowRepositoryImpl, pipelineBuilderImpl, helmAppServiceImpl, enforcerUtilImpl, enforcerUtilHelmImpl, ciHandlerImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, appWorkflowServiceImpl, pubSubClientServiceImpl, argoUserServiceImpl, scopedVariableManagerImpl) + bulkUpdateServiceImpl, err := bulkAction.NewBulkUpdateServiceImpl(bulkUpdateRepositoryImpl, chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, httpClient, appRepositoryImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, workflowDagExecutorImpl, cdWorkflowRepositoryImpl, pipelineBuilderImpl, helmAppServiceImpl, enforcerUtilImpl, enforcerUtilHelmImpl, ciHandlerImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, appWorkflowServiceImpl, pubSubClientServiceImpl, argoUserServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) if err != nil { return nil, err } From c7cfc9e11cffae54f4b4aa91f950884c5810ce52 Mon Sep 17 00:00:00 2001 From: Nishant <58689354+nishant-d@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:52:42 +0530 Subject: [PATCH 04/83] chore: Removed unused jira and migration integration (#4498) * removed unsued jira integration * removed test-suite-code * db migration conf removal * chore: removed unused injection * chore: removed dead code * added: migration script --------- Co-authored-by: Ash-exp --- Wire.go | 42 +-- .../chartProvider/ChartProviderRestHandler.go | 6 +- .../AppStoreDeploymentRestHandler.go | 6 +- .../deployment/CommonDeploymentRestHandler.go | 6 +- api/deployment/DeploymentConfigRestHandler.go | 6 +- .../application/k8sApplicationRestHandler.go | 6 +- api/restHandler/BulkUpdateRestHandler.go | 3 - api/restHandler/ChartGroupRestHandler.go | 6 +- api/restHandler/CoreAppRestHandler.go | 6 +- api/restHandler/DeploymentGroupRestHandler.go | 6 +- api/restHandler/GitHostRestHandler.go | 6 +- api/restHandler/GitProviderRestHandler.go | 8 +- api/restHandler/GlobalCMCSRestHandler.go | 6 +- api/restHandler/ImageScanRestHandler.go | 6 +- api/restHandler/JiraRestHandler.go | 111 ------- api/restHandler/MigrateDbRestHandler.go | 217 -------------- api/restHandler/NotificationRestHandler.go | 8 +- api/restHandler/PolicyRestHandler.go | 8 +- api/restHandler/TelemetryRestHandler.go | 4 +- api/restHandler/TestSuitRestHandler.go | 276 ------------------ .../app/DeploymentPipelineRestHandler.go | 131 --------- .../app/PipelineConfigRestHandler.go | 3 - api/router/MigrateDbRouter.go | 51 ---- api/router/PipelineConfigRouter.go | 4 - api/router/ProjectManagementRouter.go | 45 --- api/router/TestSuites.go | 45 --- api/router/router.go | 21 +- api/terminal/UserTerminalAccessRestHandler.go | 6 +- client/events/EventBuilder.go | 6 +- client/events/EventClient.go | 19 -- internal/sql/repository/DbConfigRepository.go | 100 ------- .../sql/repository/JiraAccountRepository.go | 92 ------ .../pipelineConfig/DbMigrationConfig.go | 85 ------ pkg/app/AppService.go | 9 +- .../deployment/service/InstalledAppService.go | 6 +- .../service/InstalledAppService_test.go | 6 +- .../gitops/AppStoreDeploymentArgoCdService.go | 6 +- pkg/auth/user/bean/bean.go | 36 +-- .../user/repository/UserAuditRepository.go | 2 +- pkg/auth/user/repository/UserRepository.go | 4 +- pkg/jira/JiraService.go | 174 ----------- pkg/notifier/NotificationConfigService.go | 6 +- pkg/pipeline/AppArtifactManager.go | 6 +- pkg/pipeline/CiHandler.go | 75 ----- pkg/pipeline/DbConfigService.go | 153 ---------- pkg/pipeline/DbMigrationService.go | 119 -------- pkg/pipeline/WorkflowDagExecutor.go | 234 +-------------- .../jira/JiraAccountValidator.go | 56 ---- .../jira/JiraManagementService.go | 98 ------- pkg/security/ImageScanService.go | 6 +- scripts/sql/210_unused_integration.up.sql | 12 + scripts/sql/210_unused_intergration.down.sql | 125 ++++++++ wire_gen.go | 32 +- 53 files changed, 247 insertions(+), 2269 deletions(-) delete mode 100644 api/restHandler/JiraRestHandler.go delete mode 100644 api/restHandler/MigrateDbRestHandler.go delete mode 100644 api/restHandler/TestSuitRestHandler.go delete mode 100644 api/router/MigrateDbRouter.go delete mode 100644 api/router/ProjectManagementRouter.go delete mode 100644 api/router/TestSuites.go delete mode 100644 internal/sql/repository/DbConfigRepository.go delete mode 100644 internal/sql/repository/JiraAccountRepository.go delete mode 100644 internal/sql/repository/pipelineConfig/DbMigrationConfig.go delete mode 100644 pkg/jira/JiraService.go delete mode 100644 pkg/pipeline/DbConfigService.go delete mode 100644 pkg/pipeline/DbMigrationService.go delete mode 100644 pkg/projectManagementService/jira/JiraAccountValidator.go delete mode 100644 pkg/projectManagementService/jira/JiraManagementService.go create mode 100644 scripts/sql/210_unused_integration.up.sql create mode 100644 scripts/sql/210_unused_intergration.down.sql diff --git a/Wire.go b/Wire.go index 9cc5e42f2f..69890f5668 100644 --- a/Wire.go +++ b/Wire.go @@ -63,7 +63,6 @@ import ( eClient "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/client/grafana" - jClient "github.com/devtron-labs/devtron/client/jira" "github.com/devtron-labs/devtron/client/lens" "github.com/devtron-labs/devtron/client/telemetry" "github.com/devtron-labs/devtron/internal/sql/repository" @@ -104,7 +103,6 @@ import ( "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" - jira2 "github.com/devtron-labs/devtron/pkg/jira" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/notifier" @@ -116,7 +114,6 @@ import ( "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" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/security" @@ -258,10 +255,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)), pipelineConfig.NewMaterialRepositoryImpl, wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), - router.NewMigrateDbRouterImpl, - wire.Bind(new(router.MigrateDbRouter), new(*router.MigrateDbRouterImpl)), - restHandler.NewMigrateDbRestHandlerImpl, - wire.Bind(new(restHandler.MigrateDbRestHandler), new(*restHandler.MigrateDbRestHandlerImpl)), + util.NewChartTemplateServiceImpl, wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), util.NewChartDeploymentServiceImpl, @@ -329,23 +323,8 @@ func InitializeApp() (*App, error) { pipeline.NewPropertiesConfigServiceImpl, wire.Bind(new(pipeline.PropertiesConfigService), new(*pipeline.PropertiesConfigServiceImpl)), - router.NewProjectManagementRouterImpl, - wire.Bind(new(router.ProjectManagementRouter), new(*router.ProjectManagementRouterImpl)), - - restHandler.NewJiraRestHandlerImpl, - wire.Bind(new(restHandler.JiraRestHandler), new(*restHandler.JiraRestHandlerImpl)), - - jira2.NewProjectManagementServiceImpl, - wire.Bind(new(jira2.ProjectManagementService), new(*jira2.ProjectManagementServiceImpl)), - - jira.NewAccountServiceImpl, - wire.Bind(new(jira.AccountService), new(*jira.AccountServiceImpl)), - util.NewHttpClient, - jClient.NewJiraClientImpl, - wire.Bind(new(jClient.JiraClient), new(*jClient.JiraClientImpl)), - eClient.NewEventRESTClientImpl, wire.Bind(new(eClient.EventClient), new(*eClient.EventRESTClientImpl)), @@ -354,11 +333,6 @@ func InitializeApp() (*App, error) { eClient.NewEventSimpleFactoryImpl, wire.Bind(new(eClient.EventFactory), new(*eClient.EventSimpleFactoryImpl)), - repository.NewJiraAccountRepositoryImpl, - wire.Bind(new(repository.JiraAccountRepository), new(*repository.JiraAccountRepositoryImpl)), - jira.NewAccountValidatorImpl, - wire.Bind(new(jira.AccountValidator), new(*jira.AccountValidatorImpl)), - repository.NewCiArtifactRepositoryImpl, wire.Bind(new(repository.CiArtifactRepository), new(*repository.CiArtifactRepositoryImpl)), pipeline.NewWebhookServiceImpl, @@ -402,15 +376,6 @@ func InitializeApp() (*App, error) { //ArgoUtil.NewRepositoryService, //wire.Bind(new(ArgoUtil.RepositoryService), new(ArgoUtil.RepositoryServiceImpl)), - pipelineConfig.NewDbMigrationConfigRepositoryImpl, - wire.Bind(new(pipelineConfig.DbMigrationConfigRepository), new(*pipelineConfig.DbMigrationConfigRepositoryImpl)), - pipeline.NewDbConfigService, - wire.Bind(new(pipeline.DbConfigService), new(*pipeline.DbConfigServiceImpl)), - - repository.NewDbConfigRepositoryImpl, - wire.Bind(new(repository.DbConfigRepository), new(*repository.DbConfigRepositoryImpl)), - pipeline.NewDbMogrationService, - wire.Bind(new(pipeline.DbMigrationService), new(*pipeline.DbMigrationServiceImpl)), //ArgoUtil.NewClusterServiceImpl, //wire.Bind(new(ArgoUtil.ClusterService), new(ArgoUtil.ClusterServiceImpl)), pipeline.GetEcrConfig, @@ -635,11 +600,6 @@ func InitializeApp() (*App, error) { commonService.NewCommonServiceImpl, wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)), - router.NewTestSuitRouterImpl, - wire.Bind(new(router.TestSuitRouter), new(*router.TestSuitRouterImpl)), - restHandler.NewTestSuitRestHandlerImpl, - wire.Bind(new(restHandler.TestSuitRestHandler), new(*restHandler.TestSuitRestHandlerImpl)), - router.NewImageScanRouterImpl, wire.Bind(new(router.ImageScanRouter), new(*router.ImageScanRouterImpl)), restHandler.NewImageScanRestHandlerImpl, diff --git a/api/appStore/chartProvider/ChartProviderRestHandler.go b/api/appStore/chartProvider/ChartProviderRestHandler.go index 797a361648..6fd199dbf0 100644 --- a/api/appStore/chartProvider/ChartProviderRestHandler.go +++ b/api/appStore/chartProvider/ChartProviderRestHandler.go @@ -39,9 +39,9 @@ type ChartProviderRestHandler interface { type ChartProviderRestHandlerImpl struct { Logger *zap.SugaredLogger chartProviderService chartProvider.ChartProviderService - validator *validator.Validate - userAuthService user.UserService - enforcer casbin.Enforcer + validator *validator.Validate + userAuthService user.UserService + enforcer casbin.Enforcer } func NewChartProviderRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, chartProviderService chartProvider.ChartProviderService, diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index 3d6d9199bf..cffb21ff55 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -59,9 +59,9 @@ type AppStoreDeploymentRestHandler interface { } type AppStoreDeploymentRestHandlerImpl struct { - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil enforcerUtilHelm rbac.EnforcerUtilHelm appStoreDeploymentService service.AppStoreDeploymentService diff --git a/api/appStore/deployment/CommonDeploymentRestHandler.go b/api/appStore/deployment/CommonDeploymentRestHandler.go index ffc200419f..d7bfac9fd8 100644 --- a/api/appStore/deployment/CommonDeploymentRestHandler.go +++ b/api/appStore/deployment/CommonDeploymentRestHandler.go @@ -51,9 +51,9 @@ type CommonDeploymentRestHandler interface { } type CommonDeploymentRestHandlerImpl struct { - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil enforcerUtilHelm rbac.EnforcerUtilHelm appStoreDeploymentService service.AppStoreDeploymentService diff --git a/api/deployment/DeploymentConfigRestHandler.go b/api/deployment/DeploymentConfigRestHandler.go index 53be9a4b6a..9e17ce9f97 100644 --- a/api/deployment/DeploymentConfigRestHandler.go +++ b/api/deployment/DeploymentConfigRestHandler.go @@ -31,9 +31,9 @@ type DeploymentConfigRestHandler interface { } type DeploymentConfigRestHandlerImpl struct { - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer validator *validator.Validate refChartDir chartRepoRepository.RefChartDir chartService chart.ChartService diff --git a/api/k8s/application/k8sApplicationRestHandler.go b/api/k8s/application/k8sApplicationRestHandler.go index c89444ec5b..0fa90296ab 100644 --- a/api/k8s/application/k8sApplicationRestHandler.go +++ b/api/k8s/application/k8sApplicationRestHandler.go @@ -62,9 +62,9 @@ type K8sApplicationRestHandlerImpl struct { validator *validator.Validate enforcerUtil rbac.EnforcerUtil enforcerUtilHelm rbac.EnforcerUtilHelm - helmAppService client.HelmAppService - userService user.UserService - k8sCommonService k8s.K8sCommonService + helmAppService client.HelmAppService + userService user.UserService + k8sCommonService k8s.K8sCommonService } func NewK8sApplicationRestHandlerImpl(logger *zap.SugaredLogger, k8sApplicationService application2.K8sApplicationService, pump connector.Pump, terminalSessionHandler terminal.TerminalSessionHandler, enforcer casbin.Enforcer, enforcerUtilHelm rbac.EnforcerUtilHelm, enforcerUtil rbac.EnforcerUtil, helmAppService client.HelmAppService, userService user.UserService, k8sCommonService k8s.K8sCommonService, validator *validator.Validate) *K8sApplicationRestHandlerImpl { diff --git a/api/restHandler/BulkUpdateRestHandler.go b/api/restHandler/BulkUpdateRestHandler.go index da3b595c81..3a4a0293a6 100644 --- a/api/restHandler/BulkUpdateRestHandler.go +++ b/api/restHandler/BulkUpdateRestHandler.go @@ -51,7 +51,6 @@ type BulkUpdateRestHandlerImpl struct { bulkUpdateService bulkAction.BulkUpdateService chartService chart.ChartService propertiesConfigService pipeline.PropertiesConfigService - dbMigrationService pipeline.DbMigrationService application application.ServiceClient userAuthService user.UserService validator *validator.Validate @@ -76,7 +75,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg bulkUpdateService bulkAction.BulkUpdateService, chartService chart.ChartService, propertiesConfigService pipeline.PropertiesConfigService, - dbMigrationService pipeline.DbMigrationService, application application.ServiceClient, userAuthService user.UserService, teamService team.TeamService, @@ -99,7 +97,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg bulkUpdateService: bulkUpdateService, chartService: chartService, propertiesConfigService: propertiesConfigService, - dbMigrationService: dbMigrationService, application: application, userAuthService: userAuthService, validator: validator, diff --git a/api/restHandler/ChartGroupRestHandler.go b/api/restHandler/ChartGroupRestHandler.go index 46746277f3..9a0b2dc03e 100644 --- a/api/restHandler/ChartGroupRestHandler.go +++ b/api/restHandler/ChartGroupRestHandler.go @@ -36,9 +36,9 @@ const CHART_GROUP_DELETE_SUCCESS_RESP = "Chart group deleted successfully." type ChartGroupRestHandlerImpl struct { ChartGroupService service.ChartGroupService - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer validator *validator.Validate } diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 20566db8c4..5cd951d7d8 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -75,9 +75,9 @@ type CoreAppRestHandler interface { } type CoreAppRestHandlerImpl struct { - logger *zap.SugaredLogger - userAuthService user.UserService - validator *validator.Validate + logger *zap.SugaredLogger + userAuthService user.UserService + validator *validator.Validate enforcerUtil rbac.EnforcerUtil enforcer casbin.Enforcer appCrudOperationService app.AppCrudOperationService diff --git a/api/restHandler/DeploymentGroupRestHandler.go b/api/restHandler/DeploymentGroupRestHandler.go index 399ca23972..d8889d6e97 100644 --- a/api/restHandler/DeploymentGroupRestHandler.go +++ b/api/restHandler/DeploymentGroupRestHandler.go @@ -51,9 +51,9 @@ type DeploymentGroupRestHandlerImpl struct { logger *zap.SugaredLogger validator *validator.Validate enforcer casbin.Enforcer - teamService team.TeamService - userAuthService user.UserService - enforcerUtil rbac.EnforcerUtil + teamService team.TeamService + userAuthService user.UserService + enforcerUtil rbac.EnforcerUtil } func NewDeploymentGroupRestHandlerImpl(deploymentGroupService deploymentGroup.DeploymentGroupService, logger *zap.SugaredLogger, diff --git a/api/restHandler/GitHostRestHandler.go b/api/restHandler/GitHostRestHandler.go index d96e5f20c1..1048ff4a5f 100644 --- a/api/restHandler/GitHostRestHandler.go +++ b/api/restHandler/GitHostRestHandler.go @@ -45,9 +45,9 @@ type GitHostRestHandler interface { type GitHostRestHandlerImpl struct { logger *zap.SugaredLogger - gitHostConfig pipeline.GitHostConfig - userAuthService user.UserService - validator *validator.Validate + gitHostConfig pipeline.GitHostConfig + userAuthService user.UserService + validator *validator.Validate enforcer casbin.Enforcer gitSensorClient gitSensor.Client gitProviderConfig pipeline.GitRegistryConfig diff --git a/api/restHandler/GitProviderRestHandler.go b/api/restHandler/GitProviderRestHandler.go index 0a0e94ceaa..3c0b80d451 100644 --- a/api/restHandler/GitProviderRestHandler.go +++ b/api/restHandler/GitProviderRestHandler.go @@ -48,9 +48,8 @@ type GitProviderRestHandlerImpl struct { dockerRegistryConfig pipeline.DockerRegistryConfig logger *zap.SugaredLogger gitRegistryConfig pipeline.GitRegistryConfig - dbConfigService pipeline.DbConfigService - userAuthService user.UserService - validator *validator.Validate + userAuthService user.UserService + validator *validator.Validate enforcer casbin.Enforcer teamService team.TeamService deleteServiceFullMode delete2.DeleteServiceFullMode @@ -59,14 +58,13 @@ type GitProviderRestHandlerImpl struct { func NewGitProviderRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryConfig, logger *zap.SugaredLogger, gitRegistryConfig pipeline.GitRegistryConfig, - dbConfigService pipeline.DbConfigService, userAuthService user.UserService, + userAuthService user.UserService, validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService, deleteServiceFullMode delete2.DeleteServiceFullMode) *GitProviderRestHandlerImpl { return &GitProviderRestHandlerImpl{ dockerRegistryConfig: dockerRegistryConfig, logger: logger, gitRegistryConfig: gitRegistryConfig, - dbConfigService: dbConfigService, userAuthService: userAuthService, validator: validator, enforcer: enforcer, diff --git a/api/restHandler/GlobalCMCSRestHandler.go b/api/restHandler/GlobalCMCSRestHandler.go index b1e294ce7e..4d6f32f36a 100644 --- a/api/restHandler/GlobalCMCSRestHandler.go +++ b/api/restHandler/GlobalCMCSRestHandler.go @@ -24,9 +24,9 @@ type GlobalCMCSRestHandler interface { } type GlobalCMCSRestHandlerImpl struct { - logger *zap.SugaredLogger - userAuthService user.UserService - validator *validator.Validate + logger *zap.SugaredLogger + userAuthService user.UserService + validator *validator.Validate enforcer casbin.Enforcer globalCMCSService pipeline.GlobalCMCSService } diff --git a/api/restHandler/ImageScanRestHandler.go b/api/restHandler/ImageScanRestHandler.go index 12222a7bc5..ca33c82b34 100644 --- a/api/restHandler/ImageScanRestHandler.go +++ b/api/restHandler/ImageScanRestHandler.go @@ -43,9 +43,9 @@ type ImageScanRestHandler interface { type ImageScanRestHandlerImpl struct { logger *zap.SugaredLogger - imageScanService security.ImageScanService - userService user.UserService - enforcer casbin.Enforcer + imageScanService security.ImageScanService + userService user.UserService + enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil environmentService cluster.EnvironmentService } diff --git a/api/restHandler/JiraRestHandler.go b/api/restHandler/JiraRestHandler.go deleted file mode 100644 index 117cd1dac0..0000000000 --- a/api/restHandler/JiraRestHandler.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package restHandler - -import ( - "encoding/json" - "net/http" - - "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/auth/user" - "github.com/devtron-labs/devtron/pkg/jira" - "go.uber.org/zap" - "gopkg.in/go-playground/validator.v9" -) - -type JiraRestHandler interface { - SaveAccountConfig(w http.ResponseWriter, r *http.Request) - UpdateIssueStatus(w http.ResponseWriter, r *http.Request) -} - -type JiraRestHandlerImpl struct { - jiraService jira.ProjectManagementService - logger *zap.SugaredLogger - userAuthService user.UserService - validator *validator.Validate -} - -func NewJiraRestHandlerImpl(jiraService jira.ProjectManagementService, logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate) *JiraRestHandlerImpl { - return &JiraRestHandlerImpl{ - jiraService: jiraService, - logger: logger, - userAuthService: userAuthService, - validator: validator, - } -} - -func (impl JiraRestHandlerImpl) SaveAccountConfig(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := impl.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var jiraConfigBean jira.ConfigBean - err = decoder.Decode(&jiraConfigBean) - if err != nil { - impl.logger.Errorw("request err, SaveAccountConfig", "err", err, "payload", jiraConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - impl.logger.Infow("request payload, SaveAccountConfig", "err", err, "payload", jiraConfigBean) - err = impl.validator.Struct(jiraConfigBean) - if err != nil { - impl.logger.Errorw("validation err, SaveAccountConfig", "err", err, "payload", jiraConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - account, err := impl.jiraService.SaveAccountDetails(&jiraConfigBean, userId) - if err != nil { - impl.logger.Errorw("service err, SaveAccountConfig", "err", err, "payload", jiraConfigBean) - common.WriteJsonResp(w, err, "error in saving jira config", http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, account.Id, http.StatusOK) -} - -func (impl JiraRestHandlerImpl) UpdateIssueStatus(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var updateBean jira.UpdateIssueBean - err = json.NewDecoder(r.Body).Decode(&updateBean) - if err != nil { - impl.logger.Errorw("request err, UpdateIssueStatus", "err", err, "payload", updateBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - impl.logger.Infow("request payload, UpdateIssueStatus", "err", err, "payload", updateBean) - err = impl.validator.Struct(updateBean) - if err != nil { - impl.logger.Errorw("validation err, UpdateIssueStatus", "err", err, "payload", updateBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - res, err := impl.jiraService.UpdateJiraStatus(&updateBean, userId) - if err != nil { - impl.logger.Errorw("service err, UpdateIssueStatus", "err", err, "payload", updateBean) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", "application/json") - common.WriteJsonResp(w, err, res, http.StatusOK) -} diff --git a/api/restHandler/MigrateDbRestHandler.go b/api/restHandler/MigrateDbRestHandler.go deleted file mode 100644 index aef4fe4beb..0000000000 --- a/api/restHandler/MigrateDbRestHandler.go +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package restHandler - -import ( - "encoding/json" - "net/http" - "strconv" - - "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" - "github.com/devtron-labs/devtron/pkg/auth/user" - "github.com/devtron-labs/devtron/pkg/pipeline" - "github.com/devtron-labs/devtron/pkg/pipeline/types" - "github.com/gorilla/mux" - "go.uber.org/zap" - "gopkg.in/go-playground/validator.v9" -) - -type MigrateDbRestHandler interface { - SaveDbConfig(w http.ResponseWriter, r *http.Request) - FetchAllDbConfig(w http.ResponseWriter, r *http.Request) - FetchOneDbConfig(w http.ResponseWriter, r *http.Request) - UpdateDbConfig(w http.ResponseWriter, r *http.Request) - FetchDbConfigForAutoComp(w http.ResponseWriter, r *http.Request) -} -type MigrateDbRestHandlerImpl struct { - dockerRegistryConfig pipeline.DockerRegistryConfig - logger *zap.SugaredLogger - gitRegistryConfig pipeline.GitRegistryConfig - dbConfigService pipeline.DbConfigService - userAuthService user.UserService - validator *validator.Validate - dbMigrationService pipeline.DbMigrationService - enforcer casbin.Enforcer -} - -func NewMigrateDbRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryConfig, - logger *zap.SugaredLogger, gitRegistryConfig pipeline.GitRegistryConfig, - dbConfigService pipeline.DbConfigService, userAuthService user.UserService, - validator *validator.Validate, dbMigrationService pipeline.DbMigrationService, - enforcer casbin.Enforcer) *MigrateDbRestHandlerImpl { - return &MigrateDbRestHandlerImpl{ - dockerRegistryConfig: dockerRegistryConfig, - logger: logger, - gitRegistryConfig: gitRegistryConfig, - dbConfigService: dbConfigService, - userAuthService: userAuthService, - validator: validator, - dbMigrationService: dbMigrationService, - enforcer: enforcer, - } -} - -func (impl MigrateDbRestHandlerImpl) SaveDbConfig(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := impl.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var bean types.DbConfigBean - err = decoder.Decode(&bean) - if err != nil { - impl.logger.Errorw("request err, SaveDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - bean.UserId = userId - impl.logger.Errorw("request payload, SaveDbConfig", "err", err, "payload", bean) - err = impl.validator.Struct(bean) - if err != nil { - impl.logger.Errorw("validation err, SaveDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - // RBAC enforcer applying - token := r.Header.Get("token") - if ok := impl.enforcer.Enforce(token, casbin.ResourceMigrate, casbin.ActionCreate, bean.Name); !ok { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden) - return - } - //RBAC enforcer Ends - - res, err := impl.dbConfigService.Save(&bean) - if err != nil { - impl.logger.Errorw("service err, SaveDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl MigrateDbRestHandlerImpl) FetchAllDbConfig(w http.ResponseWriter, r *http.Request) { - res, err := impl.dbConfigService.GetAll() - if err != nil { - impl.logger.Errorw("service err, FetchAllDbConfig", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - - // RBAC enforcer applying - token := r.Header.Get("token") - var result []types.DbConfigBean - for _, item := range res { - if ok := impl.enforcer.Enforce(token, casbin.ResourceMigrate, casbin.ActionGet, item.Name); ok { - result = append(result, *item) - } - } - //RBAC enforcer Ends - - common.WriteJsonResp(w, err, result, http.StatusOK) -} - -func (impl MigrateDbRestHandlerImpl) FetchOneDbConfig(w http.ResponseWriter, r *http.Request) { - params := mux.Vars(r) - id, err := strconv.Atoi(params["id"]) - if err != nil { - impl.logger.Errorw("request err, FetchOneDbConfig", "err", err, "id", id) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - res, err := impl.dbConfigService.GetById(id) - if err != nil { - impl.logger.Errorw("service err, FetchOneDbConfig", "err", err, "id", id) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - - // RBAC enforcer applying - token := r.Header.Get("token") - if ok := impl.enforcer.Enforce(token, casbin.ResourceMigrate, casbin.ActionGet, res.Name); !ok { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden) - return - } - //RBAC enforcer Ends - - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl MigrateDbRestHandlerImpl) UpdateDbConfig(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := impl.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var bean types.DbConfigBean - - err = decoder.Decode(&bean) - if err != nil { - impl.logger.Errorw("request err, UpdateDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - bean.UserId = userId - impl.logger.Errorw("request payload, UpdateDbConfig", "err", err, "payload", bean) - err = impl.validator.Struct(bean) - if err != nil { - impl.logger.Errorw("service err, UpdateDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - // RBAC enforcer applying - token := r.Header.Get("token") - if ok := impl.enforcer.Enforce(token, casbin.ResourceMigrate, casbin.ActionUpdate, bean.Name); !ok { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden) - return - } - //RBAC enforcer Ends - - res, err := impl.dbConfigService.Update(&bean) - if err != nil { - impl.logger.Errorw("service err, UpdateDbConfig", "err", err, "payload", bean) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl MigrateDbRestHandlerImpl) FetchDbConfigForAutoComp(w http.ResponseWriter, r *http.Request) { - res, err := impl.dbConfigService.GetForAutocomplete() - if err != nil { - impl.logger.Errorw("service err, FetchDbConfigForAutoComp", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - - // RBAC enforcer applying - token := r.Header.Get("token") - var result []types.DbConfigBean - for _, item := range res { - if ok := impl.enforcer.Enforce(token, casbin.ResourceMigrate, casbin.ActionGet, item.Name); ok { - result = append(result, *item) - } - } - //RBAC enforcer Ends - - common.WriteJsonResp(w, err, result, http.StatusOK) -} diff --git a/api/restHandler/NotificationRestHandler.go b/api/restHandler/NotificationRestHandler.go index 9840f69ec4..996ecd52e9 100644 --- a/api/restHandler/NotificationRestHandler.go +++ b/api/restHandler/NotificationRestHandler.go @@ -73,9 +73,8 @@ type NotificationRestHandlerImpl struct { dockerRegistryConfig pipeline.DockerRegistryConfig logger *zap.SugaredLogger gitRegistryConfig pipeline.GitRegistryConfig - dbConfigService pipeline.DbConfigService - userAuthService user.UserService - validator *validator.Validate + userAuthService user.UserService + validator *validator.Validate notificationService notifier.NotificationConfigService slackService notifier.SlackNotificationService webhookService notifier.WebhookNotificationService @@ -94,7 +93,7 @@ type ChannelDto struct { func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryConfig, logger *zap.SugaredLogger, gitRegistryConfig pipeline.GitRegistryConfig, - dbConfigService pipeline.DbConfigService, userAuthService user.UserService, + userAuthService user.UserService, validator *validator.Validate, notificationService notifier.NotificationConfigService, slackService notifier.SlackNotificationService, webhookService notifier.WebhookNotificationService, sesService notifier.SESNotificationService, smtpService notifier.SMTPNotificationService, enforcer casbin.Enforcer, teamService team.TeamService, environmentService cluster.EnvironmentService, pipelineBuilder pipeline.PipelineBuilder, @@ -103,7 +102,6 @@ func NewNotificationRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistry dockerRegistryConfig: dockerRegistryConfig, logger: logger, gitRegistryConfig: gitRegistryConfig, - dbConfigService: dbConfigService, userAuthService: userAuthService, validator: validator, notificationService: notificationService, diff --git a/api/restHandler/PolicyRestHandler.go b/api/restHandler/PolicyRestHandler.go index c3f99131d9..81e133c79f 100644 --- a/api/restHandler/PolicyRestHandler.go +++ b/api/restHandler/PolicyRestHandler.go @@ -43,10 +43,10 @@ type PolicyRestHandler interface { } type PolicyRestHandlerImpl struct { logger *zap.SugaredLogger - policyService security.PolicyService - userService user2.UserService - userAuthService user2.UserAuthService - enforcer casbin.Enforcer + policyService security.PolicyService + userService user2.UserService + userAuthService user2.UserAuthService + enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil environmentService cluster.EnvironmentService } diff --git a/api/restHandler/TelemetryRestHandler.go b/api/restHandler/TelemetryRestHandler.go index eb1cd76821..d6406b967b 100644 --- a/api/restHandler/TelemetryRestHandler.go +++ b/api/restHandler/TelemetryRestHandler.go @@ -38,8 +38,8 @@ type TelemetryRestHandler interface { type TelemetryRestHandlerImpl struct { logger *zap.SugaredLogger telemetryEventClient telemetry.TelemetryEventClient - enforcer casbin.Enforcer - userService user.UserService + enforcer casbin.Enforcer + userService user.UserService } type TelemetryGenericEvent struct { diff --git a/api/restHandler/TestSuitRestHandler.go b/api/restHandler/TestSuitRestHandler.go deleted file mode 100644 index 968a3f380d..0000000000 --- a/api/restHandler/TestSuitRestHandler.go +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package restHandler - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "strconv" - - "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/client/grafana" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" - "github.com/devtron-labs/devtron/pkg/auth/user" - "github.com/devtron-labs/devtron/util/rbac" - "github.com/gorilla/mux" - "go.uber.org/zap" - "gopkg.in/go-playground/validator.v9" -) - -type TestSuitRestHandler interface { - SuitesProxy(w http.ResponseWriter, r *http.Request) - GetTestSuites(w http.ResponseWriter, r *http.Request) - DetailedTestSuites(w http.ResponseWriter, r *http.Request) - GetAllSuitByID(w http.ResponseWriter, r *http.Request) - GetAllTestCases(w http.ResponseWriter, r *http.Request) - GetTestCaseByID(w http.ResponseWriter, r *http.Request) - RedirectTriggerForApp(w http.ResponseWriter, r *http.Request) - RedirectTriggerForEnv(w http.ResponseWriter, r *http.Request) -} - -type TestSuitRestHandlerImpl struct { - logger *zap.SugaredLogger - userService user.UserService - validator *validator.Validate - enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - config *client.EventClientConfig - client *http.Client -} - -func NewTestSuitRestHandlerImpl(logger *zap.SugaredLogger, userService user.UserService, - validator *validator.Validate, enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, - config *client.EventClientConfig, client *http.Client) *TestSuitRestHandlerImpl { - return &TestSuitRestHandlerImpl{ - logger: logger, - userService: userService, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - config: config, - client: client, - } -} - -type TestSuiteBean struct { - Link string `json:"link,omitempty"` - PipelineId int `json:"PipelineId"` - TriggerId int `json:"triggerId"` -} - -func (impl TestSuitRestHandlerImpl) SuitesProxy(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - decoder := json.NewDecoder(r.Body) - var bean TestSuiteBean - err = decoder.Decode(&bean) - if err != nil { - impl.logger.Errorw("decode err", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - link := fmt.Sprintf("%s/%s", impl.config.TestSuitURL, bean.Link) - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) GetTestSuites(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - - link := fmt.Sprintf("%s/%s", impl.config.TestSuitURL, "testsuite") - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) DetailedTestSuites(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - - link := fmt.Sprintf("%s/%s", impl.config.TestSuitURL, "testsuites/all") - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) GetAllSuitByID(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - vars := mux.Vars(r) - id, err := strconv.Atoi(vars["pipelineId"]) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - link := fmt.Sprintf("%s/%s/%d", impl.config.TestSuitURL, "testsuite", id) - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) GetAllTestCases(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - - link := fmt.Sprintf("%s/%s", impl.config.TestSuitURL, "testcase") - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) GetTestCaseByID(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - vars := mux.Vars(r) - id, err := strconv.Atoi(vars["pipelineId"]) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - link := fmt.Sprintf("%s/%s/%d", impl.config.TestSuitURL, "testcase", id) - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) RedirectTriggerForApp(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - vars := mux.Vars(r) - appId, err := strconv.Atoi(vars["pipelineId"]) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - link := fmt.Sprintf("%s/%s/%d", impl.config.TestSuitURL, "triggers", appId) - impl.logger.Debugw("redirect to link", "link", link) - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) RedirectTriggerForEnv(w http.ResponseWriter, r *http.Request) { - userId, err := impl.userService.GetLoggedInUser(r) - impl.logger.Debugw("request for user", "userId", userId) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - - vars := mux.Vars(r) - appId, err := strconv.Atoi(vars["pipelineId"]) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - envId, err := strconv.Atoi(vars["triggerId"]) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - link := fmt.Sprintf("%s/%s/%d/%d", impl.config.TestSuitURL, "triggers", appId, envId) - res, err := impl.HttpGet(link) - if err != nil { - impl.logger.Error(err) - } - common.WriteJsonResp(w, err, res, http.StatusOK) -} - -func (impl TestSuitRestHandlerImpl) HttpGet(url string) (map[string]interface{}, error) { - req, err := http.NewRequest(http.MethodGet, url, nil) - if err != nil { - impl.logger.Errorw("error while fetching data", "err", err) - return nil, err - } - resp, err := impl.client.Do(req) - if err != nil { - impl.logger.Errorw("err", err) - return nil, err - } - status := grafana.StatusCode(resp.StatusCode) - resBody, err := ioutil.ReadAll(resp.Body) - var apiRes map[string]interface{} - if status.IsSuccess() { - if err != nil { - impl.logger.Errorw("error in grafana communication ", "err", err) - return nil, err - } - err = json.Unmarshal(resBody, &apiRes) - if err != nil { - impl.logger.Errorw("error in grafana resp unmarshalling ", "err", err) - return nil, err - } - } else { - impl.logger.Errorw("api err", "res", string(resBody)) - return nil, fmt.Errorf("res not success, code: %d ,response body: %s", status, string(resBody)) - } - return apiRes, nil -} diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 8eedcc34b5..e7dfcac719 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -23,7 +23,6 @@ import ( "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/pipeline" bean3 "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/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables/models" @@ -87,9 +86,6 @@ type DevtronAppDeploymentConfigRestHandler interface { } type DevtronAppPrePostDeploymentRestHandler interface { - GetMigrationConfig(w http.ResponseWriter, r *http.Request) - CreateMigrationConfig(w http.ResponseWriter, r *http.Request) - UpdateMigrationConfig(w http.ResponseWriter, r *http.Request) GetStageStatus(w http.ResponseWriter, r *http.Request) GetPrePostDeploymentLogs(w http.ResponseWriter, r *http.Request) // CancelStage Cancel Pre/Post ArgoWorkflow execution @@ -1523,133 +1519,6 @@ func (handler PipelineConfigRestHandlerImpl) GetArtifactsForRollback(w http.Resp common.WriteJsonResp(w, err, ciArtifactResponse, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) GetMigrationConfig(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - pipelineId, err := strconv.Atoi(vars["pipelineId"]) - if err != nil { - handler.Logger.Errorw("request err, GetMigrationConfig", "err", err, "pipelineId", pipelineId) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.Logger.Infow("request payload, GetMigrationConfig", "pipelineId", pipelineId) - token := r.Header.Get("token") - deploymentPipeline, err := handler.pipelineBuilder.FindPipelineById(pipelineId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - app, err := handler.pipelineBuilder.GetApp(deploymentPipeline.AppId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - resourceName := handler.enforcerUtil.GetAppRBACName(app.AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - ciConf, err := handler.dbMigrationService.GetByPipelineId(pipelineId) - if err != nil { - handler.Logger.Errorw("service err, GetMigrationConfig", "err", err, "pipelineId", pipelineId) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, ciConf, http.StatusOK) -} - -func (handler PipelineConfigRestHandlerImpl) CreateMigrationConfig(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := handler.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var dbMigrationConfigBean types.DbMigrationConfigBean - err = decoder.Decode(&dbMigrationConfigBean) - - dbMigrationConfigBean.UserId = userId - if err != nil { - handler.Logger.Errorw("request err, CreateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - err = handler.validator.Struct(dbMigrationConfigBean) - if err != nil { - handler.Logger.Errorw("validation err, CreateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.Logger.Infow("request payload, CreateMigrationConfig", "payload", dbMigrationConfigBean) - token := r.Header.Get("token") - deploymentPipeline, err := handler.pipelineBuilder.FindPipelineById(dbMigrationConfigBean.PipelineId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - app, err := handler.pipelineBuilder.GetApp(deploymentPipeline.AppId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - } - resourceName := handler.enforcerUtil.GetAppRBACName(app.AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - createResp, err := handler.dbMigrationService.Save(&dbMigrationConfigBean) - if err != nil { - handler.Logger.Errorw("service err, CreateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, createResp, http.StatusOK) -} -func (handler PipelineConfigRestHandlerImpl) UpdateMigrationConfig(w http.ResponseWriter, r *http.Request) { - decoder := json.NewDecoder(r.Body) - userId, err := handler.userAuthService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - var dbMigrationConfigBean types.DbMigrationConfigBean - err = decoder.Decode(&dbMigrationConfigBean) - dbMigrationConfigBean.UserId = userId - if err != nil { - handler.Logger.Errorw("request err, UpdateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - err = handler.validator.Struct(dbMigrationConfigBean) - if err != nil { - handler.Logger.Errorw("validation err, UpdateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.Logger.Infow("request payload, UpdateMigrationConfig", "payload", dbMigrationConfigBean) - token := r.Header.Get("token") - deploymentPipeline, err := handler.pipelineBuilder.FindPipelineById(dbMigrationConfigBean.PipelineId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - app, err := handler.pipelineBuilder.GetApp(deploymentPipeline.AppId) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - resourceName := handler.enforcerUtil.GetAppRBACName(app.AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - createResp, err := handler.dbMigrationService.Update(&dbMigrationConfigBean) - if err != nil { - handler.Logger.Errorw("service err, UpdateMigrationConfig", "err", err, "payload", dbMigrationConfigBean) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, createResp, http.StatusOK) -} - func (handler PipelineConfigRestHandlerImpl) EnvConfigOverrideReset(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/PipelineConfigRestHandler.go index cf88641e43..71eeeade08 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/PipelineConfigRestHandler.go @@ -108,7 +108,6 @@ type PipelineConfigRestHandlerImpl struct { Logger *zap.SugaredLogger chartService chart.ChartService propertiesConfigService pipeline.PropertiesConfigService - dbMigrationService pipeline.DbMigrationService application application.ServiceClient userAuthService user.UserService validator *validator.Validate @@ -137,7 +136,6 @@ type PipelineConfigRestHandlerImpl struct { func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger, chartService chart.ChartService, propertiesConfigService pipeline.PropertiesConfigService, - dbMigrationService pipeline.DbMigrationService, application application.ServiceClient, userAuthService user.UserService, teamService team.TeamService, @@ -167,7 +165,6 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger Logger: Logger, chartService: chartService, propertiesConfigService: propertiesConfigService, - dbMigrationService: dbMigrationService, application: application, userAuthService: userAuthService, validator: validator, diff --git a/api/router/MigrateDbRouter.go b/api/router/MigrateDbRouter.go deleted file mode 100644 index 1652ca694a..0000000000 --- a/api/router/MigrateDbRouter.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/gorilla/mux" -) - -type MigrateDbRouter interface { - InitMigrateDbRouter(migrateRouter *mux.Router) -} -type MigrateDbRouterImpl struct { - migrateDbRestHandler restHandler.MigrateDbRestHandler -} - -func NewMigrateDbRouterImpl(migrateDbRestHandler restHandler.MigrateDbRestHandler) *MigrateDbRouterImpl { - return &MigrateDbRouterImpl{migrateDbRestHandler: migrateDbRestHandler} -} -func (impl MigrateDbRouterImpl) InitMigrateDbRouter(migrateRouter *mux.Router) { - migrateRouter.Path("/db"). - HandlerFunc(impl.migrateDbRestHandler.SaveDbConfig). - Methods("POST") - migrateRouter.Path("/db"). - HandlerFunc(impl.migrateDbRestHandler.FetchAllDbConfig). - Methods("GET") - migrateRouter.Path("/db/{id}"). - HandlerFunc(impl.migrateDbRestHandler.FetchOneDbConfig). - Methods("GET") - migrateRouter.Path("/db"). - HandlerFunc(impl.migrateDbRestHandler.UpdateDbConfig). - Methods("PUT") - migrateRouter.Path("/db/autocomplete"). - HandlerFunc(impl.migrateDbRestHandler.FetchDbConfigForAutoComp). - Methods("GET") -} diff --git a/api/router/PipelineConfigRouter.go b/api/router/PipelineConfigRouter.go index 54bc7613ec..1f1339645b 100644 --- a/api/router/PipelineConfigRouter.go +++ b/api/router/PipelineConfigRouter.go @@ -94,10 +94,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/cd-pipeline/{cd_pipeline_id}/material").HandlerFunc(router.restHandler.GetArtifactsByCDPipeline).Methods("GET") configRouter.Path("/cd-pipeline/{cd_pipeline_id}/material/rollback").HandlerFunc(router.restHandler.GetArtifactsForRollback).Methods("GET") - configRouter.Path("/migrate/db").HandlerFunc(router.restHandler.CreateMigrationConfig).Methods("POST") - configRouter.Path("/migrate/db/update").HandlerFunc(router.restHandler.UpdateMigrationConfig).Methods("POST") - configRouter.Path("/migrate/db/{pipelineId}").HandlerFunc(router.restHandler.GetMigrationConfig).Methods("GET") - configRouter.Path("/team/by-id/{teamId}").HandlerFunc(router.restHandler.FindAppsByTeamId).Methods("GET") configRouter.Path("/team/by-name/{teamName}").HandlerFunc(router.restHandler.FindAppsByTeamName).Methods("GET") diff --git a/api/router/ProjectManagementRouter.go b/api/router/ProjectManagementRouter.go deleted file mode 100644 index 35247a1d2a..0000000000 --- a/api/router/ProjectManagementRouter.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/gorilla/mux" -) - -type ProjectManagementRouter interface { - InitProjectManagementRouter(jiraRouter *mux.Router) -} - -type ProjectManagementRouterImpl struct { - jiraRestHandler restHandler.JiraRestHandler -} - -func NewProjectManagementRouterImpl(jiraRestHandler restHandler.JiraRestHandler) *ProjectManagementRouterImpl { - return &ProjectManagementRouterImpl{jiraRestHandler: jiraRestHandler} -} - -func (impl ProjectManagementRouterImpl) InitProjectManagementRouter(jiraRouter *mux.Router) { - jiraRouter.Path("/jira/config"). - Methods("POST"). - HandlerFunc(impl.jiraRestHandler.SaveAccountConfig) - jiraRouter.Path("/jira/release"). - Methods("POST"). - HandlerFunc(impl.jiraRestHandler.UpdateIssueStatus) - -} diff --git a/api/router/TestSuites.go b/api/router/TestSuites.go deleted file mode 100644 index a1ad48af12..0000000000 --- a/api/router/TestSuites.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/gorilla/mux" -) - -type TestSuitRouter interface { - InitTestSuitRouter(gocdRouter *mux.Router) -} -type TestSuitRouterImpl struct { - testSuitRouter restHandler.TestSuitRestHandler -} - -func NewTestSuitRouterImpl(testSuitRouter restHandler.TestSuitRestHandler) *TestSuitRouterImpl { - return &TestSuitRouterImpl{testSuitRouter: testSuitRouter} -} - -func (impl TestSuitRouterImpl) InitTestSuitRouter(configRouter *mux.Router) { - configRouter.Path("/suites/proxy").HandlerFunc(impl.testSuitRouter.SuitesProxy).Methods("POST") - configRouter.Path("/suites/list").HandlerFunc(impl.testSuitRouter.GetTestSuites).Methods("GET") - configRouter.Path("/suites/list/detail").HandlerFunc(impl.testSuitRouter.DetailedTestSuites).Methods("GET") - configRouter.Path("/suites/{pipelineId}").HandlerFunc(impl.testSuitRouter.GetAllSuitByID).Methods("GET") - configRouter.Path("/cases").HandlerFunc(impl.testSuitRouter.GetAllTestCases).Methods("GET") - configRouter.Path("/cases/{pipelineId}").HandlerFunc(impl.testSuitRouter.GetTestCaseByID).Methods("GET") - configRouter.Path("/trigger/{pipelineId}").HandlerFunc(impl.testSuitRouter.RedirectTriggerForApp).Methods("GET") - configRouter.Path("/trigger/{pipelineId}/{triggerId}").HandlerFunc(impl.testSuitRouter.RedirectTriggerForEnv).Methods("GET") -} diff --git a/api/router/router.go b/api/router/router.go index 78b69fcfc8..558940e3f4 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -57,7 +57,6 @@ type MuxRouter struct { HelmRouter PipelineTriggerRouter PipelineConfigRouter PipelineConfigRouter JobRouter JobRouter - MigrateDbRouter MigrateDbRouter EnvironmentClusterMappingsRouter cluster.EnvironmentRouter AppListingRouter AppListingRouter ClusterRouter cluster.ClusterRouter @@ -65,7 +64,6 @@ type MuxRouter struct { UserAuthRouter user.UserAuthRouter ApplicationRouter ApplicationRouter CDRouter CDRouter - ProjectManagementRouter ProjectManagementRouter GitProviderRouter GitProviderRouter GitHostRouter GitHostRouter DockerRegRouter DockerRegRouter @@ -85,7 +83,6 @@ type MuxRouter struct { deploymentGroupRouter DeploymentGroupRouter chartGroupRouter ChartGroupRouter batchOperationRouter BatchOperationRouter - testSuitRouter TestSuitRouter imageScanRouter ImageScanRouter policyRouter PolicyRouter gitOpsConfigRouter GitOpsConfigRouter @@ -125,10 +122,10 @@ type MuxRouter struct { } func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, PipelineConfigRouter PipelineConfigRouter, - MigrateDbRouter MigrateDbRouter, AppListingRouter AppListingRouter, + AppListingRouter AppListingRouter, EnvironmentClusterMappingsRouter cluster.EnvironmentRouter, ClusterRouter cluster.ClusterRouter, WebHookRouter WebhookRouter, UserAuthRouter user.UserAuthRouter, ApplicationRouter ApplicationRouter, - CDRouter CDRouter, ProjectManagementRouter ProjectManagementRouter, + CDRouter CDRouter, GitProviderRouter GitProviderRouter, GitHostRouter GitHostRouter, DockerRegRouter DockerRegRouter, NotificationRouter NotificationRouter, @@ -139,7 +136,7 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P ciEventHandler pubsub.CiEventHandler, pubsubClient *pubsub2.PubSubClientServiceImpl, UserRouter user.UserRouter, ChartRefRouter ChartRefRouter, ConfigMapRouter ConfigMapRouter, AppStoreRouter appStore.AppStoreRouter, chartRepositoryRouter chartRepo.ChartRepositoryRouter, ReleaseMetricsRouter ReleaseMetricsRouter, deploymentGroupRouter DeploymentGroupRouter, batchOperationRouter BatchOperationRouter, - chartGroupRouter ChartGroupRouter, testSuitRouter TestSuitRouter, imageScanRouter ImageScanRouter, + chartGroupRouter ChartGroupRouter, imageScanRouter ImageScanRouter, policyRouter PolicyRouter, gitOpsConfigRouter GitOpsConfigRouter, dashboardRouter dashboard.DashboardRouter, attributesRouter AttributesRouter, userAttributesRouter UserAttributesRouter, commonRouter CommonRouter, grafanaRouter GrafanaRouter, ssoLoginRouter sso.SsoLoginRouter, telemetryRouter TelemetryRouter, telemetryWatcher telemetry.TelemetryEventClient, bulkUpdateRouter BulkUpdateRouter, webhookListenerRouter WebhookListenerRouter, appRouter AppRouter, coreAppRouter CoreAppRouter, helmAppRouter client.HelmAppRouter, k8sApplicationRouter application.K8sApplicationRouter, @@ -158,7 +155,6 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P Router: mux.NewRouter(), HelmRouter: HelmRouter, PipelineConfigRouter: PipelineConfigRouter, - MigrateDbRouter: MigrateDbRouter, EnvironmentClusterMappingsRouter: EnvironmentClusterMappingsRouter, AppListingRouter: AppListingRouter, ClusterRouter: ClusterRouter, @@ -166,7 +162,6 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P UserAuthRouter: UserAuthRouter, ApplicationRouter: ApplicationRouter, CDRouter: CDRouter, - ProjectManagementRouter: ProjectManagementRouter, DockerRegRouter: DockerRegRouter, GitProviderRouter: GitProviderRouter, GitHostRouter: GitHostRouter, @@ -187,7 +182,6 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P deploymentGroupRouter: deploymentGroupRouter, batchOperationRouter: batchOperationRouter, chartGroupRouter: chartGroupRouter, - testSuitRouter: testSuitRouter, imageScanRouter: imageScanRouter, policyRouter: policyRouter, gitOpsConfigRouter: gitOpsConfigRouter, @@ -275,9 +269,6 @@ func (r MuxRouter) Init() { jobConfigRouter := r.Router.PathPrefix("/orchestrator/job").Subrouter() r.JobRouter.InitJobRouter(jobConfigRouter) - migrateRouter := r.Router.PathPrefix("/orchestrator/migrate").Subrouter() - r.MigrateDbRouter.InitMigrateDbRouter(migrateRouter) - environmentClusterMappingsRouter := r.Router.PathPrefix("/orchestrator/env").Subrouter() r.EnvironmentClusterMappingsRouter.InitEnvironmentClusterMappingsRouter(environmentClusterMappingsRouter) r.resourceGroupingRouter.InitResourceGroupingRouter(environmentClusterMappingsRouter) @@ -294,9 +285,6 @@ func (r MuxRouter) Init() { rootRouter := r.Router.PathPrefix("/orchestrator").Subrouter() r.UserAuthRouter.InitUserAuthRouter(rootRouter) - projectManagementRouter := r.Router.PathPrefix("/orchestrator/project-management").Subrouter() - r.ProjectManagementRouter.InitProjectManagementRouter(projectManagementRouter) - gitRouter := r.Router.PathPrefix("/orchestrator/git").Subrouter() r.GitProviderRouter.InitGitProviderRouter(gitRouter) r.GitHostRouter.InitGitHostRouter(gitRouter) @@ -336,9 +324,6 @@ func (r MuxRouter) Init() { chartGroupRouter := r.Router.PathPrefix("/orchestrator/chart-group").Subrouter() r.chartGroupRouter.initChartGroupRouter(chartGroupRouter) - testSuitRouter := r.Router.PathPrefix("/orchestrator/test-report").Subrouter() - r.testSuitRouter.InitTestSuitRouter(testSuitRouter) - imageScanRouter := r.Router.PathPrefix("/orchestrator/security/scan").Subrouter() r.imageScanRouter.InitImageScanRouter(imageScanRouter) diff --git a/api/terminal/UserTerminalAccessRestHandler.go b/api/terminal/UserTerminalAccessRestHandler.go index c2cb455c9e..4b71273c97 100644 --- a/api/terminal/UserTerminalAccessRestHandler.go +++ b/api/terminal/UserTerminalAccessRestHandler.go @@ -39,9 +39,9 @@ type validShellResponse struct { type UserTerminalAccessRestHandlerImpl struct { Logger *zap.SugaredLogger UserTerminalAccessService clusterTerminalAccess.UserTerminalAccessService - Enforcer casbin.Enforcer - UserService user.UserService - validator *validator.Validate + Enforcer casbin.Enforcer + UserService user.UserService + validator *validator.Validate } func NewUserTerminalAccessRestHandlerImpl(logger *zap.SugaredLogger, userTerminalAccessService clusterTerminalAccess.UserTerminalAccessService, Enforcer casbin.Enforcer, diff --git a/client/events/EventBuilder.go b/client/events/EventBuilder.go index d3c8150017..63060238ea 100644 --- a/client/events/EventBuilder.go +++ b/client/events/EventBuilder.go @@ -49,9 +49,9 @@ type EventSimpleFactoryImpl struct { ciWorkflowRepository pipelineConfig.CiWorkflowRepository ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository ciPipelineRepository pipelineConfig.CiPipelineRepository - pipelineRepository pipelineConfig.PipelineRepository - userRepository repository.UserRepository - ciArtifactRepository repository2.CiArtifactRepository + pipelineRepository pipelineConfig.PipelineRepository + userRepository repository.UserRepository + ciArtifactRepository repository2.CiArtifactRepository } func NewEventSimpleFactoryImpl(logger *zap.SugaredLogger, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, diff --git a/client/events/EventClient.go b/client/events/EventClient.go index 9fa5e73591..b32a06c9ff 100644 --- a/client/events/EventClient.go +++ b/client/events/EventClient.go @@ -39,7 +39,6 @@ import ( type EventClientConfig struct { DestinationURL string `env:"EVENT_URL" envDefault:"http://localhost:3000/notify"` - TestSuitURL string `env:"TEST_SUIT_URL" envDefault:"http://localhost:3000"` } func GetEventClientConfig() (*EventClientConfig, error) { @@ -54,7 +53,6 @@ func GetEventClientConfig() (*EventClientConfig, error) { type EventClient interface { WriteNotificationEvent(event Event) (bool, error) WriteNatsEvent(channel string, payload interface{}) error - SendTestSuite(reqBody []byte) (bool, error) } type Event struct { @@ -274,20 +272,3 @@ func (impl *EventRESTClientImpl) WriteNatsEvent(topic string, payload interface{ err = impl.pubsubClient.Publish(topic, string(body)) return err } - -func (impl *EventRESTClientImpl) SendTestSuite(reqBody []byte) (bool, error) { - impl.logger.Debugw("request", "body", string(reqBody)) - req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/triggers", impl.config.TestSuitURL), bytes.NewBuffer(reqBody)) - if err != nil { - impl.logger.Errorw("error while writing test suites", "err", err) - return false, err - } - req.Header.Set("Content-Type", "application/json") - resp, err := impl.client.Do(req) - if err != nil { - impl.logger.Errorw("error while UpdateJiraTransition request ", "err", err) - return false, err - } - impl.logger.Debugw("response from test suit create api", "status code", resp.StatusCode) - return true, err -} diff --git a/internal/sql/repository/DbConfigRepository.go b/internal/sql/repository/DbConfigRepository.go deleted file mode 100644 index e5a26249c8..0000000000 --- a/internal/sql/repository/DbConfigRepository.go +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package repository - -import ( - "github.com/devtron-labs/devtron/pkg/sql" - "github.com/go-pg/pg" - "go.uber.org/zap" -) - -type DbType string - -const ( - Db_TYPE_POSTGRESS DbType = "postgres" - Db_TYPE_MYSQL DbType = "mysql" - DB_TYPE_MARIADB DbType = "mariadb" -) - -func (t DbType) IsValid() bool { - types := map[string]DbType{"postgres": Db_TYPE_POSTGRESS, "mysql": Db_TYPE_MYSQL, "mariadb": DB_TYPE_MARIADB} - _, ok := types[string(t)] - return ok -} - -type DbConfig struct { - tableName struct{} `sql:"db_config" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - Name string `sql:"name"` //name by which user identifies this db - Type DbType `sql:"type"` //type of db, PG, MYsql, MariaDb - Host string `sql:"host"` - Port string `sql:"port"` - DbName string `sql:"db_name"` //name of database inside PG - UserName string `sql:"user_name"` - Password string `sql:"password"` - Active bool `sql:"active"` - sql.AuditLog -} - -type DbConfigRepository interface { - Save(config *DbConfig) error - GetAll() (configs []*DbConfig, err error) - GetById(id int) (*DbConfig, error) - Update(config *DbConfig) (*DbConfig, error) - GetActiveForAutocomplete() (configs []*DbConfig, err error) -} -type DbConfigRepositoryImpl struct { - dbConnection *pg.DB - logger *zap.SugaredLogger -} - -func NewDbConfigRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *DbConfigRepositoryImpl { - return &DbConfigRepositoryImpl{ - dbConnection: dbConnection, - logger: logger, - } -} - -func (impl DbConfigRepositoryImpl) Save(config *DbConfig) error { - return impl.dbConnection.Insert(config) -} - -func (impl DbConfigRepositoryImpl) GetAll() (configs []*DbConfig, err error) { - err = impl.dbConnection.Model(&configs).Select() - return configs, err -} - -func (impl DbConfigRepositoryImpl) GetById(id int) (*DbConfig, error) { - cfg := &DbConfig{Id: id} - err := impl.dbConnection.Model(cfg).WherePK().Select() - return cfg, err -} - -func (impl DbConfigRepositoryImpl) Update(config *DbConfig) (*DbConfig, error) { - _, err := impl.dbConnection.Model(config).WherePK().UpdateNotNull() - return config, err -} - -func (impl DbConfigRepositoryImpl) GetActiveForAutocomplete() (configs []*DbConfig, err error) { - err = impl.dbConnection.Model(&configs). - Where("active = ?", true). - Column("id", "name"). - Select() - - return configs, err -} diff --git a/internal/sql/repository/JiraAccountRepository.go b/internal/sql/repository/JiraAccountRepository.go deleted file mode 100644 index a831db6c8e..0000000000 --- a/internal/sql/repository/JiraAccountRepository.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package repository - -import ( - "github.com/devtron-labs/devtron/pkg/sql" - "github.com/go-pg/pg" - "time" -) - -type JiraAccountDetails struct { - tableName struct{} `sql:"project_management_tool_config" pg:",discard_unknown_columns"` - Id int32 `sql:"id,pk"` - UserName string `sql:"user_name"` - AccountURL string `sql:"account_url"` - AuthToken string `sql:"auth_token"` - CommitMessageRegex string `sql:"commit_message_regex"` - FinalIssueStatus string `sql:"final_issue_status"` - PipelineStage string `sql:"pipeline_stage"` - PipelineId int32 `sql:"pipeline_id"` - sql.AuditLog -} - -type JiraAccountRepository interface { - Save(accountDetails *JiraAccountDetails) error - FindByPipelineIdAndStage(pipelineId int32, pipelineStage string) (*JiraAccountDetails, error) - Update(accountDetails *JiraAccountDetails) error -} - -type JiraAccountRepositoryImpl struct { - dbConnection *pg.DB -} - -func NewJiraAccountRepositoryImpl(dbConnection *pg.DB) *JiraAccountRepositoryImpl { - return &JiraAccountRepositoryImpl{dbConnection: dbConnection} -} - -func (impl *JiraAccountRepositoryImpl) FindByPipelineIdAndStage(pipelineId int32, pipelineStage string) (*JiraAccountDetails, error) { - details := &JiraAccountDetails{} - err := impl.dbConnection.Model(details).Where("pipeline_id = ?", pipelineId).Where("pipeline_stage = ?", pipelineStage).Select() - return details, err -} - -func (impl *JiraAccountRepositoryImpl) Save(jiraAccountDetails *JiraAccountDetails) error { - model, err := impl.FindByPipelineIdAndStage(jiraAccountDetails.PipelineId, jiraAccountDetails.PipelineStage) - if err == nil && model != nil { - impl.buildAccountUpdateModel(jiraAccountDetails, model) - return impl.Update(model) - } - return impl.dbConnection.Insert(jiraAccountDetails) -} - -func (impl *JiraAccountRepositoryImpl) Update(jiraAccountDetails *JiraAccountDetails) error { - return impl.dbConnection.Update(jiraAccountDetails) -} - -func (impl *JiraAccountRepositoryImpl) buildAccountUpdateModel(jiraAccountDetails *JiraAccountDetails, model *JiraAccountDetails) { - if jiraAccountDetails.AccountURL != "" { - model.AccountURL = jiraAccountDetails.AccountURL - } - if jiraAccountDetails.AuthToken != "" { - model.AuthToken = jiraAccountDetails.AuthToken - } - if jiraAccountDetails.UserName != "" { - model.UserName = jiraAccountDetails.UserName - } - if jiraAccountDetails.CommitMessageRegex != "" { - model.CommitMessageRegex = jiraAccountDetails.CommitMessageRegex - } - if jiraAccountDetails.PipelineId != 0 { - model.PipelineId = jiraAccountDetails.PipelineId - } - if jiraAccountDetails.PipelineStage != "" { - model.PipelineStage = jiraAccountDetails.PipelineStage - } - model.UpdatedOn = time.Now() -} diff --git a/internal/sql/repository/pipelineConfig/DbMigrationConfig.go b/internal/sql/repository/pipelineConfig/DbMigrationConfig.go deleted file mode 100644 index 500a63d95f..0000000000 --- a/internal/sql/repository/pipelineConfig/DbMigrationConfig.go +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package pipelineConfig - -import ( - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/pkg/sql" - "github.com/go-pg/pg" - "go.uber.org/zap" -) - -type MigrationTool string - -const MIGRATION_TOOL_MIGRATE MigrationTool = "migrate" - -func (t MigrationTool) IsValid() bool { - types := map[string]MigrationTool{"migrate": MIGRATION_TOOL_MIGRATE} - _, ok := types[string(t)] - return ok -} - -type DbMigrationConfig struct { - tableName struct{} `sql:"db_migration_config" pg:",discard_unknown_columns"` - Id int `sql:"id"` - DbConfigId int `sql:"db_config_id"` - PipelineId int `sql:"pipeline_id"` - GitMaterialId int `sql:"git_material_id"` - ScriptSource string `sql:"script_source"` //location of file in git. relative to git root - MigrationTool MigrationTool `sql:"migration_tool"` - Active bool `sql:"active"` - sql.AuditLog - DbConfig *repository.DbConfig - GitMaterial *GitMaterial -} - -type DbMigrationConfigRepository interface { - Save(config *DbMigrationConfig) error - FindByPipelineId(pipelineId int) (config *DbMigrationConfig, err error) - Update(config *DbMigrationConfig) error -} - -type DbMigrationConfigRepositoryImpl struct { - dbConnection *pg.DB - logger *zap.SugaredLogger -} - -func NewDbMigrationConfigRepositoryImpl(dbConnection *pg.DB, logger *zap.SugaredLogger) *DbMigrationConfigRepositoryImpl { - return &DbMigrationConfigRepositoryImpl{ - dbConnection: dbConnection, - logger: logger, - } -} - -func (impl DbMigrationConfigRepositoryImpl) Save(config *DbMigrationConfig) error { - return impl.dbConnection.Insert(config) -} -func (impl DbMigrationConfigRepositoryImpl) Update(config *DbMigrationConfig) error { - _, err := impl.dbConnection.Model(config).WherePK().UpdateNotNull() - return err -} - -func (impl DbMigrationConfigRepositoryImpl) FindByPipelineId(pipelineId int) (config *DbMigrationConfig, err error) { - config = &DbMigrationConfig{} - err = impl.dbConnection.Model(config). - Column("db_migration_config.*", "DbConfig", "GitMaterial", "GitMaterial.GitProvider"). - Where("db_migration_config.pipeline_id =?", pipelineId). - Where("db_migration_config.active =? ", true). - Select() - return config, err -} diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 29e9c8e826..05c7ddf332 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -111,16 +111,15 @@ type AppServiceImpl struct { ciArtifactRepository repository.CiArtifactRepository pipelineRepository pipelineConfig.PipelineRepository gitFactory *GitFactory - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository eventClient client.EventClient eventFactory client.EventFactory acdClient application.ServiceClient tokenCache *util3.TokenCache acdAuthConfig *util3.ACDAuthConfig enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - user user.UserService - appListingRepository repository.AppListingRepository + enforcerUtil rbac.EnforcerUtil + user user.UserService + appListingRepository repository.AppListingRepository appRepository app.AppRepository envRepository repository2.EnvironmentRepository pipelineConfigRepository chartConfig.PipelineConfigRepository @@ -201,7 +200,6 @@ func NewAppService( logger *zap.SugaredLogger, ciArtifactRepository repository.CiArtifactRepository, pipelineRepository pipelineConfig.PipelineRepository, - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, eventClient client.EventClient, eventFactory client.EventFactory, acdClient application.ServiceClient, cache *util3.TokenCache, authConfig *util3.ACDAuthConfig, @@ -260,7 +258,6 @@ func NewAppService( logger: logger, ciArtifactRepository: ciArtifactRepository, pipelineRepository: pipelineRepository, - dbMigrationConfigRepository: dbMigrationConfigRepository, eventClient: eventClient, eventFactory: eventFactory, acdClient: acdClient, diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 47af5f5dc3..58c54eb5a1 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -124,9 +124,9 @@ type InstalledAppServiceImpl struct { ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService + gitOpsRepository repository3.GitOpsConfigRepository + userService user.UserService + appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository argoUserService argo.ArgoUserService diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index 3f8bb5d4de..7de0bb6574 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -43,9 +43,9 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService + gitOpsRepository repository3.GitOpsConfigRepository + userService user.UserService + appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService } type args struct { diff --git a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go index 143a4e437b..c861291f38 100644 --- a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go @@ -74,9 +74,9 @@ type AppStoreDeploymentArgoCdServiceImpl struct { helmAppService client.HelmAppService gitOpsConfigRepository repository3.GitOpsConfigRepository appStatusService appStatus.AppStatusService - pipelineStatusTimelineService status.PipelineStatusTimelineService - userService user.UserService - pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository + pipelineStatusTimelineService status.PipelineStatusTimelineService + userService user.UserService + pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig diff --git a/pkg/auth/user/bean/bean.go b/pkg/auth/user/bean/bean.go index 93202f386e..b4d7ea9b1a 100644 --- a/pkg/auth/user/bean/bean.go +++ b/pkg/auth/user/bean/bean.go @@ -7,24 +7,24 @@ const ( ENV_TYPE = "environment" APP_TYPE = "app" WorkflowType = "workflow" - CHART_GROUP_TYPE = "chart-group" - MANAGER_TYPE RoleType = "manager" - ADMIN_TYPE RoleType = "admin" - TRIGGER_TYPE RoleType = "trigger" - VIEW_TYPE RoleType = "view" - ENTITY_ALL_TYPE RoleType = "entityAll" - ENTITY_VIEW_TYPE RoleType = "entityView" - ENTITY_SPECIFIC_TYPE RoleType = "entitySpecific" - ENTITY_SPECIFIC_ADMIN_TYPE RoleType = "entitySpecificAdmin" - ENTITY_SPECIFIC_VIEW_TYPE RoleType = "entitySpecificView" - ROLE_SPECIFIC_TYPE RoleType = "roleSpecific" - ENTITY_CLUSTER_ADMIN_TYPE RoleType = "clusterAdmin" - ENTITY_CLUSTER_VIEW_TYPE RoleType = "clusterView" - ADMIN_HELM_TYPE RoleType = "admin" - EDIT_HELM_TYPE RoleType = "edit" - VIEW_HELM_TYPE RoleType = "view" - ENTITY_CLUSTER_EDIT_TYPE RoleType = "clusterEdit" - DEVTRON_APP = "devtron-app" + CHART_GROUP_TYPE = "chart-group" + MANAGER_TYPE RoleType = "manager" + ADMIN_TYPE RoleType = "admin" + TRIGGER_TYPE RoleType = "trigger" + VIEW_TYPE RoleType = "view" + ENTITY_ALL_TYPE RoleType = "entityAll" + ENTITY_VIEW_TYPE RoleType = "entityView" + ENTITY_SPECIFIC_TYPE RoleType = "entitySpecific" + ENTITY_SPECIFIC_ADMIN_TYPE RoleType = "entitySpecificAdmin" + ENTITY_SPECIFIC_VIEW_TYPE RoleType = "entitySpecificView" + ROLE_SPECIFIC_TYPE RoleType = "roleSpecific" + ENTITY_CLUSTER_ADMIN_TYPE RoleType = "clusterAdmin" + ENTITY_CLUSTER_VIEW_TYPE RoleType = "clusterView" + ADMIN_HELM_TYPE RoleType = "admin" + EDIT_HELM_TYPE RoleType = "edit" + VIEW_HELM_TYPE RoleType = "view" + ENTITY_CLUSTER_EDIT_TYPE RoleType = "clusterEdit" + DEVTRON_APP = "devtron-app" SUPER_ADMIN = "super-admin" CLUSTER = "cluster" GLOBAL_ENTITY = "globalEntity" diff --git a/pkg/auth/user/repository/UserAuditRepository.go b/pkg/auth/user/repository/UserAuditRepository.go index e82382181f..6568b57144 100644 --- a/pkg/auth/user/repository/UserAuditRepository.go +++ b/pkg/auth/user/repository/UserAuditRepository.go @@ -16,7 +16,7 @@ */ /* - @description: user crud +@description: user crud */ package repository diff --git a/pkg/auth/user/repository/UserRepository.go b/pkg/auth/user/repository/UserRepository.go index 31864907a1..191b296c07 100644 --- a/pkg/auth/user/repository/UserRepository.go +++ b/pkg/auth/user/repository/UserRepository.go @@ -66,8 +66,8 @@ type UserRoleModel struct { TableName struct{} `sql:"user_roles"` Id int `sql:"id,pk"` UserId int32 `sql:"user_id,notnull"` - RoleId int `sql:"role_id,notnull"` - User UserModel + RoleId int `sql:"role_id,notnull"` + User UserModel sql.AuditLog } diff --git a/pkg/jira/JiraService.go b/pkg/jira/JiraService.go deleted file mode 100644 index e65b04a913..0000000000 --- a/pkg/jira/JiraService.go +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package jira - -import ( - "errors" - "github.com/devtron-labs/devtron/internal/sql/repository" - jiraUtil "github.com/devtron-labs/devtron/internal/util/JiraUtil" - "github.com/devtron-labs/devtron/pkg/projectManagementService/jira" - "github.com/devtron-labs/devtron/pkg/sql" - "go.uber.org/zap" - "time" -) - -type ProjectManagementService interface { - UpdateJiraStatus(updateIssueBean *UpdateIssueBean, userId int32) (map[string][]string, error) - SaveAccountDetails(jiraConfig *ConfigBean, userId int32) (*repository.JiraAccountDetails, error) -} - -type ProjectManagementServiceImpl struct { - logger *zap.SugaredLogger - accountValidator jira.AccountValidator - jiraAccountService jira.AccountService - jiraAccountRepository repository.JiraAccountRepository -} - -func NewProjectManagementServiceImpl(logger *zap.SugaredLogger, jiraAccountService jira.AccountService, - jiraAccountRepository repository.JiraAccountRepository, accountValidator jira.AccountValidator) *ProjectManagementServiceImpl { - return &ProjectManagementServiceImpl{ - logger: logger, - jiraAccountService: jiraAccountService, - jiraAccountRepository: jiraAccountRepository, - accountValidator: accountValidator, - } -} - -type Commit struct { - CommitId string `json:"commitId"` - CommitMessage string `json:"commitMessage"` -} - -type UpdateIssueBean struct { - PipelineId int32 `json:"pipelineId" validate:"number,required"` - PipelineStage string `json:"pipelineStage" validate:"required"` - Commits []Commit `json:"commits" validate:"required" ` -} - -type ConfigBean struct { - UserId int32 `json:"userId" validate:"number,required"` - PipelineId int32 `json:"pipelineId" validate:"number,required"` - PipelineStage string `json:"pipelineStage" validate:"required"` - FinalIssueStatus string `json:"finalIssueStatus" validate:"required"` - ProjectManagementToolAuthToken string `json:"projectManagementToolAuthToken" validate:"required"` - CommitIdRegex string `json:"commitIdRegex" validate:"required"` - ToolUserName string `json:"toolUserName" validate:"required"` - CompanyToolUrl string `json:"companyToolUrl" validate:"required"` -} - -type AccountDetails struct { - UserId int32 - ProjectManagementToolAuthToken string - CommitIdRegex string - UserName string - URL string - FinalIssueStatus string -} - -func (impl *ProjectManagementServiceImpl) SaveAccountDetails(jiraConfig *ConfigBean, userId int32) (*repository.JiraAccountDetails, error) { - if jiraConfig == nil { - impl.logger.Errorw("error in saving account details", "jiraConfig", jiraConfig) - return nil, errors.New("failed SaveJiraAccountDetails, invalid accountDetails") - } - - isAuthenticated, err := impl.accountValidator.ValidateUserAccount(jiraConfig.CompanyToolUrl, jiraConfig.ToolUserName, jiraConfig.ProjectManagementToolAuthToken) - if err != nil { - impl.logger.Errorw("some error in saving account details", "err", err) - return nil, err - } - if !isAuthenticated { - impl.logger.Errorw("cannot SaveJiraAccountDetails, jira authentication failed", "isAuthenticated", isAuthenticated) - return nil, errors.New("jira authentication failed") - } - - account := &repository.JiraAccountDetails{ - UserName: jiraConfig.ToolUserName, - AccountURL: jiraConfig.CompanyToolUrl, - AuthToken: jiraConfig.ProjectManagementToolAuthToken, - CommitMessageRegex: jiraConfig.CommitIdRegex, - FinalIssueStatus: jiraConfig.FinalIssueStatus, - PipelineStage: jiraConfig.PipelineStage, - PipelineId: jiraConfig.PipelineId, - AuditLog: sql.AuditLog{ - CreatedBy: jiraConfig.UserId, - CreatedOn: time.Now(), - UpdatedOn: time.Now(), - UpdatedBy: jiraConfig.UserId, - }, - } - - err = impl.jiraAccountRepository.Save(account) - if err != nil { - return nil, err - } - return account, nil -} - -func (impl *ProjectManagementServiceImpl) UpdateJiraStatus(UpdateIssueBean *UpdateIssueBean, userId int32) (map[string][]string, error) { - commits := UpdateIssueBean.Commits - if len(commits) == 0 { - impl.logger.Errorw("no commits provided", "commits len", len(commits)) - return nil, errors.New("no commits provided") - } - accountDetails, err := impl.jiraAccountRepository.FindByPipelineIdAndStage(UpdateIssueBean.PipelineId, UpdateIssueBean.PipelineStage) - if err != nil { - impl.logger.Errorw("failed to get user account details", "err", err) - return nil, err - } - - regex := accountDetails.CommitMessageRegex - commitMap, invalidRegexCommits := impl.buildCommitMap(commits, regex) - - finalIssueStatus := accountDetails.FinalIssueStatus - - updateRequest := &jira.UpdateRequest{ - UserId: userId, - UserName: accountDetails.UserName, - AuthToken: accountDetails.AuthToken, - AccountURL: accountDetails.AccountURL, - CommitMap: commitMap, - } - resp, err := impl.jiraAccountService.UpdateJiraStatus(updateRequest, finalIssueStatus) - if err != nil { - return nil, err - } - invalidCommits := map[string][]string{"invalidCommits": resp} - if invalidRegexCommits != nil { - invalidCommits["invalidRegexCommits"] = invalidRegexCommits - } - return invalidCommits, nil -} - -func (impl *ProjectManagementServiceImpl) buildCommitMap(commits []Commit, regex string) (map[string]string, []string) { - var invalidCommits []string - commitsMap := make(map[string]string) - for _, commit := range commits { - issueIds, err := jiraUtil.ExtractRegex(regex, commit.CommitMessage) - if err != nil { - impl.logger.Errorw("failed to extract issueIds for commit: ", commit.CommitId, "err", err) - invalidCommits = append(invalidCommits, "failed to extract regex for commitId: "+commit.CommitId+" and commit msg: "+commit.CommitMessage) - continue - } - for _, issueId := range issueIds { - if commitsMap[issueId] == "" { - commitsMap[issueId] = commit.CommitId - } - } - } - return commitsMap, invalidCommits -} diff --git a/pkg/notifier/NotificationConfigService.go b/pkg/notifier/NotificationConfigService.go index 43ca1f07e2..123caa3c09 100644 --- a/pkg/notifier/NotificationConfigService.go +++ b/pkg/notifier/NotificationConfigService.go @@ -57,9 +57,9 @@ type NotificationConfigServiceImpl struct { smtpRepository repository.SMTPNotificationRepository teamRepository repository2.TeamRepository environmentRepository repository3.EnvironmentRepository - appRepository app.AppRepository - userRepository repository4.UserRepository - ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository + appRepository app.AppRepository + userRepository repository4.UserRepository + ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository } type NotificationSettingRequest struct { diff --git a/pkg/pipeline/AppArtifactManager.go b/pkg/pipeline/AppArtifactManager.go index 69dfbf762d..7ec6f4d57d 100644 --- a/pkg/pipeline/AppArtifactManager.go +++ b/pkg/pipeline/AppArtifactManager.go @@ -52,9 +52,9 @@ type AppArtifactManager interface { type AppArtifactManagerImpl struct { logger *zap.SugaredLogger - cdWorkflowRepository pipelineConfig.CdWorkflowRepository - userService user.UserService - imageTaggingService ImageTaggingService + cdWorkflowRepository pipelineConfig.CdWorkflowRepository + userService user.UserService + imageTaggingService ImageTaggingService ciArtifactRepository repository.CiArtifactRepository ciWorkflowRepository pipelineConfig.CiWorkflowRepository pipelineStageService PipelineStageService diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 2ab9eff647..9ea10e3a33 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -18,10 +18,8 @@ package pipeline import ( - "archive/zip" "bufio" "context" - "encoding/json" "errors" "fmt" "io/ioutil" @@ -84,7 +82,6 @@ type CiHandler interface { FetchCiStatusForTriggerViewV1(appId int) ([]*pipelineConfig.CiWorkflowStatus, error) RefreshMaterialByCiPipelineMaterialId(gitMaterialId int) (refreshRes *gitSensor.RefreshGitMaterialResponse, err error) FetchMaterialInfoByArtifactId(ciArtifactId int, envId int) (*types.GitTriggerInfoResponse, error) - WriteToCreateTestSuites(pipelineId int, buildId int, triggeredBy int) UpdateCiWorkflowStatusFailure(timeoutForFailureCiBuild int) error FetchCiStatusForTriggerViewForEnvironment(request resourceGroup.ResourceGroupingRequest, token string) ([]*pipelineConfig.CiWorkflowStatus, error) } @@ -1195,8 +1192,6 @@ func (impl *CiHandlerImpl) UpdateWorkflow(workflowStatus v1alpha1.WorkflowStatus } else { impl.Logger.Infof("Step failed notification received for wfID %d with message %s", savedWorkflow.Id, savedWorkflow.Message) } - - impl.WriteToCreateTestSuites(savedWorkflow.CiPipelineId, workflowId, int(savedWorkflow.TriggeredBy)) } } return savedWorkflow.Id, nil @@ -1584,76 +1579,6 @@ func (impl *CiHandlerImpl) FetchMaterialInfoByArtifactId(ciArtifactId int, envId return gitTriggerInfoResponse, nil } -func (impl *CiHandlerImpl) WriteToCreateTestSuites(pipelineId int, buildId int, triggeredBy int) { - testReportFile, err := impl.DownloadCiWorkflowArtifacts(pipelineId, buildId) - if err != nil { - impl.Logger.Errorw("WriteTestSuite, error in fetching report file from s3", "err", err, "pipelineId", pipelineId, "buildId", buildId) - return - } - if testReportFile == nil { - return - } - read, err := zip.OpenReader(testReportFile.Name()) - if err != nil { - impl.Logger.Errorw("WriteTestSuite, error while open reader", "name", testReportFile.Name()) - return - } - defer read.Close() - const CreatedBy = "created_by" - const TriggerId = "trigger_id" - const CiPipelineId = "ci_pipeline_id" - const XML = "xml" - payload := make(map[string]interface{}) - var reports []string - payload[CreatedBy] = triggeredBy - payload[TriggerId] = buildId - payload[CiPipelineId] = pipelineId - payload[XML] = reports - for _, file := range read.File { - if payload, err = impl.listFiles(file, payload); err != nil { - impl.Logger.Errorw("WriteTestSuite, failed to read from zip", "file", file.Name, "error", err) - return - } - } - b, err := json.Marshal(payload) - if err != nil { - impl.Logger.Errorw("WriteTestSuite, payload marshal error", "error", err) - return - } - impl.Logger.Debugw("WriteTestSuite, sending to create", "TriggerId", buildId) - _, err = impl.eventClient.SendTestSuite(b) - if err != nil { - impl.Logger.Errorw("WriteTestSuite, error while making test suit post request", "err", err) - return - } -} - -func (impl *CiHandlerImpl) listFiles(file *zip.File, payload map[string]interface{}) (map[string]interface{}, error) { - fileRead, err := file.Open() - if err != nil { - return payload, err - } - defer fileRead.Close() - - if strings.Contains(file.Name, ".xml") { - content, err := ioutil.ReadAll(fileRead) - if err != nil { - impl.Logger.Errorw("panic error", "err", err) - return payload, err - } - var reports []string - if _, ok := payload["xml"]; !ok { - reports = append(reports, string([]byte(content))) - payload["xml"] = reports - } else { - reports = payload["xml"].([]string) - reports = append(reports, string([]byte(content))) - payload["xml"] = reports - } - } - return payload, nil -} - func (impl *CiHandlerImpl) UpdateCiWorkflowStatusFailure(timeoutForFailureCiBuild int) error { ciWorkflows, err := impl.ciWorkflowRepository.FindByStatusesIn([]string{Starting, Running}) if err != nil { diff --git a/pkg/pipeline/DbConfigService.go b/pkg/pipeline/DbConfigService.go deleted file mode 100644 index cddc525548..0000000000 --- a/pkg/pipeline/DbConfigService.go +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package pipeline - -import ( - "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/pkg/pipeline/types" - "github.com/devtron-labs/devtron/pkg/sql" - "go.uber.org/zap" - "time" -) - -type DbConfigService interface { - Save(dbConfigBean *types.DbConfigBean) (dbConfig *types.DbConfigBean, err error) - GetAll() (dbConfigs []*types.DbConfigBean, err error) - GetById(id int) (dbConfig *types.DbConfigBean, err error) - Update(dbConfigBean *types.DbConfigBean) (dbConfig *types.DbConfigBean, err error) - GetForAutocomplete() (dbConfigs []*types.DbConfigBean, err error) -} -type DbConfigServiceImpl struct { - configRepo repository.DbConfigRepository - logger *zap.SugaredLogger -} - -func NewDbConfigService(configRepo repository.DbConfigRepository, - logger *zap.SugaredLogger) *DbConfigServiceImpl { - return &DbConfigServiceImpl{ - configRepo: configRepo, - logger: logger, - } -} -func (impl DbConfigServiceImpl) Save(dbConfigBean *types.DbConfigBean) (dbConfig *types.DbConfigBean, err error) { - t := repository.DbType(dbConfigBean.Type) - if valid := t.IsValid(); !valid { - impl.logger.Errorw("invalid type", "dbType", dbConfigBean.Type) - return nil, fmt.Errorf("invalid type %s ", dbConfigBean.Type) - } - config := &repository.DbConfig{ - Password: dbConfigBean.Password, - Port: dbConfigBean.Port, - Host: dbConfigBean.Host, - UserName: dbConfigBean.UserName, - Type: t, - Name: dbConfigBean.Name, - Active: dbConfigBean.Active, - DbName: dbConfigBean.DbName, - AuditLog: sql.AuditLog{ - CreatedBy: dbConfigBean.UserId, - UpdatedBy: dbConfigBean.UserId, - CreatedOn: time.Now(), - UpdatedOn: time.Now(), - }, - } - err = impl.configRepo.Save(config) - if err != nil { - impl.logger.Errorw("error in saving db config", "err", err) - return nil, err - } - dbConfigBean.Id = config.Id - return dbConfigBean, nil -} - -func (impl DbConfigServiceImpl) GetAll() (dbConfigs []*types.DbConfigBean, err error) { - configs, err := impl.configRepo.GetAll() - if err != nil { - return nil, err - } - for _, cfg := range configs { - bean := impl.modelToBeanAdaptor(cfg) - dbConfigs = append(dbConfigs, bean) - } - return dbConfigs, err -} -func (impl DbConfigServiceImpl) GetById(id int) (dbConfig *types.DbConfigBean, err error) { - cfg, err := impl.configRepo.GetById(id) - if err != nil { - return nil, err - } - dbConfig = impl.modelToBeanAdaptor(cfg) - return dbConfig, nil -} - -func (impl DbConfigServiceImpl) Update(dbConfigBean *types.DbConfigBean) (dbConfig *types.DbConfigBean, err error) { - var t repository.DbType - if dbConfigBean.Type != "" { - t = repository.DbType(dbConfigBean.Type) - if valid := t.IsValid(); !valid { - impl.logger.Errorw("invalid type", "dbType", dbConfigBean.Type) - return nil, fmt.Errorf("invalid type %s ", dbConfigBean.Type) - } - } - - config := &repository.DbConfig{ - Id: dbConfigBean.Id, - Password: dbConfigBean.Password, - Port: dbConfigBean.Port, - Host: dbConfigBean.Host, - UserName: dbConfigBean.UserName, - Type: t, - Name: dbConfigBean.Name, - Active: dbConfigBean.Active, - DbName: dbConfigBean.DbName, - AuditLog: sql.AuditLog{ - UpdatedBy: dbConfigBean.UserId, - UpdatedOn: time.Now(), - }, - } - _, err = impl.configRepo.Update(config) - return dbConfigBean, err -} - -func (impl DbConfigServiceImpl) modelToBeanAdaptor(conf *repository.DbConfig) (bean *types.DbConfigBean) { - bean = &types.DbConfigBean{ - DbName: conf.DbName, - Active: conf.Active, - Name: conf.Name, - Type: string(conf.Type), - UserName: conf.UserName, - Host: conf.Host, - Port: conf.Port, - Password: conf.Password, - Id: conf.Id, - } - return bean -} - -func (impl DbConfigServiceImpl) GetForAutocomplete() (dbConfigs []*types.DbConfigBean, err error) { - dbConf, err := impl.configRepo.GetActiveForAutocomplete() - if err != nil { - return nil, err - } - for _, cfg := range dbConf { - bean := impl.modelToBeanAdaptor(cfg) - dbConfigs = append(dbConfigs, bean) - } - return dbConfigs, nil -} diff --git a/pkg/pipeline/DbMigrationService.go b/pkg/pipeline/DbMigrationService.go deleted file mode 100644 index cbe6007ba2..0000000000 --- a/pkg/pipeline/DbMigrationService.go +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package pipeline - -import ( - "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/pkg/pipeline/types" - "github.com/devtron-labs/devtron/pkg/sql" - "go.uber.org/zap" - "time" -) - -type DbMigrationService interface { - Save(bean *types.DbMigrationConfigBean) (*types.DbMigrationConfigBean, error) - Update(bean *types.DbMigrationConfigBean) (*types.DbMigrationConfigBean, error) - GetByPipelineId(pipelineId int) (*types.DbMigrationConfigBean, error) -} -type DbMigrationServiceImpl struct { - logger *zap.SugaredLogger - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository -} - -func NewDbMogrationService(logger *zap.SugaredLogger, - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository) *DbMigrationServiceImpl { - return &DbMigrationServiceImpl{ - dbMigrationConfigRepository: dbMigrationConfigRepository, - logger: logger, - } -} - -func (impl DbMigrationServiceImpl) Save(bean *types.DbMigrationConfigBean) (*types.DbMigrationConfigBean, error) { - if valid := pipelineConfig.MigrationTool(bean.MigrationTool).IsValid(); !valid { - return nil, fmt.Errorf("unsupported migration tool %s", bean.MigrationTool) - } - migrationConfig := impl.beanToModelAdaptor(bean) - migrationConfig.AuditLog = sql.AuditLog{ - UpdatedOn: time.Now(), - CreatedOn: time.Now(), - CreatedBy: bean.UserId, - UpdatedBy: bean.UserId, - } - err := impl.dbMigrationConfigRepository.Save(migrationConfig) - if err != nil { - impl.logger.Errorw("error in saving db migration config", "cfg", bean, "err", err) - return nil, err - } - bean.Id = migrationConfig.Id - return bean, nil -} - -func (impl DbMigrationServiceImpl) Update(bean *types.DbMigrationConfigBean) (*types.DbMigrationConfigBean, error) { - if bean.MigrationTool != "" { - if valid := pipelineConfig.MigrationTool(bean.MigrationTool).IsValid(); !valid { - return nil, fmt.Errorf("unsupported migration tool %s", bean.MigrationTool) - } - } - - migrationConfig := impl.beanToModelAdaptor(bean) - migrationConfig.AuditLog = sql.AuditLog{ - UpdatedOn: time.Now(), - UpdatedBy: bean.UserId, - } - err := impl.dbMigrationConfigRepository.Update(migrationConfig) - if err != nil { - impl.logger.Errorw("error in updating db migration config", "cfg", bean, "err", err) - return nil, err - } - bean.Id = migrationConfig.Id - return bean, nil -} - -func (impl DbMigrationServiceImpl) GetByPipelineId(pipelineId int) (*types.DbMigrationConfigBean, error) { - cfg, err := impl.dbMigrationConfigRepository.FindByPipelineId(pipelineId) - if err != nil { - impl.logger.Errorw("error in fetching pipeline db migration config", "id", pipelineId, "err", err) - return nil, err - } - bean := &types.DbMigrationConfigBean{ - MigrationTool: string(cfg.MigrationTool), - GitMaterialId: cfg.GitMaterialId, - PipelineId: cfg.PipelineId, - ScriptSource: cfg.ScriptSource, - Active: cfg.Active, - DbConfigId: cfg.DbConfigId, - Id: cfg.Id, - } - return bean, nil - -} - -func (impl DbMigrationServiceImpl) beanToModelAdaptor(bean *types.DbMigrationConfigBean) *pipelineConfig.DbMigrationConfig { - - migrationConfig := &pipelineConfig.DbMigrationConfig{ - Id: bean.Id, - DbConfigId: bean.DbConfigId, - Active: bean.Active, - ScriptSource: bean.ScriptSource, - PipelineId: bean.PipelineId, - GitMaterialId: bean.GitMaterialId, - MigrationTool: pipelineConfig.MigrationTool(bean.MigrationTool), - } - return migrationConfig -} diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 7a8ac4a6db..a4c53eca50 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -132,8 +132,6 @@ type WorkflowDagExecutorImpl struct { enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil groupRepository repository.DeploymentGroupRepository - tokenCache *util3.TokenCache - acdAuthConfig *util3.ACDAuthConfig envRepository repository2.EnvironmentRepository eventFactory client.EventFactory eventClient client.EventClient @@ -155,9 +153,8 @@ type WorkflowDagExecutorImpl struct { appServiceConfig *app.AppServiceConfig globalPluginService plugin.GlobalPluginService - scopedVariableManager variables.ScopedVariableCMCSManager - variableSnapshotHistoryService variables.VariableSnapshotHistoryService - pluginInputVariableParser PluginInputVariableParser + scopedVariableManager variables.ScopedVariableCMCSManager + pluginInputVariableParser PluginInputVariableParser devtronAsyncHelmInstallRequestMap map[int]bool devtronAsyncHelmInstallRequestLock *sync.Mutex @@ -190,7 +187,6 @@ type WorkflowDagExecutorImpl struct { environmentConfigRepository chartConfig.EnvConfigOverrideRepository appLevelMetricsRepository repository.AppLevelMetricsRepository envLevelMetricsRepository repository.EnvLevelAppMetricsRepository - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil gitOpsConfigRepository repository.GitOpsConfigRepository gitFactory *util.GitFactory @@ -254,8 +250,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi user user.UserService, groupRepository repository.DeploymentGroupRepository, envRepository repository2.EnvironmentRepository, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, tokenCache *util3.TokenCache, - acdAuthConfig *util3.ACDAuthConfig, eventFactory client.EventFactory, + enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, eventFactory client.EventFactory, eventClient client.EventClient, cvePolicyRepository security.CvePolicyRepository, scanResultRepository security.ImageScanResultRepository, appWorkflowRepository appWorkflow.AppWorkflowRepository, @@ -267,7 +262,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi ciWorkflowRepository pipelineConfig.CiWorkflowRepository, appLabelRepository pipelineConfig.AppLabelRepository, gitSensorGrpcClient gitSensorClient.Client, pipelineStageService PipelineStageService, k8sCommonService k8s.K8sCommonService, - variableSnapshotHistoryService variables.VariableSnapshotHistoryService, globalPluginService plugin.GlobalPluginService, pluginInputVariableParser PluginInputVariableParser, scopedVariableManager variables.ScopedVariableCMCSManager, @@ -298,7 +292,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository chartConfig.EnvConfigOverrideRepository, appLevelMetricsRepository repository.AppLevelMetricsRepository, envLevelMetricsRepository repository.EnvLevelAppMetricsRepository, - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, gitOpsConfigRepository repository.GitOpsConfigRepository, gitFactory *util.GitFactory, @@ -322,8 +315,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi enforcer: enforcer, enforcerUtil: enforcerUtil, groupRepository: groupRepository, - tokenCache: tokenCache, - acdAuthConfig: acdAuthConfig, envRepository: envRepository, eventFactory: eventFactory, eventClient: eventClient, @@ -375,7 +366,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository: environmentConfigRepository, appLevelMetricsRepository: appLevelMetricsRepository, envLevelMetricsRepository: envLevelMetricsRepository, - dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, gitOpsConfigRepository: gitOpsConfigRepository, gitFactory: gitFactory, @@ -3256,8 +3246,8 @@ func (impl *WorkflowDagExecutorImpl) GetValuesOverrideForTrigger(overrideRequest return valuesOverrideResponse, err } var ( - pipelineOverride *chartConfig.PipelineOverride - dbMigrationOverride, configMapJson, appLabelJsonByte []byte + pipelineOverride *chartConfig.PipelineOverride + configMapJson, appLabelJsonByte []byte ) // Conditional Block based on PipelineOverrideCreated --> start @@ -3288,15 +3278,6 @@ func (impl *WorkflowDagExecutorImpl) GetValuesOverrideForTrigger(overrideRequest // Conditional Block based on PipelineOverrideCreated --> start if !isPipelineOverrideCreated { - _, span = otel.Tracer("orchestrator").Start(ctx, "getDbMigrationOverride") - //FIXME: how to determine rollback - //we can't depend on ciArtifact ID because CI pipeline can be manually triggered in any order regardless of sourcecode status - dbMigrationOverride, err = impl.getDbMigrationOverride(overrideRequest, artifact, false) - span.End() - if err != nil { - impl.logger.Errorw("error in fetching db migration config", "req", overrideRequest, "err", err) - return valuesOverrideResponse, err - } chartVersion := envOverride.Chart.ChartVersion _, span = otel.Tracer("orchestrator").Start(ctx, "getConfigMapAndSecretJsonV2") scope := getScopeForVariables(overrideRequest, envOverride) @@ -3316,7 +3297,7 @@ func (impl *WorkflowDagExecutorImpl) GetValuesOverrideForTrigger(overrideRequest appLabelJsonByte = nil } - mergedValues, err := impl.mergeOverrideValues(envOverride, dbMigrationOverride, releaseOverrideJson, configMapJson, appLabelJsonByte, strategy) + mergedValues, err := impl.mergeOverrideValues(envOverride, releaseOverrideJson, configMapJson, appLabelJsonByte, strategy) appName := fmt.Sprintf("%s-%s", overrideRequest.AppName, envOverride.Environment.Name) mergedValues = impl.autoscalingCheckBeforeTrigger(ctx, appName, envOverride.Namespace, mergedValues, overrideRequest) @@ -3838,70 +3819,6 @@ func (impl *WorkflowDagExecutorImpl) GetAppMetricsByTriggerType(overrideRequest return appMetrics, nil } -func (impl *WorkflowDagExecutorImpl) getDbMigrationOverride(overrideRequest *bean.ValuesOverrideRequest, artifact *repository.CiArtifact, isRollback bool) (overrideJson []byte, err error) { - if isRollback { - return nil, fmt.Errorf("rollback not supported ye") - } - notConfigured := false - config, err := impl.dbMigrationConfigRepository.FindByPipelineId(overrideRequest.PipelineId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("error in fetching pipeline override config", "req", overrideRequest, "err", err) - return nil, err - } else if util.IsErrNoRows(err) { - notConfigured = true - } - envVal := &EnvironmentOverride{} - if notConfigured { - impl.logger.Warnw("no active db migration found", "pipeline", overrideRequest.PipelineId) - envVal.Enabled = false - } else { - materialInfos, err := artifact.ParseMaterialInfo() - if err != nil { - return nil, err - } - - hash, ok := materialInfos[config.GitMaterial.Url] - if !ok { - impl.logger.Errorf("wrong url map ", "map", materialInfos, "url", config.GitMaterial.Url) - return nil, fmt.Errorf("configured url not found in material %s", config.GitMaterial.Url) - } - - envVal.Enabled = true - if config.GitMaterial.GitProvider.AuthMode != repository.AUTH_MODE_USERNAME_PASSWORD && - config.GitMaterial.GitProvider.AuthMode != repository.AUTH_MODE_ACCESS_TOKEN && - config.GitMaterial.GitProvider.AuthMode != repository.AUTH_MODE_ANONYMOUS { - return nil, fmt.Errorf("auth mode %s not supported for migration", config.GitMaterial.GitProvider.AuthMode) - } - envVal.appendEnvironmentVariable("GIT_REPO_URL", config.GitMaterial.Url) - envVal.appendEnvironmentVariable("GIT_USER", config.GitMaterial.GitProvider.UserName) - var password string - if config.GitMaterial.GitProvider.AuthMode == repository.AUTH_MODE_USERNAME_PASSWORD { - password = config.GitMaterial.GitProvider.Password - } else { - password = config.GitMaterial.GitProvider.AccessToken - } - envVal.appendEnvironmentVariable("GIT_AUTH_TOKEN", password) - // parse git-tag not required - //envVal.appendEnvironmentVariable("GIT_TAG", "") - envVal.appendEnvironmentVariable("GIT_HASH", hash) - envVal.appendEnvironmentVariable("SCRIPT_LOCATION", config.ScriptSource) - envVal.appendEnvironmentVariable("DB_TYPE", string(config.DbConfig.Type)) - envVal.appendEnvironmentVariable("DB_USER_NAME", config.DbConfig.UserName) - envVal.appendEnvironmentVariable("DB_PASSWORD", config.DbConfig.Password) - envVal.appendEnvironmentVariable("DB_HOST", config.DbConfig.Host) - envVal.appendEnvironmentVariable("DB_PORT", config.DbConfig.Port) - envVal.appendEnvironmentVariable("DB_NAME", config.DbConfig.DbName) - //Will be used for rollback don't delete it - //envVal.appendEnvironmentVariable("MIGRATE_TO_VERSION", strconv.Itoa(overrideRequest.TargetDbVersion)) - } - dbMigrationConfig := map[string]interface{}{"dbMigrationConfig": envVal} - confByte, err := json.Marshal(dbMigrationConfig) - if err != nil { - return nil, err - } - return confByte, nil -} - type ConfigMapAndSecretJsonV2 struct { AppId int EnvId int @@ -4095,142 +4012,7 @@ func (impl *WorkflowDagExecutorImpl) getReleaseOverride(envOverride *chartConfig return override, nil } -func (impl *WorkflowDagExecutorImpl) mergeAndSave(envOverride *chartConfig.EnvConfigOverride, - overrideRequest *bean.ValuesOverrideRequest, - dbMigrationOverride []byte, - artifact *repository.CiArtifact, - pipeline *pipelineConfig.Pipeline, configMapJson, appLabelJsonByte []byte, strategy *chartConfig.PipelineStrategy, ctx context.Context, - triggeredAt time.Time, deployedBy int32, appMetrics *bool) (releaseId int, overrideId int, mergedValues string, err error) { - - //register release , obtain release id TODO: populate releaseId to template - override, err := impl.savePipelineOverride(overrideRequest, envOverride.Id, triggeredAt) - if err != nil { - return 0, 0, "", err - } - //TODO: check status and apply lock - overrideJson, err := impl.getReleaseOverride(envOverride, overrideRequest, artifact, override, strategy, appMetrics) - if err != nil { - return 0, 0, "", err - } - - //merge three values on the fly - //ordering is important here - //global < environment < db< release - var merged []byte - if !envOverride.IsOverride { - merged, err = impl.mergeUtil.JsonPatch([]byte("{}"), []byte(envOverride.Chart.GlobalOverride)) - if err != nil { - return 0, 0, "", err - } - } else { - merged, err = impl.mergeUtil.JsonPatch([]byte("{}"), []byte(envOverride.EnvOverrideValues)) - if err != nil { - return 0, 0, "", err - } - } - - //pipeline override here comes from pipeline strategy table - if strategy != nil && len(strategy.Config) > 0 { - merged, err = impl.mergeUtil.JsonPatch(merged, []byte(strategy.Config)) - if err != nil { - return 0, 0, "", err - } - } - merged, err = impl.mergeUtil.JsonPatch(merged, dbMigrationOverride) - if err != nil { - return 0, 0, "", err - } - merged, err = impl.mergeUtil.JsonPatch(merged, []byte(overrideJson)) - if err != nil { - return 0, 0, "", err - } - - if configMapJson != nil { - merged, err = impl.mergeUtil.JsonPatch(merged, configMapJson) - if err != nil { - return 0, 0, "", err - } - } - - if appLabelJsonByte != nil { - merged, err = impl.mergeUtil.JsonPatch(merged, appLabelJsonByte) - if err != nil { - return 0, 0, "", err - } - } - - appName := fmt.Sprintf("%s-%s", pipeline.App.AppName, envOverride.Environment.Name) - merged = impl.autoscalingCheckBeforeTrigger(ctx, appName, envOverride.Namespace, merged, overrideRequest) - - _, span := otel.Tracer("orchestrator").Start(ctx, "dockerRegistryIpsConfigService.HandleImagePullSecretOnApplicationDeployment") - // handle image pull secret if access given - merged, err = impl.dockerRegistryIpsConfigService.HandleImagePullSecretOnApplicationDeployment(envOverride.Environment, artifact, pipeline.CiPipelineId, merged) - span.End() - if err != nil { - return 0, 0, "", err - } - - commitHash := "" - commitTime := time.Time{} - if util.IsAcdApp(pipeline.DeploymentAppType) { - chartRepoName := impl.chartTemplateService.GetGitOpsRepoNameFromUrl(envOverride.Chart.GitRepoUrl) - _, span = otel.Tracer("orchestrator").Start(ctx, "chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit") - //getting username & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(overrideRequest.UserId) - span.End() - chartGitAttr := &util.ChartConfig{ - FileName: fmt.Sprintf("_%d-values.yaml", envOverride.TargetEnvironment), - FileContent: string(merged), - ChartName: envOverride.Chart.ChartName, - ChartLocation: envOverride.Chart.ChartLocation, - ChartRepoName: chartRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", override.Id, envOverride.TargetEnvironment), - UserName: userName, - UserEmailId: userEmailId, - } - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return 0, 0, "", err - } - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} - _, span = otel.Tracer("orchestrator").Start(ctx, "gitFactory.Client.CommitValues") - commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) - span.End() - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return 0, 0, "", err - } - } - if commitTime.IsZero() { - commitTime = time.Now() - } - pipelineOverride := &chartConfig.PipelineOverride{ - Id: override.Id, - GitHash: commitHash, - CommitTime: commitTime, - EnvConfigOverrideId: envOverride.Id, - PipelineOverrideValues: overrideJson, - PipelineId: overrideRequest.PipelineId, - CiArtifactId: overrideRequest.CiArtifactId, - PipelineMergedValues: string(merged), - AuditLog: sql.AuditLog{UpdatedOn: triggeredAt, UpdatedBy: deployedBy}, - } - _, span = otel.Tracer("orchestrator").Start(ctx, "pipelineOverrideRepository.Update") - err = impl.pipelineOverrideRepository.Update(pipelineOverride) - span.End() - if err != nil { - return 0, 0, "", err - } - mergedValues = string(merged) - return override.PipelineReleaseCounter, override.Id, mergedValues, nil -} - func (impl *WorkflowDagExecutorImpl) mergeOverrideValues(envOverride *chartConfig.EnvConfigOverride, - dbMigrationOverride []byte, releaseOverrideJson string, configMapJson []byte, appLabelJsonByte []byte, @@ -4258,10 +4040,6 @@ func (impl *WorkflowDagExecutorImpl) mergeOverrideValues(envOverride *chartConfi return nil, err } } - merged, err = impl.mergeUtil.JsonPatch(merged, dbMigrationOverride) - if err != nil { - return nil, err - } merged, err = impl.mergeUtil.JsonPatch(merged, []byte(releaseOverrideJson)) if err != nil { return nil, err diff --git a/pkg/projectManagementService/jira/JiraAccountValidator.go b/pkg/projectManagementService/jira/JiraAccountValidator.go deleted file mode 100644 index 4ee55ac402..0000000000 --- a/pkg/projectManagementService/jira/JiraAccountValidator.go +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package jira - -import ( - "errors" - "github.com/devtron-labs/devtron/client/jira" - "go.uber.org/zap" -) - -type AccountValidator interface { - ValidateUserAccount(jiraAccountUrl string, userName string, token string) (bool, error) -} - -type AccountValidatorImpl struct { - logger *zap.SugaredLogger - jiraClient client.JiraClient -} - -func NewAccountValidatorImpl(logger *zap.SugaredLogger, jiraClient client.JiraClient) *AccountValidatorImpl { - return &AccountValidatorImpl{logger: logger, jiraClient: jiraClient} -} - -func (impl *AccountValidatorImpl) ValidateUserAccount(jiraAccountUrl string, userName string, token string) (bool, error) { - if jiraAccountUrl == "" || userName == "" || token == "" { - impl.logger.Errorw("cannot validate user account for invalid params", "jiraAccountUrl", jiraAccountUrl, "userName", userName) - return false, errors.New("cannot validate user account for invalid params") - } - - clientReq := client.CreateClientReq(userName, token, jiraAccountUrl+"/test") - resp, err := impl.jiraClient.AuthenticateUserAccount(clientReq) - - if err != nil { - return false, err - } - if resp.StatusCode == 401 { - impl.logger.Errorw("User jira could not be authenticated", "code", resp.StatusCode) - return false, nil - } - return true, nil -} diff --git a/pkg/projectManagementService/jira/JiraManagementService.go b/pkg/projectManagementService/jira/JiraManagementService.go deleted file mode 100644 index f5cc70c27f..0000000000 --- a/pkg/projectManagementService/jira/JiraManagementService.go +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package jira - -import ( - "errors" - "strings" - - client "github.com/devtron-labs/devtron/client/jira" - "github.com/devtron-labs/devtron/internal/sql/repository" - "go.uber.org/zap" -) - -type AccountService interface { - UpdateJiraStatus(UpdateRequest *UpdateRequest, finalIssueStatus string) ([]string, error) -} - -type UpdateRequest struct { - UserId int32 - UserName string - AuthToken string - AccountURL string - CommitMap map[string]string -} - -type AccountServiceImpl struct { - logger *zap.SugaredLogger - jiraAccountRepository repository.JiraAccountRepository - jiraClient client.JiraClient -} - -func NewAccountServiceImpl(logger *zap.SugaredLogger, jiraAccountRepository repository.JiraAccountRepository, jiraClient client.JiraClient) *AccountServiceImpl { - return &AccountServiceImpl{logger: logger, jiraAccountRepository: jiraAccountRepository, jiraClient: jiraClient} -} - -func (impl *AccountServiceImpl) UpdateJiraStatus(updateRequest *UpdateRequest, finalIssueStatus string) ([]string, error) { - if updateRequest == nil { - return nil, errors.New("cannot UpdateJiraStatus, invalid updateRequest") - } - // TODO: create goroutines - var errorCommits []string - for issueId, commitId := range updateRequest.CommitMap { - clientReq := client.CreateClientReq(updateRequest.UserName, updateRequest.AuthToken, updateRequest.AccountURL) - transitionResponses, err := impl.jiraClient.FindIssueTransitions(clientReq, issueId) - - if err != nil { - impl.logger.Errorw("could not find transitions for ", issueId, "err", err) - errorCommits = impl.handleJiraUpdateError(issueId, err, errorCommits, commitId) - continue - } - - id := "" - for _, jiraTransition := range transitionResponses { - if strings.EqualFold(finalIssueStatus, jiraTransition.Name) { - id = jiraTransition.Id - break - } - } - - if id == "" { - impl.logger.Errorw("no transition id not found for issue:", "issueId", issueId, "and status:", finalIssueStatus, "err", err) - errorCommits = impl.handleJiraUpdateError(issueId, err, errorCommits, commitId) - continue - } - - resp, err := impl.jiraClient.UpdateJiraTransition(clientReq, issueId, id) - if err != nil { - impl.logger.Errorw("could not update transition for ", "issueId", issueId, "err", err) - errorCommits = impl.handleJiraUpdateError(issueId, err, errorCommits, commitId) - continue - } - if resp.StatusCode != 204 { - impl.logger.Errorw("update transition jira response status ", "status", resp.Status) - errorCommits = impl.handleJiraUpdateError(issueId, err, errorCommits, commitId) - } - } - return errorCommits, nil -} - -func (impl *AccountServiceImpl) handleJiraUpdateError(issueId string, err error, errorCommits []string, commitId string) []string { - errorCommits = append(errorCommits, "could not update jira for commitId: "+commitId+" issueId: "+issueId) - return errorCommits -} diff --git a/pkg/security/ImageScanService.go b/pkg/security/ImageScanService.go index d4a8ffbf5e..e8d027e5f1 100644 --- a/pkg/security/ImageScanService.go +++ b/pkg/security/ImageScanService.go @@ -47,9 +47,9 @@ type ImageScanServiceImpl struct { scanResultRepository security.ImageScanResultRepository scanObjectMetaRepository security.ImageScanObjectMetaRepository cveStoreRepository security.CveStoreRepository - imageScanDeployInfoRepository security.ImageScanDeployInfoRepository - userService user.UserService - teamRepository repository2.TeamRepository + imageScanDeployInfoRepository security.ImageScanDeployInfoRepository + userService user.UserService + teamRepository repository2.TeamRepository appRepository repository1.AppRepository envService cluster.EnvironmentService ciArtifactRepository repository.CiArtifactRepository diff --git a/scripts/sql/210_unused_integration.up.sql b/scripts/sql/210_unused_integration.up.sql new file mode 100644 index 0000000000..df31f1b8c6 --- /dev/null +++ b/scripts/sql/210_unused_integration.up.sql @@ -0,0 +1,12 @@ +-- +-- Dropping table: project_management_tool_config; Schema: public; Owner: postgres +-- +DROP TABLE "public"."project_management_tool_config" CASCADE; +-- +-- Dropping table: db_migration_config; Schema: public; Owner: postgres +-- +DROP TABLE "public"."db_migration_config" CASCADE; +-- +-- Dropping table: db_config; Schema: public; Owner: postgres +-- +DROP TABLE "public"."db_config" CASCADE; \ No newline at end of file diff --git a/scripts/sql/210_unused_intergration.down.sql b/scripts/sql/210_unused_intergration.down.sql new file mode 100644 index 0000000000..3b4f014dc9 --- /dev/null +++ b/scripts/sql/210_unused_intergration.down.sql @@ -0,0 +1,125 @@ +CREATE TABLE public.project_management_tool_config ( + id integer NOT NULL, + user_name character varying(250) NOT NULL, + account_url character varying(250) NOT NULL, + auth_token character varying(250) NOT NULL, + commit_message_regex character varying(250) NOT NULL, + final_issue_status character varying(250) NOT NULL, + pipeline_stage character varying(250) NOT NULL, + pipeline_id integer NOT NULL, + created_on timestamp with time zone NOT NULL, + updated_on timestamp with time zone NOT NULL, + created_by integer NOT NULL, + updated_by integer NOT NULL +); + + +ALTER TABLE public.project_management_tool_config OWNER TO postgres; + +-- +-- Name: project_management_tool_config_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.project_management_tool_config_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.project_management_tool_config_id_seq OWNER TO postgres; + +-- +-- Name: project_management_tool_config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.project_management_tool_config_id_seq OWNED BY public.project_management_tool_config.id; + +-- +-- Name: db_config; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.db_config ( + id integer NOT NULL, + name character varying(250) NOT NULL, + type character varying(250) NOT NULL, + host character varying(250) NOT NULL, + port character varying(250) NOT NULL, + db_name character varying(250) NOT NULL, + user_name character varying(250) NOT NULL, + password character varying(250) NOT NULL, + active boolean NOT NULL, + created_on timestamp with time zone NOT NULL, + created_by integer NOT NULL, + updated_on timestamp with time zone NOT NULL, + updated_by integer NOT NULL +); + + +ALTER TABLE public.db_config OWNER TO postgres; + +-- +-- Name: db_config_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.db_config_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.db_config_id_seq OWNER TO postgres; + +-- +-- Name: db_config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.db_config_id_seq OWNED BY public.db_config.id; + + +-- +-- Name: db_migration_config; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.db_migration_config ( + id integer NOT NULL, + db_config_id integer NOT NULL, + pipeline_id integer NOT NULL, + git_material_id integer NOT NULL, + script_source character varying(250) NOT NULL, + migration_tool character varying(250) NOT NULL, + active boolean NOT NULL, + created_on timestamp with time zone NOT NULL, + created_by integer NOT NULL, + updated_on timestamp with time zone NOT NULL, + updated_by integer NOT NULL +); + + +ALTER TABLE public.db_migration_config OWNER TO postgres; + +-- +-- Name: db_migration_config_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.db_migration_config_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.db_migration_config_id_seq OWNER TO postgres; + +-- +-- Name: db_migration_config_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.db_migration_config_id_seq OWNED BY public.db_migration_config.id; diff --git a/wire_gen.go b/wire_gen.go index 1ec6b644e1..e871688b17 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -51,7 +51,6 @@ import ( "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/client/grafana" - client4 "github.com/devtron-labs/devtron/client/jira" "github.com/devtron-labs/devtron/client/lens" "github.com/devtron-labs/devtron/client/telemetry" "github.com/devtron-labs/devtron/internal/sql/repository" @@ -112,7 +111,6 @@ import ( repository10 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" - jira2 "github.com/devtron-labs/devtron/pkg/jira" k8s2 "github.com/devtron-labs/devtron/pkg/k8s" application2 "github.com/devtron-labs/devtron/pkg/k8s/application" "github.com/devtron-labs/devtron/pkg/k8s/capacity" @@ -131,7 +129,6 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" repository12 "github.com/devtron-labs/devtron/pkg/plugin/repository" - "github.com/devtron-labs/devtron/pkg/projectManagementService/jira" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" security2 "github.com/devtron-labs/devtron/pkg/security" @@ -179,7 +176,6 @@ func InitializeApp() (*App, error) { } ciArtifactRepositoryImpl := repository.NewCiArtifactRepositoryImpl(db, sugaredLogger) pipelineRepositoryImpl := pipelineConfig.NewPipelineRepositoryImpl(db, sugaredLogger) - dbMigrationConfigRepositoryImpl := pipelineConfig.NewDbMigrationConfigRepositoryImpl(db, sugaredLogger) httpClient := util.NewHttpClient() eventClientConfig, err := client.GetEventClientConfig() if err != nil { @@ -426,7 +422,7 @@ func InitializeApp() (*App, error) { k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) manifestPushConfigRepositoryImpl := repository11.NewManifestPushConfigRepository(sugaredLogger, db) gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, chartServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, dbMigrationConfigRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) validate, err := util.IntValidator() if err != nil { return nil, err @@ -467,7 +463,7 @@ func InitializeApp() (*App, error) { customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl) @@ -513,7 +509,6 @@ func InitializeApp() (*App, error) { appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, chartTemplateServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl) devtronAppConfigServiceImpl := pipeline.NewDevtronAppConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, appRepositoryImpl, pipelineRepositoryImpl, resourceGroupServiceImpl, enforcerUtilImpl, ciMaterialConfigServiceImpl) pipelineBuilderImpl := pipeline.NewPipelineBuilderImpl(sugaredLogger, materialRepositoryImpl, chartRepositoryImpl, ciPipelineConfigServiceImpl, ciMaterialConfigServiceImpl, appArtifactManagerImpl, devtronAppCMCSServiceImpl, devtronAppStrategyServiceImpl, appDeploymentTypeChangeManagerImpl, cdPipelineConfigServiceImpl, devtronAppConfigServiceImpl) - dbMigrationServiceImpl := pipeline.NewDbMogrationService(sugaredLogger, dbMigrationConfigRepositoryImpl) ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) ciLogServiceImpl, err := pipeline.NewCiLogServiceImpl(sugaredLogger, ciServiceImpl, k8sUtil) if err != nil { @@ -534,7 +529,7 @@ func InitializeApp() (*App, error) { imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciCdConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl) - pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl) + pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl) appWorkflowRestHandlerImpl := restHandler.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) webhookEventDataRepositoryImpl := repository.NewWebhookEventDataRepositoryImpl(db) webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) @@ -543,10 +538,6 @@ func InitializeApp() (*App, error) { pipelineHistoryRestHandlerImpl := restHandler.NewPipelineHistoryRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, pipelineStrategyHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, prePostCdScriptHistoryServiceImpl, enforcerUtilImpl, deployedConfigurationHistoryServiceImpl) pipelineStatusTimelineRestHandlerImpl := restHandler.NewPipelineStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) pipelineConfigRouterImpl := router.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, appWorkflowRestHandlerImpl, webhookDataRestHandlerImpl, pipelineHistoryRestHandlerImpl, pipelineStatusTimelineRestHandlerImpl) - dbConfigRepositoryImpl := repository.NewDbConfigRepositoryImpl(db, sugaredLogger) - dbConfigServiceImpl := pipeline.NewDbConfigService(dbConfigRepositoryImpl, sugaredLogger) - migrateDbRestHandlerImpl := restHandler.NewMigrateDbRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, dbConfigServiceImpl, userServiceImpl, validate, dbMigrationServiceImpl, enforcerImpl) - migrateDbRouterImpl := router.NewMigrateDbRouterImpl(migrateDbRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) k8sResourceHistoryRepositoryImpl := repository14.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) @@ -607,15 +598,8 @@ func InitializeApp() (*App, error) { resourceServiceImpl := ArgoUtil.NewResourceServiceImpl(argoSession) cdRestHandlerImpl := restHandler.NewCDRestHandlerImpl(sugaredLogger, resourceServiceImpl) cdRouterImpl := router.NewCDRouterImpl(sugaredLogger, cdRestHandlerImpl) - jiraAccountRepositoryImpl := repository.NewJiraAccountRepositoryImpl(db) - jiraClientImpl := client4.NewJiraClientImpl(sugaredLogger, httpClient) - accountServiceImpl := jira.NewAccountServiceImpl(sugaredLogger, jiraAccountRepositoryImpl, jiraClientImpl) - accountValidatorImpl := jira.NewAccountValidatorImpl(sugaredLogger, jiraClientImpl) - projectManagementServiceImpl := jira2.NewProjectManagementServiceImpl(sugaredLogger, accountServiceImpl, jiraAccountRepositoryImpl, accountValidatorImpl) - jiraRestHandlerImpl := restHandler.NewJiraRestHandlerImpl(projectManagementServiceImpl, sugaredLogger, userServiceImpl, validate) - projectManagementRouterImpl := router.NewProjectManagementRouterImpl(jiraRestHandlerImpl) deleteServiceFullModeImpl := delete2.NewDeleteServiceFullModeImpl(sugaredLogger, materialRepositoryImpl, gitRegistryConfigImpl, ciTemplateRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) - gitProviderRestHandlerImpl := restHandler.NewGitProviderRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, dbConfigServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, deleteServiceFullModeImpl) + gitProviderRestHandlerImpl := restHandler.NewGitProviderRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, deleteServiceFullModeImpl) gitProviderRouterImpl := router.NewGitProviderRouterImpl(gitProviderRestHandlerImpl) gitHostRepositoryImpl := repository.NewGitHostRepositoryImpl(db) gitHostConfigImpl := pipeline.NewGitHostConfigImpl(gitHostRepositoryImpl, sugaredLogger, attributesServiceImpl) @@ -635,7 +619,7 @@ func InitializeApp() (*App, error) { webhookNotificationServiceImpl := notifier.NewWebhookNotificationServiceImpl(sugaredLogger, webhookNotificationRepositoryImpl, teamServiceImpl, userRepositoryImpl, notificationSettingsRepositoryImpl) sesNotificationServiceImpl := notifier.NewSESNotificationServiceImpl(sugaredLogger, sesNotificationRepositoryImpl, teamServiceImpl, notificationSettingsRepositoryImpl) smtpNotificationServiceImpl := notifier.NewSMTPNotificationServiceImpl(sugaredLogger, smtpNotificationRepositoryImpl, teamServiceImpl, notificationSettingsRepositoryImpl) - notificationRestHandlerImpl := restHandler.NewNotificationRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, dbConfigServiceImpl, userServiceImpl, validate, notificationConfigServiceImpl, slackNotificationServiceImpl, webhookNotificationServiceImpl, sesNotificationServiceImpl, smtpNotificationServiceImpl, enforcerImpl, teamServiceImpl, environmentServiceImpl, pipelineBuilderImpl, enforcerUtilImpl) + notificationRestHandlerImpl := restHandler.NewNotificationRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, userServiceImpl, validate, notificationConfigServiceImpl, slackNotificationServiceImpl, webhookNotificationServiceImpl, sesNotificationServiceImpl, smtpNotificationServiceImpl, enforcerImpl, teamServiceImpl, environmentServiceImpl, pipelineBuilderImpl, enforcerUtilImpl) notificationRouterImpl := router.NewNotificationRouterImpl(notificationRestHandlerImpl) teamRestHandlerImpl := team2.NewTeamRestHandlerImpl(sugaredLogger, teamServiceImpl, userServiceImpl, enforcerImpl, validate, userAuthServiceImpl, deleteServiceExtendedImpl) teamRouterImpl := team2.NewTeamRouterImpl(teamRestHandlerImpl) @@ -688,8 +672,6 @@ func InitializeApp() (*App, error) { chartGroupServiceImpl := service.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) chartGroupRestHandlerImpl := restHandler.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) chartGroupRouterImpl := router.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) - testSuitRestHandlerImpl := restHandler.NewTestSuitRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerImpl, enforcerUtilImpl, eventClientConfig, httpClient) - testSuitRouterImpl := router.NewTestSuitRouterImpl(testSuitRestHandlerImpl) scanToolExecutionHistoryMappingRepositoryImpl := security.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) imageScanServiceImpl := security2.NewImageScanServiceImpl(sugaredLogger, imageScanHistoryRepositoryImpl, imageScanResultRepositoryImpl, imageScanObjectMetaRepositoryImpl, cveStoreRepositoryImpl, imageScanDeployInfoRepositoryImpl, userServiceImpl, teamRepositoryImpl, appRepositoryImpl, environmentServiceImpl, ciArtifactRepositoryImpl, policyServiceImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, scanToolMetadataRepositoryImpl, scanToolExecutionHistoryMappingRepositoryImpl) imageScanRestHandlerImpl := restHandler.NewImageScanRestHandlerImpl(sugaredLogger, imageScanServiceImpl, userServiceImpl, enforcerImpl, enforcerUtilImpl, environmentServiceImpl) @@ -736,7 +718,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - bulkUpdateRestHandlerImpl := restHandler.NewBulkUpdateRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, bulkUpdateServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, argoUserServiceImpl) + bulkUpdateRestHandlerImpl := restHandler.NewBulkUpdateRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, bulkUpdateServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, argoUserServiceImpl) bulkUpdateRouterImpl := router.NewBulkUpdateRouterImpl(bulkUpdateRestHandlerImpl) webhookSecretValidatorImpl := git.NewWebhookSecretValidatorImpl(sugaredLogger) webhookEventHandlerImpl := restHandler.NewWebhookEventHandlerImpl(sugaredLogger, gitHostConfigImpl, eventRESTClientImpl, webhookSecretValidatorImpl, webhookEventDataConfigImpl) @@ -820,7 +802,7 @@ func InitializeApp() (*App, error) { return nil, err } ciTriggerCronImpl := cron.NewCiTriggerCronImpl(sugaredLogger, ciTriggerCronConfig, pipelineStageRepositoryImpl, ciHandlerImpl, ciArtifactRepositoryImpl, globalPluginRepositoryImpl) - muxRouter := router.NewMuxRouter(sugaredLogger, pipelineTriggerRouterImpl, pipelineConfigRouterImpl, migrateDbRouterImpl, appListingRouterImpl, environmentRouterImpl, clusterRouterImpl, webhookRouterImpl, userAuthRouterImpl, applicationRouterImpl, cdRouterImpl, projectManagementRouterImpl, gitProviderRouterImpl, gitHostRouterImpl, dockerRegRouterImpl, notificationRouterImpl, teamRouterImpl, gitWebhookHandlerImpl, workflowStatusUpdateHandlerImpl, applicationStatusHandlerImpl, ciEventHandlerImpl, pubSubClientServiceImpl, userRouterImpl, chartRefRouterImpl, configMapRouterImpl, appStoreRouterImpl, chartRepositoryRouterImpl, releaseMetricsRouterImpl, deploymentGroupRouterImpl, batchOperationRouterImpl, chartGroupRouterImpl, testSuitRouterImpl, imageScanRouterImpl, policyRouterImpl, gitOpsConfigRouterImpl, dashboardRouterImpl, attributesRouterImpl, userAttributesRouterImpl, commonRouterImpl, grafanaRouterImpl, ssoLoginRouterImpl, telemetryRouterImpl, telemetryEventClientImplExtended, bulkUpdateRouterImpl, webhookListenerRouterImpl, appRouterImpl, coreAppRouterImpl, helmAppRouterImpl, k8sApplicationRouterImpl, pProfRouterImpl, deploymentConfigRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, globalPluginRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, cdApplicationStatusUpdateHandlerImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, globalCMCSRouterImpl, userTerminalAccessRouterImpl, jobRouterImpl, ciStatusUpdateCronImpl, resourceGroupingRouterImpl, rbacRoleRouterImpl, scopedVariableRouterImpl, ciTriggerCronImpl) + muxRouter := router.NewMuxRouter(sugaredLogger, pipelineTriggerRouterImpl, pipelineConfigRouterImpl, appListingRouterImpl, environmentRouterImpl, clusterRouterImpl, webhookRouterImpl, userAuthRouterImpl, applicationRouterImpl, cdRouterImpl, gitProviderRouterImpl, gitHostRouterImpl, dockerRegRouterImpl, notificationRouterImpl, teamRouterImpl, gitWebhookHandlerImpl, workflowStatusUpdateHandlerImpl, applicationStatusHandlerImpl, ciEventHandlerImpl, pubSubClientServiceImpl, userRouterImpl, chartRefRouterImpl, configMapRouterImpl, appStoreRouterImpl, chartRepositoryRouterImpl, releaseMetricsRouterImpl, deploymentGroupRouterImpl, batchOperationRouterImpl, chartGroupRouterImpl, imageScanRouterImpl, policyRouterImpl, gitOpsConfigRouterImpl, dashboardRouterImpl, attributesRouterImpl, userAttributesRouterImpl, commonRouterImpl, grafanaRouterImpl, ssoLoginRouterImpl, telemetryRouterImpl, telemetryEventClientImplExtended, bulkUpdateRouterImpl, webhookListenerRouterImpl, appRouterImpl, coreAppRouterImpl, helmAppRouterImpl, k8sApplicationRouterImpl, pProfRouterImpl, deploymentConfigRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, globalPluginRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, cdApplicationStatusUpdateHandlerImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, globalCMCSRouterImpl, userTerminalAccessRouterImpl, jobRouterImpl, ciStatusUpdateCronImpl, resourceGroupingRouterImpl, rbacRoleRouterImpl, scopedVariableRouterImpl, ciTriggerCronImpl) loggingMiddlewareImpl := util4.NewLoggingMiddlewareImpl(userServiceImpl) mainApp := NewApp(muxRouter, sugaredLogger, sseSSE, syncedEnforcer, db, pubSubClientServiceImpl, sessionManager, posthogClient, loggingMiddlewareImpl) return mainApp, nil From 28b07fd7acfcc20184a45e0ca818a0bb24c73dac Mon Sep 17 00:00:00 2001 From: Nishant <58689354+nishant-d@users.noreply.github.com> Date: Mon, 15 Jan 2024 17:01:16 +0530 Subject: [PATCH 05/83] chore: App store dead code cleanup and restructuring (#4497) * moved chart-group in seperate code * removed unused dependency * removed dead code * extracted resource tree * moved notes * resource movement * removed unused code * removed unused dependency * commit methods * extracted status update * chore: clean up unused dead code * updated: EA mode docker file * updated: migration number --------- Co-authored-by: Ash-exp --- DockerfileEA | 2 +- Wire.go | 9 +- api/appStore/InstalledAppRestHandler.go | 3 +- api/restHandler/ChartGroupRestHandler.go | 16 +- cmd/external-app/wire.go | 5 +- cmd/external-app/wire_gen.go | 7 +- pkg/appStore/bean/bean.go | 21 - .../ChartGroupService.go | 29 +- pkg/appStore/chartGroup/bean.go | 23 + .../repository/ChartGroup.go | 0 .../repository/ChartGroupDeployment.go | 0 .../repository/ChartGroupEntry.go | 0 .../AppStoreDeploymentFullModeService.go | 284 ++-------- .../service/AppStoreDeploymentService.go | 13 +- .../service/AppStoreDeploymentService_test.go | 3 +- .../deployment/service/InstalledAppService.go | 492 +----------------- .../service/InstalledAppService_test.go | 3 +- pkg/appStore/deployment/service/Notes.go | 118 +++++ .../deployment/service/ResourceTree.go | 334 ++++++++++++ .../AppStoreDeploymentArgoCdService.go | 295 +---------- .../tool/AppStoreDeploymentHelmService.go | 113 +--- .../tool/DeploymentStatusService.go | 122 +++++ ...n.up.sql => 211_unused_integration.up.sql} | 0 ...n.sql => 211_unused_intergration.down.sql} | 0 wire_gen.go | 39 +- 25 files changed, 732 insertions(+), 1199 deletions(-) rename pkg/appStore/{deployment/service => chartGroup}/ChartGroupService.go (95%) create mode 100644 pkg/appStore/chartGroup/bean.go rename pkg/appStore/{deployment => chartGroup}/repository/ChartGroup.go (100%) rename pkg/appStore/{deployment => chartGroup}/repository/ChartGroupDeployment.go (100%) rename pkg/appStore/{deployment => chartGroup}/repository/ChartGroupEntry.go (100%) create mode 100644 pkg/appStore/deployment/service/Notes.go create mode 100644 pkg/appStore/deployment/service/ResourceTree.go rename pkg/appStore/deployment/tool/{gitops => }/AppStoreDeploymentArgoCdService.go (66%) create mode 100644 pkg/appStore/deployment/tool/DeploymentStatusService.go rename scripts/sql/{210_unused_integration.up.sql => 211_unused_integration.up.sql} (100%) rename scripts/sql/{210_unused_intergration.down.sql => 211_unused_intergration.down.sql} (100%) diff --git a/DockerfileEA b/DockerfileEA index 0fbc7b85ec..74827c1e35 100644 --- a/DockerfileEA +++ b/DockerfileEA @@ -21,7 +21,7 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/sql scripts/sql COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/casbin scripts/casbin -COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON +COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.tmpl scripts/argo-assets/APPLICATION_TEMPLATE.tmpl RUN useradd -ms /bin/bash devtron RUN chown -R devtron:devtron ./devtron-ea diff --git a/Wire.go b/Wire.go index 69890f5668..caeb9157b9 100644 --- a/Wire.go +++ b/Wire.go @@ -85,10 +85,11 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone/batch" "github.com/devtron-labs/devtron/pkg/appStatus" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" + appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bulkAction" @@ -588,8 +589,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(repository4.ChartGroupReposotory), new(*repository4.ChartGroupReposotoryImpl)), repository4.NewChartGroupEntriesRepositoryImpl, wire.Bind(new(repository4.ChartGroupEntriesRepository), new(*repository4.ChartGroupEntriesRepositoryImpl)), - service.NewChartGroupServiceImpl, - wire.Bind(new(service.ChartGroupService), new(*service.ChartGroupServiceImpl)), + chartGroup.NewChartGroupServiceImpl, + wire.Bind(new(chartGroup.ChartGroupService), new(*chartGroup.ChartGroupServiceImpl)), restHandler.NewChartGroupRestHandlerImpl, wire.Bind(new(restHandler.ChartGroupRestHandler), new(*restHandler.ChartGroupRestHandlerImpl)), router.NewChartGroupRouterImpl, diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index b44f3e9056..c6e1427c8d 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -38,6 +38,7 @@ import ( util2 "github.com/devtron-labs/devtron/internal/util" app2 "github.com/devtron-labs/devtron/pkg/app" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" @@ -325,7 +326,7 @@ func (handler *InstalledAppRestHandlerImpl) DeployBulk(w http.ResponseWriter, r return } decoder := json.NewDecoder(r.Body) - var request appStoreBean.ChartGroupInstallRequest + var request chartGroup.ChartGroupInstallRequest err = decoder.Decode(&request) if err != nil { handler.Logger.Errorw("request err, DeployBulk", "err", err, "payload", request) diff --git a/api/restHandler/ChartGroupRestHandler.go b/api/restHandler/ChartGroupRestHandler.go index 9a0b2dc03e..0e496bea65 100644 --- a/api/restHandler/ChartGroupRestHandler.go +++ b/api/restHandler/ChartGroupRestHandler.go @@ -24,7 +24,7 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/gorilla/mux" @@ -35,14 +35,14 @@ import ( const CHART_GROUP_DELETE_SUCCESS_RESP = "Chart group deleted successfully." type ChartGroupRestHandlerImpl struct { - ChartGroupService service.ChartGroupService + ChartGroupService chartGroup.ChartGroupService Logger *zap.SugaredLogger userAuthService user.UserService enforcer casbin.Enforcer validator *validator.Validate } -func NewChartGroupRestHandlerImpl(ChartGroupService service.ChartGroupService, +func NewChartGroupRestHandlerImpl(ChartGroupService chartGroup.ChartGroupService, Logger *zap.SugaredLogger, userAuthService user.UserService, enforcer casbin.Enforcer, validator *validator.Validate) *ChartGroupRestHandlerImpl { return &ChartGroupRestHandlerImpl{ @@ -72,7 +72,7 @@ func (impl *ChartGroupRestHandlerImpl) CreateChartGroup(w http.ResponseWriter, r return } decoder := json.NewDecoder(r.Body) - var request service.ChartGroupBean + var request chartGroup.ChartGroupBean err = decoder.Decode(&request) if err != nil { impl.Logger.Errorw("request err, CreateChartGroup", "err", err, "payload", request) @@ -101,7 +101,7 @@ func (impl *ChartGroupRestHandlerImpl) CreateChartGroup(w http.ResponseWriter, r if err != nil { impl.Logger.Errorw("service err, CreateChartGroup", "err", err, "payload", request) statusCode := http.StatusInternalServerError - if service.AppNameAlreadyExistsError == err.Error() { + if chartGroup.AppNameAlreadyExistsError == err.Error() { statusCode = http.StatusBadRequest } common.WriteJsonResp(w, err, nil, statusCode) @@ -117,7 +117,7 @@ func (impl *ChartGroupRestHandlerImpl) UpdateChartGroup(w http.ResponseWriter, r return } decoder := json.NewDecoder(r.Body) - var request service.ChartGroupBean + var request chartGroup.ChartGroupBean err = decoder.Decode(&request) if err != nil { impl.Logger.Errorw("request err, UpdateChartGroup", "err", err, "payload", request) @@ -158,7 +158,7 @@ func (impl *ChartGroupRestHandlerImpl) SaveChartGroupEntries(w http.ResponseWrit return } decoder := json.NewDecoder(r.Body) - var request service.ChartGroupBean + var request chartGroup.ChartGroupBean err = decoder.Decode(&request) if err != nil { impl.Logger.Errorw("request err, SaveChartGroupEntries", "err", err, "payload", request) @@ -326,7 +326,7 @@ func (impl *ChartGroupRestHandlerImpl) DeleteChartGroup(w http.ResponseWriter, r return } decoder := json.NewDecoder(r.Body) - var request service.ChartGroupBean + var request chartGroup.ChartGroupBean err = decoder.Decode(&request) if err != nil { impl.Logger.Errorw("request err, DeleteChartGroup", "err", err, "payload", request) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 044f9c0d98..e03344eaff 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -39,9 +39,8 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository3 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" "github.com/devtron-labs/devtron/pkg/attributes" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" delete2 "github.com/devtron-labs/devtron/pkg/delete" @@ -138,7 +137,7 @@ func InitializeApp() (*App, error) { // // needed for enforcer util ends // binding gitops to helm (for hyperion) - wire.Bind(new(appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentTool.AppStoreDeploymentHelmServiceImpl)), + wire.Bind(new(appStoreDeploymentTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentTool.AppStoreDeploymentHelmServiceImpl)), wire.Value(chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts")), diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index c95ee93e35..9e3eb8ea36 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -46,6 +46,7 @@ import ( "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository8 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" @@ -274,9 +275,9 @@ func InitializeApp() (*App, error) { appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) - chartGroupDeploymentRepositoryImpl := repository4.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + chartGroupDeploymentRepositoryImpl := repository8.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) deploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() if err != nil { @@ -286,7 +287,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 19dde14013..373cc85deb 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -126,27 +126,6 @@ type InstallAppVersionChartRepoDTO struct { Password string `json:"-"` } -// / bean for v2 -type ChartGroupInstallRequest struct { - ProjectId int `json:"projectId" validate:"required,number"` - ChartGroupInstallChartRequest []*ChartGroupInstallChartRequest `json:"charts" validate:"dive,required"` - ChartGroupId int `json:"chartGroupId"` //optional - UserId int32 `json:"-"` -} - -type ChartGroupInstallChartRequest struct { - AppName string `json:"appName,omitempty" validate:"name-component,max=100" ` - EnvironmentId int `json:"environmentId,omitempty" validate:"required,number" ` - AppStoreVersion int `json:"appStoreVersion,omitempty,notnull" validate:"required,number" ` - ValuesOverrideYaml string `json:"valuesOverrideYaml,omitempty"` //optional - ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` - ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED"` - ChartGroupEntryId int `json:"chartGroupEntryId"` //optional - DefaultClusterComponent bool `json:"-"` -} -type ChartGroupInstallAppRes struct { -} - // / type RefChartProxyDir string diff --git a/pkg/appStore/deployment/service/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go similarity index 95% rename from pkg/appStore/deployment/service/ChartGroupService.go rename to pkg/appStore/chartGroup/ChartGroupService.go index 02e396c19a..7036d946a5 100644 --- a/pkg/appStore/deployment/service/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -15,13 +15,14 @@ * */ -package service +package chartGroup import ( "errors" "time" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreValuesRepository "github.com/devtron-labs/devtron/pkg/appStore/values/repository" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -32,18 +33,18 @@ import ( ) type ChartGroupServiceImpl struct { - chartGroupEntriesRepository repository.ChartGroupEntriesRepository - chartGroupRepository repository.ChartGroupReposotory + chartGroupEntriesRepository repository2.ChartGroupEntriesRepository + chartGroupRepository repository2.ChartGroupReposotory Logger *zap.SugaredLogger - chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository + chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository installedAppRepository repository.InstalledAppRepository appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository userAuthService user.UserAuthService } -func NewChartGroupServiceImpl(chartGroupEntriesRepository repository.ChartGroupEntriesRepository, - chartGroupRepository repository.ChartGroupReposotory, - Logger *zap.SugaredLogger, chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository, +func NewChartGroupServiceImpl(chartGroupEntriesRepository repository2.ChartGroupEntriesRepository, + chartGroupRepository repository2.ChartGroupReposotory, + Logger *zap.SugaredLogger, chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, installedAppRepository repository.InstalledAppRepository, appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository, userAuthService user.UserAuthService) *ChartGroupServiceImpl { return &ChartGroupServiceImpl{ chartGroupEntriesRepository: chartGroupEntriesRepository, @@ -125,7 +126,7 @@ func (impl *ChartGroupServiceImpl) CreateChartGroup(req *ChartGroupBean) (*Chart return nil, errors.New(AppNameAlreadyExistsError) } - chartGrouModel := &repository.ChartGroup{ + chartGrouModel := &repository2.ChartGroup{ Name: req.Name, Description: req.Description, AuditLog: sql.AuditLog{ @@ -146,7 +147,7 @@ func (impl *ChartGroupServiceImpl) CreateChartGroup(req *ChartGroupBean) (*Chart func (impl *ChartGroupServiceImpl) UpdateChartGroup(req *ChartGroupBean) (*ChartGroupBean, error) { impl.Logger.Debugw("chart group update request", "req", req) - chartGrouModel := &repository.ChartGroup{ + chartGrouModel := &repository2.ChartGroup{ Name: req.Name, Description: req.Description, Id: req.Id, @@ -182,7 +183,7 @@ func (impl *ChartGroupServiceImpl) SaveChartGroupEntries(req *ChartGroupBean) (* newEntries = append(newEntries, entryBean) } } - var updateEntries []*repository.ChartGroupEntry + var updateEntries []*repository2.ChartGroupEntry for _, existingEntry := range group.ChartGroupEntries { if entry, ok := oldEntriesMap[existingEntry.Id]; ok { //update @@ -197,9 +198,9 @@ func (impl *ChartGroupServiceImpl) SaveChartGroupEntries(req *ChartGroupBean) (* updateEntries = append(updateEntries, existingEntry) } - var createEntries []*repository.ChartGroupEntry + var createEntries []*repository2.ChartGroupEntry for _, entryBean := range newEntries { - entry := &repository.ChartGroupEntry{ + entry := &repository2.ChartGroupEntry{ AppStoreValuesVersionId: entryBean.AppStoreValuesVersionId, AppStoreApplicationVersionId: entryBean.AppStoreApplicationVersionId, ChartGroupId: group.Id, @@ -243,7 +244,7 @@ func (impl *ChartGroupServiceImpl) GetChartGroupWithChartMetaData(chartGroupId i return chartGroupRes, err } -func (impl *ChartGroupServiceImpl) charterEntryAdopter(chartGroupEntry *repository.ChartGroupEntry) *ChartGroupEntryBean { +func (impl *ChartGroupServiceImpl) charterEntryAdopter(chartGroupEntry *repository2.ChartGroupEntry) *ChartGroupEntryBean { var referenceType string var valueVersionName string @@ -342,7 +343,7 @@ func (impl *ChartGroupServiceImpl) GetChartGroupWithInstallationDetail(chartGrou impl.Logger.Errorw("error in finding deployment", "chartGroupId", chartGroupId, "err", err) return nil, err } - groupDeploymentMap := make(map[string][]*repository.ChartGroupDeployment) + groupDeploymentMap := make(map[string][]*repository2.ChartGroupDeployment) for _, deployment := range deployments { groupDeploymentMap[deployment.GroupInstallationId] = append(groupDeploymentMap[deployment.GroupInstallationId], deployment) } diff --git a/pkg/appStore/chartGroup/bean.go b/pkg/appStore/chartGroup/bean.go new file mode 100644 index 0000000000..c385e358da --- /dev/null +++ b/pkg/appStore/chartGroup/bean.go @@ -0,0 +1,23 @@ +package chartGroup + +// / bean for v2 +type ChartGroupInstallRequest struct { + ProjectId int `json:"projectId" validate:"required,number"` + ChartGroupInstallChartRequest []*ChartGroupInstallChartRequest `json:"charts" validate:"dive,required"` + ChartGroupId int `json:"chartGroupId"` //optional + UserId int32 `json:"-"` +} + +type ChartGroupInstallChartRequest struct { + AppName string `json:"appName,omitempty" validate:"name-component,max=100" ` + EnvironmentId int `json:"environmentId,omitempty" validate:"required,number" ` + AppStoreVersion int `json:"appStoreVersion,omitempty,notnull" validate:"required,number" ` + ValuesOverrideYaml string `json:"valuesOverrideYaml,omitempty"` //optional + ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` + ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED"` + ChartGroupEntryId int `json:"chartGroupEntryId"` //optional + DefaultClusterComponent bool `json:"-"` +} + +type ChartGroupInstallAppRes struct { +} diff --git a/pkg/appStore/deployment/repository/ChartGroup.go b/pkg/appStore/chartGroup/repository/ChartGroup.go similarity index 100% rename from pkg/appStore/deployment/repository/ChartGroup.go rename to pkg/appStore/chartGroup/repository/ChartGroup.go diff --git a/pkg/appStore/deployment/repository/ChartGroupDeployment.go b/pkg/appStore/chartGroup/repository/ChartGroupDeployment.go similarity index 100% rename from pkg/appStore/deployment/repository/ChartGroupDeployment.go rename to pkg/appStore/chartGroup/repository/ChartGroupDeployment.go diff --git a/pkg/appStore/deployment/repository/ChartGroupEntry.go b/pkg/appStore/chartGroup/repository/ChartGroupEntry.go similarity index 100% rename from pkg/appStore/deployment/repository/ChartGroupEntry.go rename to pkg/appStore/chartGroup/repository/ChartGroupEntry.go diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 0899e6d7d0..fd28cedde9 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -24,13 +24,9 @@ import ( "fmt" "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" - "path" - "regexp" "time" - "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/argocdServer" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app/status" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" @@ -40,7 +36,6 @@ import ( repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/pkg/util" - util3 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" "github.com/go-pg/pg" @@ -51,9 +46,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/util" "go.uber.org/zap" - "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/proto/hapi/chart" - "sigs.k8s.io/yaml" ) const ( @@ -61,52 +53,39 @@ const ( CLUSTER_COMPONENT_DIR_PATH = "/cluster/component" ) +// ACD operation and git operation type AppStoreDeploymentFullModeService interface { - AppStoreDeployOperationGIT(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, *util.ChartGitAttribute, error) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + //TRACE usages and delete if unused RegisterInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context) error - SyncACD(acdAppName string, ctx context.Context) UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error GetGitOpsRepoName(appName string, environmentName string) (string, error) - SubscribeHelmInstallStatus() error } type AppStoreDeploymentFullModeServiceImpl struct { - logger *zap.SugaredLogger - chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir - repositoryService repository.ServiceClient - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository5.EnvironmentRepository - acdClient application2.ServiceClient - ArgoK8sClient argocdServer.ArgoK8sClient - gitFactory *util.GitFactory - aCDAuthConfig *util2.ACDAuthConfig - globalEnvVariables *util3.GlobalEnvVariables - installedAppRepository repository4.InstalledAppRepository - tokenCache *util2.TokenCache - argoUserService argo.ArgoUserService - gitOpsConfigRepository repository3.GitOpsConfigRepository - pipelineStatusTimelineService status.PipelineStatusTimelineService - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - argoClientWrapperService argocdServer.ArgoClientWrapperService - pubSubClient *pubsub_lib.PubSubClientServiceImpl - installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository - ACDConfig *argocdServer.ACDConfig + logger *zap.SugaredLogger + chartTemplateService util.ChartTemplateService + repositoryService repository.ServiceClient + acdClient application2.ServiceClient + ArgoK8sClient argocdServer.ArgoK8sClient + aCDAuthConfig *util2.ACDAuthConfig + argoUserService argo.ArgoUserService + pipelineStatusTimelineService status.PipelineStatusTimelineService + appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService + argoClientWrapperService argocdServer.ArgoClientWrapperService + pubSubClient *pubsub_lib.PubSubClientServiceImpl + installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository + ACDConfig *argocdServer.ACDConfig } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, - chartTemplateService util.ChartTemplateService, refChartDir appStoreBean.RefChartProxyDir, + chartTemplateService util.ChartTemplateService, repositoryService repository.ServiceClient, - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository repository5.EnvironmentRepository, acdClient application2.ServiceClient, argoK8sClient argocdServer.ArgoK8sClient, - gitFactory *util.GitFactory, aCDAuthConfig *util2.ACDAuthConfig, - globalEnvVariables *util3.GlobalEnvVariables, - installedAppRepository repository4.InstalledAppRepository, tokenCache *util2.TokenCache, - argoUserService argo.ArgoUserService, gitOpsConfigRepository repository3.GitOpsConfigRepository, + aCDAuthConfig *util2.ACDAuthConfig, + argoUserService argo.ArgoUserService, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, argoClientWrapperService argocdServer.ArgoClientWrapperService, @@ -115,210 +94,27 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, ACDConfig *argocdServer.ACDConfig, ) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ - logger: logger, - chartTemplateService: chartTemplateService, - refChartDir: refChartDir, - repositoryService: repositoryService, - appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, - acdClient: acdClient, - ArgoK8sClient: argoK8sClient, - gitFactory: gitFactory, - aCDAuthConfig: aCDAuthConfig, - globalEnvVariables: globalEnvVariables, - installedAppRepository: installedAppRepository, - tokenCache: tokenCache, - argoUserService: argoUserService, - gitOpsConfigRepository: gitOpsConfigRepository, - pipelineStatusTimelineService: pipelineStatusTimelineService, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, - argoClientWrapperService: argoClientWrapperService, - pubSubClient: pubSubClient, - installedAppRepositoryHistory: installedAppRepositoryHistory, - ACDConfig: ACDConfig, - } - err := appStoreDeploymentFullModeServiceImpl.SubscribeHelmInstallStatus() + logger: logger, + chartTemplateService: chartTemplateService, + repositoryService: repositoryService, + acdClient: acdClient, + ArgoK8sClient: argoK8sClient, + aCDAuthConfig: aCDAuthConfig, + argoUserService: argoUserService, + pipelineStatusTimelineService: pipelineStatusTimelineService, + appStoreDeploymentCommonService: appStoreDeploymentCommonService, + argoClientWrapperService: argoClientWrapperService, + pubSubClient: pubSubClient, + installedAppRepositoryHistory: installedAppRepositoryHistory, + ACDConfig: ACDConfig, + } + err := appStoreDeploymentFullModeServiceImpl.subscribeHelmInstallStatus() if err != nil { return nil } return appStoreDeploymentFullModeServiceImpl } -func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationGIT(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, *util.ChartGitAttribute, error) { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installAppVersionRequest, nil, err - } - - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installAppVersionRequest, nil, err - } - - //STEP 1: Commit and PUSH on Gitlab - template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(string(impl.refChartDir), template) - valid, err := chartutil.IsChartDir(chartPath) - if err != nil || !valid { - impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) - return installAppVersionRequest, nil, err - } - chartMeta := &chart.Metadata{ - Name: installAppVersionRequest.AppName, - Version: "1.0.1", - } - _, chartGitAttr, err := impl.chartTemplateService.CreateChartProxy(chartMeta, chartPath, environment.Name, installAppVersionRequest) - if err != nil { - return installAppVersionRequest, nil, err - } - - //STEP 3 - update requirements and values - argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name - dependency := appStoreBean.Dependency{ - Name: appStoreAppVersion.AppStore.Name, - Version: appStoreAppVersion.Version, - } - if appStoreAppVersion.AppStore.ChartRepo != nil { - dependency.Repository = appStoreAppVersion.AppStore.ChartRepo.Url - } - var dependencies []appStoreBean.Dependency - dependencies = append(dependencies, dependency) - requirementDependencies := &appStoreBean.Dependencies{ - Dependencies: dependencies, - } - requirementDependenciesByte, err := json.Marshal(requirementDependencies) - if err != nil { - return installAppVersionRequest, nil, err - } - requirementDependenciesByte, err = yaml.JSONToYAML(requirementDependenciesByte) - if err != nil { - return installAppVersionRequest, nil, err - } - - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) - //getting username & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return installAppVersionRequest, nil, err - } - } - requirmentYamlConfig := &util.ChartConfig{ - FileName: appStoreBean.REQUIREMENTS_YAML_FILE, - FileContent: string(requirementDependenciesByte), - ChartName: chartMeta.Name, - ChartLocation: argocdAppName, - ChartRepoName: gitOpsRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), - UserEmailId: userEmailId, - UserName: userName, - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} - _, _, err = impl.gitFactory.Client.CommitValues(requirmentYamlConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return installAppVersionRequest, nil, err - } - - //GIT PULL - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(chartMeta.Name, "-") - clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttr.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return installAppVersionRequest, nil, err - } - - //update values yaml in chart - ValuesOverrideByte, err := yaml.YAMLToJSON([]byte(installAppVersionRequest.ValuesOverrideYaml)) - if err != nil { - impl.logger.Errorw("error in json patch", "err", err) - return installAppVersionRequest, nil, err - } - - var dat map[string]interface{} - err = json.Unmarshal(ValuesOverrideByte, &dat) - - valuesMap := make(map[string]map[string]interface{}) - valuesMap[appStoreAppVersion.AppStore.Name] = dat - valuesByte, err := json.Marshal(valuesMap) - if err != nil { - impl.logger.Errorw("error in marshaling", "err", err) - return installAppVersionRequest, nil, err - } - - valuesYamlConfig := &util.ChartConfig{ - FileName: appStoreBean.VALUES_YAML_FILE, - FileContent: string(valuesByte), - ChartName: chartMeta.Name, - ChartLocation: argocdAppName, - ChartRepoName: gitOpsRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), - UserEmailId: userEmailId, - UserName: userName, - } - - commitHash, _, err := impl.gitFactory.Client.CommitValues(valuesYamlConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - //update timeline status for git commit failed state - gitCommitStatus := pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED - gitCommitStatusDetail := fmt.Sprintf("Git commit failed - %v", err) - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: gitCommitStatus, - StatusDetail: gitCommitStatusDetail, - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - timelineErr := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if timelineErr != nil { - impl.logger.Errorw("error in creating timeline status for git commit", "err", timelineErr, "timeline", timeline) - } - return installAppVersionRequest, nil, err - } - //creating timeline for Git Commit stage - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, - StatusDetail: "Git commit done successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if err != nil { - impl.logger.Errorw("error in creating timeline status for git commit", "err", err, "timeline", timeline) - } - - //sync local dir with remote - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttr.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return installAppVersionRequest, nil, err - } - installAppVersionRequest.GitHash = commitHash - installAppVersionRequest.ACDAppName = argocdAppName - installAppVersionRequest.Environment = environment - - return installAppVersionRequest, chartGitAttr, nil -} - func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() @@ -378,18 +174,6 @@ func (impl AppStoreDeploymentFullModeServiceImpl) RegisterInArgo(chartGitAttribu return err } -func (impl AppStoreDeploymentFullModeServiceImpl) SyncACD(acdAppName string, ctx context.Context) { - req := new(application.ApplicationSyncRequest) - req.Name = &acdAppName - if ctx == nil { - impl.logger.Errorw("err in syncing ACD for AppStore, ctx is NULL", "acdAppName", acdAppName) - return - } - if _, err := impl.acdClient.Sync(ctx, req); err != nil { - impl.logger.Errorw("err in syncing ACD for AppStore", "acdAppName", acdAppName, "err", err) - } -} - func (impl AppStoreDeploymentFullModeServiceImpl) createInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context, envModel repository5.Environment, argocdAppName string) error { appNamespace := envModel.Namespace if appNamespace == "" { @@ -484,7 +268,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) UpdateRequirementYaml(installA return nil } -func (impl AppStoreDeploymentFullModeServiceImpl) SubscribeHelmInstallStatus() error { +func (impl AppStoreDeploymentFullModeServiceImpl) subscribeHelmInstallStatus() error { callback := func(msg *model.PubSubMsg) { diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index 02e55ca006..a06b2c76dc 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -34,10 +34,10 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository3 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bean" @@ -91,18 +91,17 @@ func GetDeploymentServiceTypeConfig() (*DeploymentServiceTypeConfig, error) { type AppStoreDeploymentServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository.InstalledAppRepository - chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository + chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository clusterRepository.EnvironmentRepository clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository appRepository app.AppRepository appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService - appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService + appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService environmentService cluster.EnvironmentService clusterService cluster.ClusterService helmAppService client.HelmAppService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - globalEnvVariables *util2.GlobalEnvVariables installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository gitOpsRepository repository2.GitOpsConfigRepository deploymentTypeConfig *DeploymentServiceTypeConfig @@ -111,12 +110,11 @@ type AppStoreDeploymentServiceImpl struct { } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, - chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository clusterRepository.EnvironmentRepository, + chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository clusterRepository.EnvironmentRepository, clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService, - appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, + appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService client.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - globalEnvVariables *util2.GlobalEnvVariables, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, attributesService attributes.AttributesService, deploymentTypeConfig *DeploymentServiceTypeConfig, ChartTemplateService util.ChartTemplateService, aCDConfig *argocdServer.ACDConfig) *AppStoreDeploymentServiceImpl { @@ -134,7 +132,6 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep clusterService: clusterService, helmAppService: helmAppService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, - globalEnvVariables: globalEnvVariables, installedAppRepositoryHistory: installedAppRepositoryHistory, gitOpsRepository: gitOpsRepository, deploymentTypeConfig: deploymentTypeConfig, diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go index bf7ff3567a..79a6fd1f9f 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go @@ -9,6 +9,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" repository5 "github.com/devtron-labs/devtron/pkg/auth/user/repository" @@ -133,7 +134,7 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl db, _ := sql.NewDbConnection(config, sugaredLogger) gitOpsRepository := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - chartGroupDeploymentRepository := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + chartGroupDeploymentRepository := repository5.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) appStoreDiscoverRepository := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 58c54eb5a1..cc426a9381 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -27,32 +27,27 @@ import ( "io/ioutil" "net/http" "os" - "regexp" "strconv" "strings" - "sync" - "sync/atomic" "time" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/common-lib/pubsub-lib/model" util4 "github.com/devtron-labs/common-lib/utils/k8s" - k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" - k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appStatus" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" + repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -64,14 +59,12 @@ import ( util2 "github.com/devtron-labs/devtron/pkg/util" util3 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" - "github.com/tidwall/gjson" "github.com/Pallinder/go-randomdata" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" bean2 "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/client/argocdServer/repository" repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/bean" @@ -88,29 +81,27 @@ const ( HELM_RELEASE_STATUS_UNKNOWN = "Unknown" ) +// DB operation + chart group + nats msg consume(to be removed) type InstalledAppService interface { GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) - DeployBulk(chartGroupInstallRequest *appStoreBean.ChartGroupInstallRequest) (*appStoreBean.ChartGroupInstallAppRes, error) - performDeployStage(appId int, installedAppVersionHistoryId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) + DeployBulk(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) UpdateInstalledAppVersionStatus(application *v1alpha1.Application) (bool, error) - FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean2.AppDetailsContainer, installedApp repository2.InstalledApps, helmReleaseInstallStatus string, status string) error MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId int, envId int) error CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) - FindNotesForArgoApplication(installedAppId, envId int) (string, string, error) - FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) + FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean2.AppDetailContainer) bean2.AppDetailContainer - fetchResourceTreeForACD(rctx context.Context, cn http.CloseNotifier, appId int, envId, clusterId int, deploymentAppName, namespace string) (map[string]interface{}, error) + FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean2.AppDetailsContainer, installedApp repository2.InstalledApps, helmReleaseInstallStatus string, status string) error + + //move to notes service + FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) } type InstalledAppServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository2.InstalledAppRepository - chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir - repositoryService repository.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository5.EnvironmentRepository teamRepository repository4.TeamRepository @@ -118,10 +109,8 @@ type InstalledAppServiceImpl struct { acdClient application2.ServiceClient appStoreValuesService service.AppStoreValuesService pubsubClient *pubsub.PubSubClientServiceImpl - tokenCache *util2.TokenCache - chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository + chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository envService cluster2.EnvironmentService - ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig gitOpsRepository repository3.GitOpsConfigRepository @@ -132,7 +121,6 @@ type InstalledAppServiceImpl struct { argoUserService argo.ArgoUserService helmAppClient client.HelmAppClient helmAppService client.HelmAppService - attributesRepository repository3.AttributesRepository appStatusService appStatus.AppStatusService K8sUtil *util4.K8sUtil pipelineStatusTimelineService status.PipelineStatusTimelineService @@ -144,34 +132,27 @@ type InstalledAppServiceImpl struct { func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository, - chartTemplateService util.ChartTemplateService, refChartDir appStoreBean.RefChartProxyDir, - repositoryService repository.ServiceClient, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, appRepository app.AppRepository, acdClient application2.ServiceClient, appStoreValuesService service.AppStoreValuesService, pubsubClient *pubsub.PubSubClientServiceImpl, - tokenCache *util2.TokenCache, - chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, - envService cluster2.EnvironmentService, argoK8sClient argocdServer.ArgoK8sClient, + chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository, + envService cluster2.EnvironmentService, gitFactory *util.GitFactory, aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, argoUserService argo.ArgoUserService, helmAppClient client.HelmAppClient, helmAppService client.HelmAppService, - attributesRepository repository3.AttributesRepository, appStatusService appStatus.AppStatusService, K8sUtil *util4.K8sUtil, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, + k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, acdConfig *argocdServer.ACDConfig) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, - chartTemplateService: chartTemplateService, - refChartDir: refChartDir, - repositoryService: repositoryService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, teamRepository: teamRepository, @@ -179,10 +160,8 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, acdClient: acdClient, appStoreValuesService: appStoreValuesService, pubsubClient: pubsubClient, - tokenCache: tokenCache, chartGroupDeploymentRepository: chartGroupDeploymentRepository, envService: envService, - ArgoK8sClient: argoK8sClient, gitFactory: gitFactory, aCDAuthConfig: aCDAuthConfig, gitOpsRepository: gitOpsRepository, @@ -193,7 +172,6 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, argoUserService: argoUserService, helmAppClient: helmAppClient, helmAppService: helmAppService, - attributesRepository: attributesRepository, appStatusService: appStatusService, K8sUtil: K8sUtil, pipelineStatusTimelineService: pipelineStatusTimelineService, @@ -260,17 +238,6 @@ func (impl InstalledAppServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) return installedAppsResponse, nil } -// converts db object to bean -func (impl InstalledAppServiceImpl) chartAdaptor(chart *repository2.InstalledAppVersions) (*appStoreBean.InstallAppVersionDTO, error) { - - return &appStoreBean.InstallAppVersionDTO{ - InstalledAppId: chart.InstalledAppId, - Id: chart.Id, - AppStoreVersion: chart.AppStoreApplicationVersionId, - ValuesOverrideYaml: chart.ValuesYaml, - }, nil -} - func (impl InstalledAppServiceImpl) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) { if len(appNames) == 0 { return nil, nil @@ -297,7 +264,7 @@ func (impl InstalledAppServiceImpl) CheckAppExists(appNames []*appStoreBean.AppN return appNames, nil } -func (impl InstalledAppServiceImpl) DeployBulk(chartGroupInstallRequest *appStoreBean.ChartGroupInstallRequest) (*appStoreBean.ChartGroupInstallAppRes, error) { +func (impl InstalledAppServiceImpl) DeployBulk(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) { impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) //save in db // raise nats event @@ -349,7 +316,7 @@ func (impl InstalledAppServiceImpl) DeployBulk(chartGroupInstallRequest *appStor } //nats event impl.triggerDeploymentEvent(installAppVersions) - return &appStoreBean.ChartGroupInstallAppRes{}, nil + return &chartGroup.ChartGroupInstallAppRes{}, nil } // generate unique installation ID using APPID @@ -372,8 +339,8 @@ func (impl InstalledAppServiceImpl) getInstallationId(installAppVersions []*appS return fmt.Sprintf("%x", bs), nil } -func (impl InstalledAppServiceImpl) createChartGroupEntryObject(installAppVersionDTO *appStoreBean.InstallAppVersionDTO, chartGroupId int, groupINstallationId string) *repository2.ChartGroupDeployment { - return &repository2.ChartGroupDeployment{ +func (impl InstalledAppServiceImpl) createChartGroupEntryObject(installAppVersionDTO *appStoreBean.InstallAppVersionDTO, chartGroupId int, groupINstallationId string) *repository6.ChartGroupDeployment { + return &repository6.ChartGroupDeployment{ ChartGroupId: chartGroupId, ChartGroupEntryId: installAppVersionDTO.ChartGroupEntryId, InstalledAppId: installAppVersionDTO.InstalledAppId, @@ -591,7 +558,7 @@ func (impl InstalledAppServiceImpl) performDeployStage(installedAppVersionId int return installedAppVersion, nil } -func (impl InstalledAppServiceImpl) requestBuilderForBulkDeployment(installRequest *appStoreBean.ChartGroupInstallChartRequest, projectId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl InstalledAppServiceImpl) requestBuilderForBulkDeployment(installRequest *chartGroup.ChartGroupInstallChartRequest, projectId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { valYaml := installRequest.ValuesOverrideYaml if valYaml == "" { valVersion, err := impl.appStoreValuesService.FindValuesByIdAndKind(installRequest.ReferenceValueId, installRequest.ReferenceValueKind) @@ -747,17 +714,17 @@ func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2. // STEP 4 - prepare a bulk request (unique names need to apply for deploying chart) // STEP 4.1 - fetch chart for required name(actual chart name (app-store)) with default values // STEP 4.2 - update all the required charts, override values.yaml with env variables. - chartGroupInstallRequest := &appStoreBean.ChartGroupInstallRequest{} + chartGroupInstallRequest := &chartGroup.ChartGroupInstallRequest{} chartGroupInstallRequest.ProjectId = t.Id chartGroupInstallRequest.UserId = userId - var chartGroupInstallChartRequests []*appStoreBean.ChartGroupInstallChartRequest + var chartGroupInstallChartRequests []*chartGroup.ChartGroupInstallChartRequest for _, item := range charts.ChartComponent { appStore, err := impl.appStoreApplicationVersionRepository.FindByAppStoreName(item.Name) if err != nil { impl.logger.Errorw("DeployDefaultChartOnCluster, error in getting app store", "data", t, "err", err) return false, err } - chartGroupInstallChartRequest := &appStoreBean.ChartGroupInstallChartRequest{ + chartGroupInstallChartRequest := &chartGroup.ChartGroupInstallChartRequest{ AppName: fmt.Sprintf("%d-%d-%s", bean.Id, env.Id, item.Name), EnvironmentId: env.Id, ValuesOverrideYaml: item.Values, @@ -790,7 +757,7 @@ type ChartComponent struct { Values string `json:"values"` } -func (impl InstalledAppServiceImpl) DeployDefaultComponent(chartGroupInstallRequest *appStoreBean.ChartGroupInstallRequest) (*appStoreBean.ChartGroupInstallAppRes, error) { +func (impl InstalledAppServiceImpl) DeployDefaultComponent(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) { impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) //save in db // raise nats event @@ -853,7 +820,7 @@ func (impl InstalledAppServiceImpl) DeployDefaultComponent(chartGroupInstallRequ } } - return &appStoreBean.ChartGroupInstallAppRes{}, nil + return &chartGroup.ChartGroupInstallAppRes{}, nil } func (impl *InstalledAppServiceImpl) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) { @@ -905,113 +872,6 @@ func (impl *InstalledAppServiceImpl) FindAppDetailsForAppstoreApplication(instal } return appDetail, nil } -func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { - //check notes.txt in db - installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) - if err != nil && err != pg.ErrNoRows { - return "", err - } - installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) - if err != nil { - if err == pg.ErrNoRows { - return "", fmt.Errorf("values are outdated. please fetch the latest version and try again") - } - impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) - return "", err - } - chartVersion := installedAppVerison.AppStoreApplicationVersion.Version - if err != nil { - impl.logger.Errorw("error fetching chart version in installed app service", "err", err) - return "", err - } - re := regexp.MustCompile(`CHART VERSION: ([0-9]+\.[0-9]+\.[0-9]+)`) - newStr := re.ReplaceAllString(installedApp.Notes, "CHART VERSION: "+chartVersion) - installedApp.Notes = newStr - appName := installedApp.App.AppName - if err != nil { - impl.logger.Errorw("error fetching notes from db", "err", err) - return "", err - } - isValidAuth := checkNotesAuth(token, appName, envId) - if !isValidAuth { - impl.logger.Errorw("unauthorized user", "isValidAuth", isValidAuth) - return "", fmt.Errorf("unauthorized user") - } - //if notes is not present in db then below call will happen - if installedApp.Notes == "" { - notes, _, err := impl.FindNotesForArgoApplication(installedAppId, envId) - if err != nil { - impl.logger.Errorw("error fetching notes", "err", err) - return "", err - } - if notes == "" { - impl.logger.Errorw("error fetching notes", "err", err) - } - return notes, err - } - - return installedApp.Notes, nil -} -func (impl *InstalledAppServiceImpl) FindNotesForArgoApplication(installedAppId, envId int) (string, string, error) { - installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) - if err != nil { - impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) - return "", "", err - } - var notes string - appName := installedAppVerison.InstalledApp.App.AppName - - if util.IsAcdApp(installedAppVerison.InstalledApp.DeploymentAppType) { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installedAppVerison.AppStoreApplicationVersion.Id) - if err != nil { - impl.logger.Errorw("error fetching app store app version in installed app service", "err", err) - return notes, appName, err - } - k8sServerVersion, err := impl.K8sUtil.GetKubeVersion() - if err != nil { - impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err) - return notes, appName, err - } - - installReleaseRequest := &client.InstallReleaseRequest{ - ChartName: appStoreAppVersion.Name, - ChartVersion: appStoreAppVersion.Version, - ValuesYaml: installedAppVerison.ValuesYaml, - K8SVersion: k8sServerVersion.String(), - ChartRepository: &client.ChartRepository{ - Name: appStoreAppVersion.AppStore.ChartRepo.Name, - Url: appStoreAppVersion.AppStore.ChartRepo.Url, - Username: appStoreAppVersion.AppStore.ChartRepo.UserName, - Password: appStoreAppVersion.AppStore.ChartRepo.Password, - }, - ReleaseIdentifier: &client.ReleaseIdentifier{ - ReleaseNamespace: installedAppVerison.InstalledApp.Environment.Namespace, - ReleaseName: installedAppVerison.InstalledApp.App.AppName, - }, - } - - clusterId := installedAppVerison.InstalledApp.Environment.ClusterId - config, err := impl.helmAppService.GetClusterConf(clusterId) - if err != nil { - impl.logger.Errorw("error in fetching cluster detail", "clusterId", clusterId, "err", err) - return "", appName, err - } - installReleaseRequest.ReleaseIdentifier.ClusterConfig = config - - notes, err = impl.helmAppService.GetNotes(context.Background(), installReleaseRequest) - if err != nil { - impl.logger.Errorw("error in fetching notes", "err", err) - return notes, appName, err - } - _, err = impl.appStoreDeploymentService.UpdateNotesForInstalledApp(installedAppId, notes) - if err != nil { - impl.logger.Errorw("error in updating notes in db ", "err", err) - return notes, appName, err - } - } - - return notes, appName, nil -} func (impl InstalledAppServiceImpl) GetInstalledAppVersionHistory(installedAppId int) (*appStoreBean.InstallAppVersionHistoryDto, error) { result := &appStoreBean.InstallAppVersionHistoryDto{} @@ -1121,82 +981,6 @@ func (impl InstalledAppServiceImpl) GetInstalledAppVersionHistoryValues(installe values.ValuesYaml = versionHistory.ValuesYamlRaw return values, err } -func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean2.AppDetailsContainer, installedApp repository2.InstalledApps, helmReleaseInstallStatus string, status string) error { - var err error - var resourceTree map[string]interface{} - deploymentAppName := fmt.Sprintf("%s-%s", installedApp.App.AppName, installedApp.Environment.Name) - if util.IsAcdApp(installedApp.DeploymentAppType) { - resourceTree, err = impl.fetchResourceTreeForACD(rctx, cn, installedApp.App.Id, installedApp.EnvironmentId, installedApp.Environment.ClusterId, deploymentAppName, installedApp.Environment.Namespace) - } else if util.IsHelmApp(installedApp.DeploymentAppType) { - config, err := impl.helmAppService.GetClusterConf(installedApp.Environment.ClusterId) - if err != nil { - impl.logger.Errorw("error in fetching cluster detail", "err", err) - } - req := &client.AppDetailRequest{ - ClusterConfig: config, - Namespace: installedApp.Environment.Namespace, - ReleaseName: installedApp.App.AppName, - } - detail, err := impl.helmAppClient.GetAppDetail(rctx, req) - if err != nil { - impl.logger.Errorw("error in fetching app detail", "err", err) - } - - /* helmReleaseInstallStatus is nats message sent from kubelink to orchestrator and has the following details about installation :- - 1) isReleaseInstalled -> whether release object is created or not in this installation - 2) ErrorInInstallation -> if there is error in installation - 3) Message -> error message/ success message - 4) InstallAppVersionHistoryId - 5) Status -> Progressing, Failed, Succeeded - */ - - if detail != nil && detail.ReleaseExist { - - resourceTree = util3.InterfaceToMapAdapter(detail.ResourceTreeResponse) - resourceTree["status"] = detail.ApplicationStatus - appDetailsContainer.Notes = detail.ChartMetadata.Notes - - helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} - releaseStatus := detail.ReleaseStatus - - if len(helmReleaseInstallStatus) > 0 { - err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) - if err != nil { - impl.logger.Errorw("error in unmarshalling helm release install status") - return err - } - // ReleaseExist=true in app detail container but helm install status says that isReleaseInstalled=false which means this release was created externally - if helmInstallStatus.IsReleaseInstalled == false && status != "Progressing" { - /* - Handling case when :- - 1) An external release with name "foo" exist - 2) User creates an app with same name i.e "foo" - 3) In this case we use helmReleaseInstallStatus which will have status of our release and not external release - */ - resourceTree = make(map[string]interface{}) - releaseStatus = impl.getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus, status) - } - } - releaseStatusMap := util3.InterfaceToMapAdapter(releaseStatus) - appDetailsContainer.ReleaseStatus = releaseStatusMap - } else { - // case when helm release is not created - releaseStatus := impl.getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus, status) - releaseStatusMap := util3.InterfaceToMapAdapter(releaseStatus) - appDetailsContainer.ReleaseStatus = releaseStatusMap - } - } - if resourceTree != nil { - version, err := impl.k8sCommonService.GetK8sServerVersion(installedApp.Environment.ClusterId) - if err != nil { - impl.logger.Errorw("error in fetching k8s version in resource tree call fetching", "clusterId", installedApp.Environment.ClusterId, "err", err) - } else { - resourceTree["serverVersion"] = version.String() - } - appDetailsContainer.ResourceTree = resourceTree - } - return err -} func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *client.ReleaseStatus { //release status is sent in resource tree call and is shown on UI as helm config apply status @@ -1291,233 +1075,3 @@ func (impl InstalledAppServiceImpl) CheckAppExistsByInstalledAppId(installedAppI } return installedApp, err } - -func (impl InstalledAppServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean2.AppDetailContainer) bean2.AppDetailContainer { - ctx, cancel := context.WithCancel(rctx) - if cn != nil { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - return *appDetail - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - deploymentAppName := fmt.Sprintf("%s-%s", appDetail.AppName, appDetail.EnvironmentName) - resourceTree, err := impl.fetchResourceTreeForACD(rctx, cn, appDetail.InstalledAppId, appDetail.EnvironmentId, appDetail.ClusterId, deploymentAppName, appDetail.Namespace) - appDetail.ResourceTree = resourceTree - if err != nil { - return *appDetail - } - if appDetail.ResourceTree["nodes"] == nil { - return *appDetail - } - appDetail.ResourceTree, _ = impl.checkHibernate(appDetail.ResourceTree, deploymentAppName, ctx) - return *appDetail -} -func (impl InstalledAppServiceImpl) checkHibernate(resp map[string]interface{}, deploymentAppName string, ctx context.Context) (map[string]interface{}, string) { - - if resp == nil { - return resp, "" - } - responseTree := resp - var canBeHibernated uint64 = 0 - var hibernated uint64 = 0 - responseTreeNodes, ok := responseTree["nodes"] - if !ok { - return resp, "" - } - replicaNodes := impl.filterOutReplicaNodes(responseTreeNodes) - batchSize := impl.aCDAuthConfig.ResourceListForReplicasBatchSize - requestsLength := len(replicaNodes) - for i := 0; i < requestsLength; { - //requests left to process - remainingBatch := requestsLength - i - if remainingBatch < batchSize { - batchSize = remainingBatch - } - var wg sync.WaitGroup - for j := 0; j < batchSize; j++ { - wg.Add(1) - go func(j int) { - defer wg.Done() - canBeHibernatedFlag, hibernatedFlag := impl.processReplicaNodeForHibernation(replicaNodes[i+j], deploymentAppName, ctx) - if canBeHibernatedFlag { - atomic.AddUint64(&canBeHibernated, 1) - } - if hibernatedFlag { - atomic.AddUint64(&hibernated, 1) - } - }(j) - } - wg.Wait() - i += batchSize - } - - status := "" - if hibernated > 0 && canBeHibernated > 0 { - if hibernated == canBeHibernated { - status = appStatus.HealthStatusHibernating - } else if hibernated < canBeHibernated { - status = appStatus.HealthStatusPartiallyHibernated - } - } - - return responseTree, status -} - -func (impl InstalledAppServiceImpl) processReplicaNodeForHibernation(node interface{}, deploymentAppName string, ctx context.Context) (bool, bool) { - currNode := node.(interface{}).(map[string]interface{}) - resName := util3.InterfaceToString(currNode["name"]) - resKind := util3.InterfaceToString(currNode["kind"]) - resGroup := util3.InterfaceToString(currNode["group"]) - resVersion := util3.InterfaceToString(currNode["version"]) - resNamespace := util3.InterfaceToString(currNode["namespace"]) - rQuery := &application.ApplicationResourceRequest{ - Name: &deploymentAppName, - ResourceName: &resName, - Kind: &resKind, - Group: &resGroup, - Version: &resVersion, - Namespace: &resNamespace, - } - canBeHibernatedFlag := false - alreadyHibernated := false - - if currNode["parentRefs"] == nil { - canBeHibernatedFlag, alreadyHibernated = impl.checkForHibernation(ctx, rQuery, currNode) - } - return canBeHibernatedFlag, alreadyHibernated -} - -func (impl InstalledAppServiceImpl) checkForHibernation(ctx context.Context, rQuery *application.ApplicationResourceRequest, currNode map[string]interface{}) (bool, bool) { - t0 := time.Now() - canBeHibernated := false - alreadyHibernated := false - ctx, _ = context.WithTimeout(ctx, 60*time.Second) - res, err := impl.acdClient.GetResource(ctx, rQuery) - if err != nil { - impl.logger.Errorw("error getting response from acdClient", "request", rQuery, "data", res, "timeTaken", time.Since(t0), "err", err) - return canBeHibernated, alreadyHibernated - } - if res.Manifest != nil { - manifest, _ := gjson.Parse(*res.Manifest).Value().(map[string]interface{}) - replicas := util3.InterfaceToMapAdapter(manifest["spec"])["replicas"] - if replicas != nil { - currNode["canBeHibernated"] = true - canBeHibernated = true - } - annotations := util3.InterfaceToMapAdapter(manifest["metadata"])["annotations"] - if annotations != nil { - val := util3.InterfaceToMapAdapter(annotations)["hibernator.devtron.ai/replicas"] - if val != nil { - if util3.InterfaceToString(val) != "0" && util3.InterfaceToFloat(replicas) == 0 { - currNode["isHibernated"] = true - alreadyHibernated = true - } - } - } - } - return canBeHibernated, alreadyHibernated -} - -func (impl InstalledAppServiceImpl) fetchResourceTreeForACD(rctx context.Context, cn http.CloseNotifier, appId int, envId, clusterId int, deploymentAppName, namespace string) (map[string]interface{}, error) { - var resourceTree map[string]interface{} - query := &application.ResourcesQuery{ - ApplicationName: &deploymentAppName, - } - ctx, cancel := context.WithCancel(rctx) - if cn != nil { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - return resourceTree, err - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - start := time.Now() - resp, err := impl.acdClient.ResourceTree(ctx, query) - elapsed := time.Since(start) - impl.logger.Debugf("Time elapsed %s in fetching app-store installed application %s for environment %s", elapsed, deploymentAppName, envId) - if err != nil { - impl.logger.Errorw("service err, FetchAppDetailsForInstalledAppV2, fetching resource tree", "err", err, "installedAppId", appId, "envId", envId) - err = &util.ApiError{ - Code: constants.AppDetailResourceTreeNotFound, - InternalMessage: "app detail fetched, failed to get resource tree from acd", - UserMessage: "app detail fetched, failed to get resource tree from acd", - } - return resourceTree, err - } - label := fmt.Sprintf("app.kubernetes.io/instance=%s", deploymentAppName) - pods, err := impl.k8sApplicationService.GetPodListByLabel(clusterId, namespace, label) - if err != nil { - impl.logger.Errorw("error in getting pods by label", "err", err, "clusterId", clusterId, "namespace", namespace, "label", label) - return resourceTree, err - } - ephemeralContainersMap := k8sObjectUtils.ExtractEphemeralContainers(pods) - for _, metaData := range resp.PodMetadata { - metaData.EphemeralContainers = ephemeralContainersMap[metaData.Name] - } - resourceTree = util3.InterfaceToMapAdapter(resp) - resourceTree, hibernationStatus := impl.checkHibernate(resourceTree, deploymentAppName, ctx) - appStatus := resp.Status - if resourceTree != nil { - if hibernationStatus != "" { - resourceTree["status"] = hibernationStatus - appStatus = hibernationStatus - } - } - // using this resp.Status to update in app_status table - go func() { - err = impl.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, appStatus) - if err != nil { - impl.logger.Warnw("error in updating app status", "err", err, appId, "envId", envId) - } - }() - impl.logger.Debugf("application %s in environment %s had status %+v\n", appId, envId, resp) - k8sAppDetail := bean2.AppDetailContainer{ - DeploymentDetailContainer: bean2.DeploymentDetailContainer{ - ClusterId: clusterId, - Namespace: namespace, - }, - } - clusterIdString := strconv.Itoa(clusterId) - validRequest := impl.k8sCommonService.FilterK8sResources(rctx, resourceTree, k8sAppDetail, clusterIdString, []string{k8sCommonBean.ServiceKind, k8sCommonBean.EndpointsKind, k8sCommonBean.IngressKind}) - response, err := impl.k8sCommonService.GetManifestsByBatch(rctx, validRequest) - if err != nil { - impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) - return nil, err - } - newResourceTree := impl.k8sCommonService.PortNumberExtraction(response, resourceTree) - return newResourceTree, err -} - -func (impl InstalledAppServiceImpl) filterOutReplicaNodes(responseTreeNodes interface{}) []interface{} { - resourceListForReplicas := impl.aCDAuthConfig.ResourceListForReplicas - entries := strings.Split(resourceListForReplicas, ",") - resourceListMap := util3.ConvertStringSliceToMap(entries) - var replicaNodes []interface{} - for _, node := range responseTreeNodes.(interface{}).([]interface{}) { - currNode := node.(interface{}).(map[string]interface{}) - resKind := util3.InterfaceToString(currNode["kind"]) - if _, ok := resourceListMap[resKind]; ok { - replicaNodes = append(replicaNodes, node) - } - } - return replicaNodes -} diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index 7de0bb6574..b28d642ec6 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -11,6 +11,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" @@ -38,7 +39,7 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { appStoreValuesService service.AppStoreValuesService pubsubClient *pubsub.PubSubClientServiceImpl tokenCache *util2.TokenCache - chartGroupDeploymentRepository repository4.ChartGroupDeploymentRepository + chartGroupDeploymentRepository repository5.ChartGroupDeploymentRepository envService cluster.EnvironmentService ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory diff --git a/pkg/appStore/deployment/service/Notes.go b/pkg/appStore/deployment/service/Notes.go new file mode 100644 index 0000000000..88ce454af6 --- /dev/null +++ b/pkg/appStore/deployment/service/Notes.go @@ -0,0 +1,118 @@ +package service + +import ( + "context" + "fmt" + "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/internal/util" + "github.com/go-pg/pg" + "regexp" +) + +func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, envId int) (string, string, error) { + installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) + if err != nil { + impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) + return "", "", err + } + var notes string + appName := installedAppVerison.InstalledApp.App.AppName + + if util.IsAcdApp(installedAppVerison.InstalledApp.DeploymentAppType) { + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installedAppVerison.AppStoreApplicationVersion.Id) + if err != nil { + impl.logger.Errorw("error fetching app store app version in installed app service", "err", err) + return notes, appName, err + } + k8sServerVersion, err := impl.K8sUtil.GetKubeVersion() + if err != nil { + impl.logger.Errorw("exception caught in getting k8sServerVersion", "err", err) + return notes, appName, err + } + + installReleaseRequest := &client.InstallReleaseRequest{ + ChartName: appStoreAppVersion.Name, + ChartVersion: appStoreAppVersion.Version, + ValuesYaml: installedAppVerison.ValuesYaml, + K8SVersion: k8sServerVersion.String(), + ChartRepository: &client.ChartRepository{ + Name: appStoreAppVersion.AppStore.ChartRepo.Name, + Url: appStoreAppVersion.AppStore.ChartRepo.Url, + Username: appStoreAppVersion.AppStore.ChartRepo.UserName, + Password: appStoreAppVersion.AppStore.ChartRepo.Password, + }, + ReleaseIdentifier: &client.ReleaseIdentifier{ + ReleaseNamespace: installedAppVerison.InstalledApp.Environment.Namespace, + ReleaseName: installedAppVerison.InstalledApp.App.AppName, + }, + } + + clusterId := installedAppVerison.InstalledApp.Environment.ClusterId + config, err := impl.helmAppService.GetClusterConf(clusterId) + if err != nil { + impl.logger.Errorw("error in fetching cluster detail", "clusterId", clusterId, "err", err) + return "", appName, err + } + installReleaseRequest.ReleaseIdentifier.ClusterConfig = config + + notes, err = impl.helmAppService.GetNotes(context.Background(), installReleaseRequest) + if err != nil { + impl.logger.Errorw("error in fetching notes", "err", err) + return notes, appName, err + } + _, err = impl.appStoreDeploymentService.UpdateNotesForInstalledApp(installedAppId, notes) + if err != nil { + impl.logger.Errorw("error in updating notes in db ", "err", err) + return notes, appName, err + } + } + + return notes, appName, nil +} +func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { + //check notes.txt in db + installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) + if err != nil && err != pg.ErrNoRows { + return "", err + } + installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) + if err != nil { + if err == pg.ErrNoRows { + return "", fmt.Errorf("values are outdated. please fetch the latest version and try again") + } + impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) + return "", err + } + chartVersion := installedAppVerison.AppStoreApplicationVersion.Version + if err != nil { + impl.logger.Errorw("error fetching chart version in installed app service", "err", err) + return "", err + } + re := regexp.MustCompile(`CHART VERSION: ([0-9]+\.[0-9]+\.[0-9]+)`) + newStr := re.ReplaceAllString(installedApp.Notes, "CHART VERSION: "+chartVersion) + installedApp.Notes = newStr + appName := installedApp.App.AppName + if err != nil { + impl.logger.Errorw("error fetching notes from db", "err", err) + return "", err + } + isValidAuth := checkNotesAuth(token, appName, envId) + if !isValidAuth { + impl.logger.Errorw("unauthorized user", "isValidAuth", isValidAuth) + return "", fmt.Errorf("unauthorized user") + } + //if notes is not present in db then below call will happen + if installedApp.Notes == "" { + notes, _, err := impl.findNotesForArgoApplication(installedAppId, envId) + if err != nil { + impl.logger.Errorw("error fetching notes", "err", err) + return "", err + } + if notes == "" { + impl.logger.Errorw("error fetching notes", "err", err) + } + return notes, err + } + + return installedApp.Notes, nil +} diff --git a/pkg/appStore/deployment/service/ResourceTree.go b/pkg/appStore/deployment/service/ResourceTree.go new file mode 100644 index 0000000000..e826bacb55 --- /dev/null +++ b/pkg/appStore/deployment/service/ResourceTree.go @@ -0,0 +1,334 @@ +package service + +import ( + "context" + "encoding/json" + "fmt" + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + "github.com/devtron-labs/common-lib/utils/k8s/commonBean" + "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" + "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/internal/constants" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStatus" + "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + util2 "github.com/devtron-labs/devtron/util" + "github.com/tidwall/gjson" + "net/http" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" +) + +func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error { + var err error + var resourceTree map[string]interface{} + deploymentAppName := fmt.Sprintf("%s-%s", installedApp.App.AppName, installedApp.Environment.Name) + if util.IsAcdApp(installedApp.DeploymentAppType) { + resourceTree, err = impl.fetchResourceTreeForACD(rctx, cn, installedApp.App.Id, installedApp.EnvironmentId, installedApp.Environment.ClusterId, deploymentAppName, installedApp.Environment.Namespace) + } else if util.IsHelmApp(installedApp.DeploymentAppType) { + config, err := impl.helmAppService.GetClusterConf(installedApp.Environment.ClusterId) + if err != nil { + impl.logger.Errorw("error in fetching cluster detail", "err", err) + } + req := &client.AppDetailRequest{ + ClusterConfig: config, + Namespace: installedApp.Environment.Namespace, + ReleaseName: installedApp.App.AppName, + } + detail, err := impl.helmAppClient.GetAppDetail(rctx, req) + if err != nil { + impl.logger.Errorw("error in fetching app detail", "err", err) + } + + /* helmReleaseInstallStatus is nats message sent from kubelink to orchestrator and has the following details about installation :- + 1) isReleaseInstalled -> whether release object is created or not in this installation + 2) ErrorInInstallation -> if there is error in installation + 3) Message -> error message/ success message + 4) InstallAppVersionHistoryId + 5) Status -> Progressing, Failed, Succeeded + */ + + if detail != nil && detail.ReleaseExist { + + resourceTree = util2.InterfaceToMapAdapter(detail.ResourceTreeResponse) + resourceTree["status"] = detail.ApplicationStatus + appDetailsContainer.Notes = detail.ChartMetadata.Notes + + helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} + releaseStatus := detail.ReleaseStatus + + if len(helmReleaseInstallStatus) > 0 { + err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) + if err != nil { + impl.logger.Errorw("error in unmarshalling helm release install status") + return err + } + // ReleaseExist=true in app detail container but helm install status says that isReleaseInstalled=false which means this release was created externally + if helmInstallStatus.IsReleaseInstalled == false && status != "Progressing" { + /* + Handling case when :- + 1) An external release with name "foo" exist + 2) User creates an app with same name i.e "foo" + 3) In this case we use helmReleaseInstallStatus which will have status of our release and not external release + */ + resourceTree = make(map[string]interface{}) + releaseStatus = impl.getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus, status) + } + } + releaseStatusMap := util2.InterfaceToMapAdapter(releaseStatus) + appDetailsContainer.ReleaseStatus = releaseStatusMap + } else { + // case when helm release is not created + releaseStatus := impl.getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus, status) + releaseStatusMap := util2.InterfaceToMapAdapter(releaseStatus) + appDetailsContainer.ReleaseStatus = releaseStatusMap + } + } + if resourceTree != nil { + version, err := impl.k8sCommonService.GetK8sServerVersion(installedApp.Environment.ClusterId) + if err != nil { + impl.logger.Errorw("error in fetching k8s version in resource tree call fetching", "clusterId", installedApp.Environment.ClusterId, "err", err) + } else { + resourceTree["serverVersion"] = version.String() + } + appDetailsContainer.ResourceTree = resourceTree + } + return err +} + +func (impl InstalledAppServiceImpl) fetchResourceTreeForACD(rctx context.Context, cn http.CloseNotifier, appId int, envId, clusterId int, deploymentAppName, namespace string) (map[string]interface{}, error) { + var resourceTree map[string]interface{} + query := &application.ResourcesQuery{ + ApplicationName: &deploymentAppName, + } + ctx, cancel := context.WithCancel(rctx) + if cn != nil { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.logger.Errorw("error in getting acd token", "err", err) + return resourceTree, err + } + ctx = context.WithValue(ctx, "token", acdToken) + defer cancel() + start := time.Now() + resp, err := impl.acdClient.ResourceTree(ctx, query) + elapsed := time.Since(start) + impl.logger.Debugf("Time elapsed %s in fetching app-store installed application %s for environment %s", elapsed, deploymentAppName, envId) + if err != nil { + impl.logger.Errorw("service err, FetchAppDetailsForInstalledAppV2, fetching resource tree", "err", err, "installedAppId", appId, "envId", envId) + err = &util.ApiError{ + Code: constants.AppDetailResourceTreeNotFound, + InternalMessage: "app detail fetched, failed to get resource tree from acd", + UserMessage: "app detail fetched, failed to get resource tree from acd", + } + return resourceTree, err + } + label := fmt.Sprintf("app.kubernetes.io/instance=%s", deploymentAppName) + pods, err := impl.k8sApplicationService.GetPodListByLabel(clusterId, namespace, label) + if err != nil { + impl.logger.Errorw("error in getting pods by label", "err", err, "clusterId", clusterId, "namespace", namespace, "label", label) + return resourceTree, err + } + ephemeralContainersMap := k8sObjectsUtil.ExtractEphemeralContainers(pods) + for _, metaData := range resp.PodMetadata { + metaData.EphemeralContainers = ephemeralContainersMap[metaData.Name] + } + resourceTree = util2.InterfaceToMapAdapter(resp) + resourceTree, hibernationStatus := impl.checkHibernate(resourceTree, deploymentAppName, ctx) + appStatus := resp.Status + if resourceTree != nil { + if hibernationStatus != "" { + resourceTree["status"] = hibernationStatus + appStatus = hibernationStatus + } + } + // using this resp.Status to update in app_status table + //FIXME: remove this dangling thread + go func() { + err = impl.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, appStatus) + if err != nil { + impl.logger.Warnw("error in updating app status", "err", err, appId, "envId", envId) + } + }() + impl.logger.Debugf("application %s in environment %s had status %+v\n", appId, envId, resp) + k8sAppDetail := bean.AppDetailContainer{ + DeploymentDetailContainer: bean.DeploymentDetailContainer{ + ClusterId: clusterId, + Namespace: namespace, + }, + } + clusterIdString := strconv.Itoa(clusterId) + validRequest := impl.k8sCommonService.FilterK8sResources(rctx, resourceTree, k8sAppDetail, clusterIdString, []string{commonBean.ServiceKind, commonBean.EndpointsKind, commonBean.IngressKind}) + response, err := impl.k8sCommonService.GetManifestsByBatch(rctx, validRequest) + if err != nil { + impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) + return nil, err + } + newResourceTree := impl.k8sCommonService.PortNumberExtraction(response, resourceTree) + return newResourceTree, err +} + +func (impl InstalledAppServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer { + ctx, cancel := context.WithCancel(rctx) + if cn != nil { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.logger.Errorw("error in getting acd token", "err", err) + return *appDetail + } + ctx = context.WithValue(ctx, "token", acdToken) + defer cancel() + deploymentAppName := fmt.Sprintf("%s-%s", appDetail.AppName, appDetail.EnvironmentName) + resourceTree, err := impl.fetchResourceTreeForACD(rctx, cn, appDetail.InstalledAppId, appDetail.EnvironmentId, appDetail.ClusterId, deploymentAppName, appDetail.Namespace) + appDetail.ResourceTree = resourceTree + if err != nil { + return *appDetail + } + if appDetail.ResourceTree["nodes"] == nil { + return *appDetail + } + appDetail.ResourceTree, _ = impl.checkHibernate(appDetail.ResourceTree, deploymentAppName, ctx) + return *appDetail +} + +func (impl InstalledAppServiceImpl) checkHibernate(resp map[string]interface{}, deploymentAppName string, ctx context.Context) (map[string]interface{}, string) { + + if resp == nil { + return resp, "" + } + responseTree := resp + var canBeHibernated uint64 = 0 + var hibernated uint64 = 0 + responseTreeNodes, ok := responseTree["nodes"] + if !ok { + return resp, "" + } + replicaNodes := impl.filterOutReplicaNodes(responseTreeNodes) + batchSize := impl.aCDAuthConfig.ResourceListForReplicasBatchSize + requestsLength := len(replicaNodes) + for i := 0; i < requestsLength; { + //requests left to process + remainingBatch := requestsLength - i + if remainingBatch < batchSize { + batchSize = remainingBatch + } + var wg sync.WaitGroup + for j := 0; j < batchSize; j++ { + wg.Add(1) + go func(j int) { + defer wg.Done() + canBeHibernatedFlag, hibernatedFlag := impl.processReplicaNodeForHibernation(replicaNodes[i+j], deploymentAppName, ctx) + if canBeHibernatedFlag { + atomic.AddUint64(&canBeHibernated, 1) + } + if hibernatedFlag { + atomic.AddUint64(&hibernated, 1) + } + }(j) + } + wg.Wait() + i += batchSize + } + + status := "" + if hibernated > 0 && canBeHibernated > 0 { + if hibernated == canBeHibernated { + status = appStatus.HealthStatusHibernating + } else if hibernated < canBeHibernated { + status = appStatus.HealthStatusPartiallyHibernated + } + } + + return responseTree, status +} + +func (impl InstalledAppServiceImpl) processReplicaNodeForHibernation(node interface{}, deploymentAppName string, ctx context.Context) (bool, bool) { + currNode := node.(interface{}).(map[string]interface{}) + resName := util2.InterfaceToString(currNode["name"]) + resKind := util2.InterfaceToString(currNode["kind"]) + resGroup := util2.InterfaceToString(currNode["group"]) + resVersion := util2.InterfaceToString(currNode["version"]) + resNamespace := util2.InterfaceToString(currNode["namespace"]) + rQuery := &application.ApplicationResourceRequest{ + Name: &deploymentAppName, + ResourceName: &resName, + Kind: &resKind, + Group: &resGroup, + Version: &resVersion, + Namespace: &resNamespace, + } + canBeHibernatedFlag := false + alreadyHibernated := false + + if currNode["parentRefs"] == nil { + canBeHibernatedFlag, alreadyHibernated = impl.checkForHibernation(ctx, rQuery, currNode) + } + return canBeHibernatedFlag, alreadyHibernated +} + +func (impl InstalledAppServiceImpl) checkForHibernation(ctx context.Context, rQuery *application.ApplicationResourceRequest, currNode map[string]interface{}) (bool, bool) { + t0 := time.Now() + canBeHibernated := false + alreadyHibernated := false + ctx, _ = context.WithTimeout(ctx, 60*time.Second) + res, err := impl.acdClient.GetResource(ctx, rQuery) + if err != nil { + impl.logger.Errorw("error getting response from acdClient", "request", rQuery, "data", res, "timeTaken", time.Since(t0), "err", err) + return canBeHibernated, alreadyHibernated + } + if res.Manifest != nil { + manifest, _ := gjson.Parse(*res.Manifest).Value().(map[string]interface{}) + replicas := util2.InterfaceToMapAdapter(manifest["spec"])["replicas"] + if replicas != nil { + currNode["canBeHibernated"] = true + canBeHibernated = true + } + annotations := util2.InterfaceToMapAdapter(manifest["metadata"])["annotations"] + if annotations != nil { + val := util2.InterfaceToMapAdapter(annotations)["hibernator.devtron.ai/replicas"] + if val != nil { + if util2.InterfaceToString(val) != "0" && util2.InterfaceToFloat(replicas) == 0 { + currNode["isHibernated"] = true + alreadyHibernated = true + } + } + } + } + return canBeHibernated, alreadyHibernated +} + +func (impl InstalledAppServiceImpl) filterOutReplicaNodes(responseTreeNodes interface{}) []interface{} { + resourceListForReplicas := impl.aCDAuthConfig.ResourceListForReplicas + entries := strings.Split(resourceListForReplicas, ",") + resourceListMap := util2.ConvertStringSliceToMap(entries) + var replicaNodes []interface{} + for _, node := range responseTreeNodes.(interface{}).([]interface{}) { + currNode := node.(interface{}).(map[string]interface{}) + resKind := util2.InterfaceToString(currNode["kind"]) + if _, ok := resourceListMap[resKind]; ok { + replicaNodes = append(replicaNodes, node) + } + } + return replicaNodes +} diff --git a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go similarity index 66% rename from pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go rename to pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go index c861291f38..e92a5e0485 100644 --- a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go @@ -1,29 +1,26 @@ -package appStoreDeploymentGitopsTool +package appStoreDeploymentTool import ( "context" "encoding/json" "errors" "fmt" - "net/http" "strings" "time" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/devtron-labs/common-lib/utils/k8s/health" client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/constants" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appStatus" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" @@ -31,7 +28,6 @@ import ( "github.com/devtron-labs/devtron/pkg/auth/user" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" - "github.com/devtron-labs/devtron/util/argo" "github.com/go-pg/pg" "github.com/golang/protobuf/ptypes/timestamp" "go.opentelemetry.io/otel" @@ -44,19 +40,14 @@ import ( type AppStoreDeploymentArgoCdService interface { //InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) GetGitOpsRepoName(appName string, environmentName string) (string, error) - OnUpdateRepoInInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - UpdateRequirementDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error - UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *clusterRepository.Environment, installedAppVersion *repository.InstalledAppVersions, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error - UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error } @@ -64,31 +55,29 @@ type AppStoreDeploymentArgoCdServiceImpl struct { Logger *zap.SugaredLogger appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService acdClient application2.ServiceClient - chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository + chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository installedAppRepository repository.InstalledAppRepository installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory - argoUserService argo.ArgoUserService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService helmAppService client.HelmAppService - gitOpsConfigRepository repository3.GitOpsConfigRepository appStatusService appStatus.AppStatusService pipelineStatusTimelineService status.PipelineStatusTimelineService - userService user.UserService pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository + userService user.UserService appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig } func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, - acdClient application2.ServiceClient, chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository, - installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, chartTemplateService util.ChartTemplateService, - gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - helmAppService client.HelmAppService, gitOpsConfigRepository repository3.GitOpsConfigRepository, appStatusService appStatus.AppStatusService, - pipelineStatusTimelineService status.PipelineStatusTimelineService, userService user.UserService, + acdClient application2.ServiceClient, chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, + installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, + gitFactory *util.GitFactory, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + helmAppService client.HelmAppService, appStatusService appStatus.AppStatusService, + pipelineStatusTimelineService status.PipelineStatusTimelineService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, + userService user.UserService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, ) *AppStoreDeploymentArgoCdServiceImpl { @@ -99,16 +88,13 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD chartGroupDeploymentRepository: chartGroupDeploymentRepository, installedAppRepository: installedAppRepository, installedAppRepositoryHistory: installedAppRepositoryHistory, - chartTemplateService: chartTemplateService, gitFactory: gitFactory, - argoUserService: argoUserService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, helmAppService: helmAppService, - gitOpsConfigRepository: gitOpsConfigRepository, appStatusService: appStatusService, pipelineStatusTimelineService: pipelineStatusTimelineService, - userService: userService, pipelineStatusTimelineRepository: pipelineStatusTimelineRepository, + userService: userService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, argoClientWrapperService: argoClientWrapperService, acdConfig: acdConfig, @@ -213,55 +199,6 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequ // return installAppVersionRequest, nil //} -// TODO: Test ACD to get status -func (impl AppStoreDeploymentArgoCdServiceImpl) GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) { - if len(installedAppAndEnvDetails.AppName) > 0 && len(installedAppAndEnvDetails.EnvironmentName) > 0 { - acdAppName := installedAppAndEnvDetails.AppName + "-" + installedAppAndEnvDetails.EnvironmentName - query := &application.ResourcesQuery{ - ApplicationName: &acdAppName, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.Logger.Errorw("error in getting acd token", "err", err) - return "", err - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - impl.Logger.Debugf("Getting status for app %s in env %s", installedAppAndEnvDetails.AppName, installedAppAndEnvDetails.EnvironmentName) - start := time.Now() - resp, err := impl.acdClient.ResourceTree(ctx, query) - elapsed := time.Since(start) - impl.Logger.Debugf("Time elapsed %s in fetching application %s for environment %s", elapsed, installedAppAndEnvDetails.AppName, installedAppAndEnvDetails.EnvironmentName) - if err != nil { - impl.Logger.Errorw("error fetching resource tree", "error", err) - err = &util.ApiError{ - Code: constants.AppDetailResourceTreeNotFound, - InternalMessage: "app detail fetched, failed to get resource tree from acd", - UserMessage: "app detail fetched, failed to get resource tree from acd", - } - return "", err - - } - //use this resp.Status to update app_status table - err = impl.appStatusService.UpdateStatusWithAppIdEnvId(installedAppAndEnvDetails.AppId, installedAppAndEnvDetails.EnvironmentId, resp.Status) - if err != nil { - impl.Logger.Warnw("error in updating app status", "err", err, installedAppAndEnvDetails.AppId, "envId", installedAppAndEnvDetails.EnvironmentId) - } - return resp.Status, nil - } - return "", errors.New("invalid app name or env name") -} - func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { err := impl.appStatusService.DeleteWithAppIdEnvId(dbTransaction, installedApps.AppId, installedApps.EnvironmentId) @@ -560,104 +497,6 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetGitOpsRepoName(appName string return impl.appStoreDeploymentFullModeService.GetGitOpsRepoName(appName, environmentName) } -func (impl *AppStoreDeploymentArgoCdServiceImpl) OnUpdateRepoInInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - //creating deployment started status timeline - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, - StatusDetail: "Deployment initiated successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - err := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if err != nil { - impl.Logger.Errorw("error in creating timeline status for deployment initiation for update of installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId) - } - //git operation pull push - appStoreGitOpsResponse, err := impl.appStoreDeploymentCommonService.GenerateManifestAndPerformGitOperations(installAppVersionRequest) - if err != nil { - impl.Logger.Errorw("error in doing gitops operation", "err", err) - _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) - - } - - _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) - - //acd operation register, sync - installAppVersionRequest, err = impl.patchAcdApp(ctx, installAppVersionRequest, appStoreGitOpsResponse.ChartGitAttribute) - if err != nil { - return installAppVersionRequest, err - } - - return installAppVersionRequest, nil -} - -func (impl *AppStoreDeploymentArgoCdServiceImpl) UpdateRequirementDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { - RequirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.Logger.Errorw("error in building requirements config for helm app", "err", err) - return err - } - requirementsGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, RequirementsString, appStoreBean.REQUIREMENTS_YAML_FILE) - if err != nil { - impl.Logger.Errorw("error in getting git config for helm app", "err", err) - return err - } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(requirementsGitConfig) - if err != nil { - impl.Logger.Errorw("error in committing config to git for helm app", "err", err) - return err - } - return nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *clusterRepository.Environment, installedAppVersion *repository.InstalledAppVersions, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - //creating deployment started status timeline when mono repo migration is not required - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, - StatusDetail: "Deployment initiated successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - err := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if err != nil { - impl.Logger.Errorw("error in creating timeline status for deployment initiation for update of installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId) - } - //update values yaml in chart - installAppVersionRequest, err = impl.updateValuesYaml(environment, installedAppVersion, installAppVersionRequest, tx) - if err != nil { - impl.Logger.Errorw("error while commit values to git", "error", err) - noTargetFound, _ := impl.appStoreDeploymentCommonService.ParseGitRepoErrorResponse(err) - if noTargetFound { - //if by mistake no content found while updating git repo, do auto fix - installAppVersionRequest, err = impl.OnUpdateRepoInInstalledApp(ctx, installAppVersionRequest, tx) - if err != nil { - impl.Logger.Errorw("error while update repo on helm update", "error", err) - return nil, err - } - } else { - return nil, err - } - } - installAppVersionRequest.Environment = environment - - //ACD sync operation - //impl.appStoreDeploymentFullModeService.SyncACD(installAppVersionRequest.ACDAppName, ctx) - - return installAppVersionRequest, nil -} - func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() @@ -740,115 +579,3 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteDeploymentApp(ctx context. } return nil } - -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { - if err != nil { - terminalStatusExists, timelineErr := impl.pipelineStatusTimelineRepository.CheckIfTerminalStatusTimelinePresentByInstalledAppVersionHistoryId(installAppVersionRequest.InstalledAppVersionHistoryId) - if timelineErr != nil { - impl.Logger.Errorw("error in checking if terminal status timeline exists by installedAppVersionHistoryId", "err", timelineErr, "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId) - return timelineErr - } - if !terminalStatusExists { - impl.Logger.Infow("marking pipeline deployment failed", "err", err) - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_FAILED, - StatusDetail: fmt.Sprintf("Deployment failed: %v", err), - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: 1, - CreatedOn: time.Now(), - UpdatedBy: 1, - UpdatedOn: time.Now(), - }, - } - isAppStore := true - timelineErr = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, isAppStore) - if timelineErr != nil { - impl.Logger.Errorw("error in creating timeline status for deployment fail", "err", timelineErr, "timeline", timeline) - } - } - impl.Logger.Errorw("error in triggering installed application deployment, setting status as fail ", "versionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId, "err", err) - - installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) - if err != nil { - impl.Logger.Errorw("error in getting installedAppVersionHistory by installedAppVersionHistoryId", "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId, "err", err) - return err - } - installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed - installedAppVersionHistory.FinishedOn = triggeredAt - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) - if err != nil { - impl.Logger.Errorw("error updating installed app version history status", "err", err, "installedAppVersionHistory", installedAppVersionHistory) - return err - } - - } else { - //update [n,n-1] statuses as failed if not terminal - terminalStatus := []string{string(health.HealthStatusHealthy), pipelineConfig.WorkflowAborted, pipelineConfig.WorkflowFailed, pipelineConfig.WorkflowSucceeded} - previousNonTerminalHistory, err := impl.installedAppRepositoryHistory.FindPreviousInstalledAppVersionHistoryByStatus(installAppVersionRequest.Id, installAppVersionRequest.InstalledAppVersionHistoryId, terminalStatus) - if err != nil { - impl.Logger.Errorw("error fetching previous installed app version history, updating installed app version history status,", "err", err, "installAppVersionRequest", installAppVersionRequest) - return err - } else if len(previousNonTerminalHistory) == 0 { - impl.Logger.Errorw("no previous history found in updating installedAppVersionHistory status,", "err", err, "installAppVersionRequest", installAppVersionRequest) - return nil - } - dbConnection := impl.installedAppRepositoryHistory.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - impl.Logger.Errorw("error on update status, txn begin failed", "err", err) - return err - } - // Rollback tx on error. - defer tx.Rollback() - var timelines []*pipelineConfig.PipelineStatusTimeline - for _, previousHistory := range previousNonTerminalHistory { - if previousHistory.Status == string(health.HealthStatusHealthy) || - previousHistory.Status == pipelineConfig.WorkflowSucceeded || - previousHistory.Status == pipelineConfig.WorkflowAborted || - previousHistory.Status == pipelineConfig.WorkflowFailed { - //terminal status return - impl.Logger.Infow("skip updating installedAppVersionHistory status as previous history status is", "status", previousHistory.Status) - continue - } - impl.Logger.Infow("updating installedAppVersionHistory status as previous runner status is", "status", previousHistory.Status) - previousHistory.FinishedOn = triggeredAt - previousHistory.Status = pipelineConfig.WorkflowFailed - previousHistory.UpdatedOn = time.Now() - previousHistory.UpdatedBy = installAppVersionRequest.UserId - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: previousHistory.Id, - Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_SUPERSEDED, - StatusDetail: "This deployment is superseded.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: 1, - CreatedOn: time.Now(), - UpdatedBy: 1, - UpdatedOn: time.Now(), - }, - } - timelines = append(timelines, timeline) - } - - err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistoryWithTxn(previousNonTerminalHistory, tx) - if err != nil { - impl.Logger.Errorw("error updating cd wf runner status", "err", err, "previousNonTerminalHistory", previousNonTerminalHistory) - return err - } - err = impl.pipelineStatusTimelineRepository.SaveTimelinesWithTxn(timelines, tx) - if err != nil { - impl.Logger.Errorw("error updating pipeline status timelines", "err", err, "timelines", timelines) - return err - } - err = tx.Commit() - if err != nil { - impl.Logger.Errorw("error in db transaction commit", "err", err) - return err - } - } - return nil -} diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index 9716abb607..fd94dbad26 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -4,18 +4,15 @@ import ( "context" "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "net/http" "time" client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" - "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" "go.opentelemetry.io/otel" "go.uber.org/zap" @@ -24,18 +21,11 @@ import ( type AppStoreDeploymentHelmService interface { InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - GetGitOpsRepoName(appName string, environmentName string) (string, error) - OnUpdateRepoInInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - UpdateRequirementDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error - UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *clusterRepository.Environment, installedAppVersion *repository.InstalledAppVersions, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error - UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error - SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error } @@ -43,7 +33,6 @@ type AppStoreDeploymentHelmServiceImpl struct { Logger *zap.SugaredLogger helmAppService client.HelmAppService appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository clusterRepository.EnvironmentRepository helmAppClient client.HelmAppClient installedAppRepository repository.InstalledAppRepository appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService @@ -51,12 +40,11 @@ type AppStoreDeploymentHelmServiceImpl struct { } func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository clusterRepository.EnvironmentRepository, helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentHelmServiceImpl { + helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, helmAppClient: helmAppClient, installedAppRepository: installedAppRepository, appStoreDeploymentCommonService: appStoreDeploymentCommonService, @@ -138,38 +126,6 @@ func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionReques return installAppVersionRequest, nil } -func (impl AppStoreDeploymentHelmServiceImpl) GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) { - - environment, err := impl.environmentRepository.FindById(installedAppAndEnvDetails.EnvironmentId) - if err != nil { - impl.Logger.Errorw("Error in getting environment", "err", err) - return "", err - } - - appIdentifier := &client.AppIdentifier{ - ClusterId: environment.ClusterId, - Namespace: environment.Namespace, - ReleaseName: installedAppAndEnvDetails.AppName, - } - - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) - defer cancel() - - appDetail, err := impl.helmAppService.GetApplicationDetail(ctx, appIdentifier) - if err != nil { - // handling like argocd - impl.Logger.Errorw("error fetching helm app resource tree", "error", err, "appIdentifier", appIdentifier) - err = &util.ApiError{ - Code: constants.AppDetailResourceTreeNotFound, - InternalMessage: "Failed to get resource tree from helm", - UserMessage: "Failed to get resource tree from helm", - } - return "", err - } - - return appDetail.ApplicationStatus, nil -} - func (impl AppStoreDeploymentHelmServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { if installAppVersionRequest.ForceDelete { return nil @@ -294,42 +250,6 @@ func (impl *AppStoreDeploymentHelmServiceImpl) GetGitOpsRepoName(appName string, return "", errors.New("method GetGitOpsRepoName not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) OnUpdateRepoInInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - //TODO: gitOps operations here based on flag - if installAppVersionRequest.PerformGitOpsForHelmApp { - _, err := impl.appStoreDeploymentCommonService.GenerateManifestAndPerformGitOperations(installAppVersionRequest) - if err != nil { - return installAppVersionRequest, err - } - } - - err := impl.updateApplicationWithChartInfo(ctx, installAppVersionRequest.InstalledAppId, installAppVersionRequest.AppStoreVersion, installAppVersionRequest.ValuesOverrideYaml, installAppVersionRequest.InstalledAppVersionHistoryId) - if err != nil { - return installAppVersionRequest, err - } - return installAppVersionRequest, err -} - -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateRequirementDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { - RequirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.Logger.Errorw("error in building requirements config for helm app", "err", err) - return err - } - requirementsGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, RequirementsString, appStoreBean.REQUIREMENTS_YAML_FILE) - if err != nil { - impl.Logger.Errorw("error in getting git config for helm app", "err", err) - return err - } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(requirementsGitConfig) - if err != nil { - impl.Logger.Errorw("error in committing config to git for helm app", "err", err) - return err - } - return nil - //return errors.New("method UpdateRequirementDependencies not implemented") -} - func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { @@ -354,37 +274,6 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installA return nil } -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *clusterRepository.Environment, installedAppVersion *repository.InstalledAppVersions, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - - noTargetFound := false - - if installAppVersionRequest.PerformGitOps { - err := impl.UpdateValuesDependencies(installAppVersionRequest) - if err != nil { - impl.Logger.Errorw("error while commit values to git", "error", err) - noTargetFound, _ = impl.appStoreDeploymentCommonService.ParseGitRepoErrorResponse(err) - if noTargetFound { - //if by mistake no content found while updating git repo, do auto fix - installAppVersionRequest, err = impl.OnUpdateRepoInInstalledApp(ctx, installAppVersionRequest, tx) - if err != nil { - impl.Logger.Errorw("error while update repo on helm update", "error", err) - return nil, err - } - } else { - return nil, err - } - } - } - if !noTargetFound { - // update chart application already called, hence skipping - err := impl.updateApplicationWithChartInfo(ctx, installAppVersionRequest.InstalledAppId, installAppVersionRequest.AppStoreVersion, installAppVersionRequest.ValuesOverrideYaml, 0) - if err != nil { - return nil, err - } - } - return installAppVersionRequest, nil -} - func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ctx context.Context, installedAppId int, appStoreApplicationVersionId int, valuesOverrideYaml string, installAppVersionHistoryId int) error { installedApp, err := impl.installedAppRepository.GetInstalledApp(installedAppId) diff --git a/pkg/appStore/deployment/tool/DeploymentStatusService.go b/pkg/appStore/deployment/tool/DeploymentStatusService.go new file mode 100644 index 0000000000..fe2de9c816 --- /dev/null +++ b/pkg/appStore/deployment/tool/DeploymentStatusService.go @@ -0,0 +1,122 @@ +package appStoreDeploymentTool + +import ( + "fmt" + "github.com/devtron-labs/common-lib/utils/k8s/health" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/sql" + "time" +) + +func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { + if err != nil { + terminalStatusExists, timelineErr := impl.pipelineStatusTimelineRepository.CheckIfTerminalStatusTimelinePresentByInstalledAppVersionHistoryId(installAppVersionRequest.InstalledAppVersionHistoryId) + if timelineErr != nil { + impl.Logger.Errorw("error in checking if terminal status timeline exists by installedAppVersionHistoryId", "err", timelineErr, "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId) + return timelineErr + } + if !terminalStatusExists { + impl.Logger.Infow("marking pipeline deployment failed", "err", err) + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, + Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_FAILED, + StatusDetail: fmt.Sprintf("Deployment failed: %v", err), + StatusTime: time.Now(), + AuditLog: sql.AuditLog{ + CreatedBy: 1, + CreatedOn: time.Now(), + UpdatedBy: 1, + UpdatedOn: time.Now(), + }, + } + isAppStore := true + timelineErr = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, isAppStore) + if timelineErr != nil { + impl.Logger.Errorw("error in creating timeline status for deployment fail", "err", timelineErr, "timeline", timeline) + } + } + impl.Logger.Errorw("error in triggering installed application deployment, setting status as fail ", "versionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId, "err", err) + + installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) + if err != nil { + impl.Logger.Errorw("error in getting installedAppVersionHistory by installedAppVersionHistoryId", "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId, "err", err) + return err + } + installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed + installedAppVersionHistory.FinishedOn = triggeredAt + installedAppVersionHistory.UpdatedOn = time.Now() + installedAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId + _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) + if err != nil { + impl.Logger.Errorw("error updating installed app version history status", "err", err, "installedAppVersionHistory", installedAppVersionHistory) + return err + } + + } else { + //update [n,n-1] statuses as failed if not terminal + terminalStatus := []string{string(health.HealthStatusHealthy), pipelineConfig.WorkflowAborted, pipelineConfig.WorkflowFailed, pipelineConfig.WorkflowSucceeded} + previousNonTerminalHistory, err := impl.installedAppRepositoryHistory.FindPreviousInstalledAppVersionHistoryByStatus(installAppVersionRequest.Id, installAppVersionRequest.InstalledAppVersionHistoryId, terminalStatus) + if err != nil { + impl.Logger.Errorw("error fetching previous installed app version history, updating installed app version history status,", "err", err, "installAppVersionRequest", installAppVersionRequest) + return err + } else if len(previousNonTerminalHistory) == 0 { + impl.Logger.Errorw("no previous history found in updating installedAppVersionHistory status,", "err", err, "installAppVersionRequest", installAppVersionRequest) + return nil + } + dbConnection := impl.installedAppRepositoryHistory.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + impl.Logger.Errorw("error on update status, txn begin failed", "err", err) + return err + } + // Rollback tx on error. + defer tx.Rollback() + var timelines []*pipelineConfig.PipelineStatusTimeline + for _, previousHistory := range previousNonTerminalHistory { + if previousHistory.Status == string(health.HealthStatusHealthy) || + previousHistory.Status == pipelineConfig.WorkflowSucceeded || + previousHistory.Status == pipelineConfig.WorkflowAborted || + previousHistory.Status == pipelineConfig.WorkflowFailed { + //terminal status return + impl.Logger.Infow("skip updating installedAppVersionHistory status as previous history status is", "status", previousHistory.Status) + continue + } + impl.Logger.Infow("updating installedAppVersionHistory status as previous runner status is", "status", previousHistory.Status) + previousHistory.FinishedOn = triggeredAt + previousHistory.Status = pipelineConfig.WorkflowFailed + previousHistory.UpdatedOn = time.Now() + previousHistory.UpdatedBy = installAppVersionRequest.UserId + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: previousHistory.Id, + Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_SUPERSEDED, + StatusDetail: "This deployment is superseded.", + StatusTime: time.Now(), + AuditLog: sql.AuditLog{ + CreatedBy: 1, + CreatedOn: time.Now(), + UpdatedBy: 1, + UpdatedOn: time.Now(), + }, + } + timelines = append(timelines, timeline) + } + + err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistoryWithTxn(previousNonTerminalHistory, tx) + if err != nil { + impl.Logger.Errorw("error updating cd wf runner status", "err", err, "previousNonTerminalHistory", previousNonTerminalHistory) + return err + } + err = impl.pipelineStatusTimelineRepository.SaveTimelinesWithTxn(timelines, tx) + if err != nil { + impl.Logger.Errorw("error updating pipeline status timelines", "err", err, "timelines", timelines) + return err + } + err = tx.Commit() + if err != nil { + impl.Logger.Errorw("error in db transaction commit", "err", err) + return err + } + } + return nil +} diff --git a/scripts/sql/210_unused_integration.up.sql b/scripts/sql/211_unused_integration.up.sql similarity index 100% rename from scripts/sql/210_unused_integration.up.sql rename to scripts/sql/211_unused_integration.up.sql diff --git a/scripts/sql/210_unused_intergration.down.sql b/scripts/sql/211_unused_intergration.down.sql similarity index 100% rename from scripts/sql/210_unused_intergration.down.sql rename to scripts/sql/211_unused_intergration.down.sql diff --git a/wire_gen.go b/wire_gen.go index e871688b17..a0bd21ec8a 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -61,7 +61,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" repository5 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository13 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + repository14 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" "github.com/devtron-labs/devtron/internal/sql/repository/security" @@ -74,13 +74,14 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone/batch" appStatus2 "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" + repository11 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service3 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" @@ -116,7 +117,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository14 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository15 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -125,10 +126,10 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/history" repository6 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - repository11 "github.com/devtron-labs/devtron/pkg/pipeline/repository" + repository12 "github.com/devtron-labs/devtron/pkg/pipeline/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" - repository12 "github.com/devtron-labs/devtron/pkg/plugin/repository" + repository13 "github.com/devtron-labs/devtron/pkg/plugin/repository" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" security2 "github.com/devtron-labs/devtron/pkg/security" @@ -401,26 +402,26 @@ func InitializeApp() (*App, error) { return nil, err } appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) - chartGroupDeploymentRepositoryImpl := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + chartGroupDeploymentRepositoryImpl := repository11.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) refChartProxyDir := _wireRefChartProxyDirValue appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, refChartProxyDir, gitFactory, gitOpsConfigRepositoryImpl) ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, refChartProxyDir, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, applicationServiceClientImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, globalEnvVariables, installedAppRepositoryImpl, tokenCache, argoUserServiceImpl, gitOpsConfigRepositoryImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, chartTemplateServiceImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, gitOpsConfigRepositoryImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) + appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, repositoryServiceClientImpl, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, gitFactory, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, userServiceImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) deploymentServiceTypeConfig, err := service.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) + appStoreDeploymentServiceImpl := service.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) - manifestPushConfigRepositoryImpl := repository11.NewManifestPushConfigRepository(sugaredLogger, db) + manifestPushConfigRepositoryImpl := repository12.NewManifestPushConfigRepository(sugaredLogger, db) gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, chartServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig) appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) validate, err := util.IntValidator() @@ -454,8 +455,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - pipelineStageRepositoryImpl := repository11.NewPipelineStageRepository(sugaredLogger, db) - globalPluginRepositoryImpl := repository12.NewGlobalPluginRepository(sugaredLogger, db) + pipelineStageRepositoryImpl := repository12.NewPipelineStageRepository(sugaredLogger, db) + globalPluginRepositoryImpl := repository13.NewGlobalPluginRepository(sugaredLogger, db) pipelineStageServiceImpl := pipeline.NewPipelineStageService(sugaredLogger, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, pipelineRepositoryImpl, scopedVariableManagerImpl) globalPluginServiceImpl := plugin.NewGlobalPluginService(sugaredLogger, globalPluginRepositoryImpl, pipelineStageRepositoryImpl) dockerRegistryConfigImpl := pipeline.NewDockerRegistryConfigImpl(sugaredLogger, helmAppServiceImpl, dockerArtifactStoreRepositoryImpl, dockerRegistryIpsConfigRepositoryImpl, ociRegistryConfigRepositoryImpl) @@ -493,7 +494,7 @@ func InitializeApp() (*App, error) { buildPipelineSwitchServiceImpl := pipeline.NewBuildPipelineSwitchServiceImpl(sugaredLogger, ciPipelineRepositoryImpl, ciCdPipelineOrchestratorImpl, pipelineRepositoryImpl, ciWorkflowRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineHistoryServiceImpl, ciTemplateOverrideRepositoryImpl, ciPipelineMaterialRepositoryImpl) ciPipelineConfigServiceImpl := pipeline.NewCiPipelineConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, dockerArtifactStoreRepositoryImpl, materialRepositoryImpl, appRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ecrConfig, appWorkflowRepositoryImpl, ciCdConfig, attributesServiceImpl, pipelineStageServiceImpl, ciPipelineMaterialRepositoryImpl, ciTemplateServiceImpl, ciTemplateOverrideRepositoryImpl, ciTemplateHistoryServiceImpl, enforcerUtilImpl, ciWorkflowRepositoryImpl, resourceGroupServiceImpl, customTagServiceImpl, ciPipelineHistoryServiceImpl, cdWorkflowRepositoryImpl, buildPipelineSwitchServiceImpl) ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) - imageTaggingRepositoryImpl := repository13.NewImageTaggingRepositoryImpl(db) + imageTaggingRepositoryImpl := repository14.NewImageTaggingRepositoryImpl(db) imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) chartDeploymentServiceImpl := util.NewChartDeploymentServiceImpl(sugaredLogger, repositoryServiceClientImpl) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, envLevelAppMetricsRepositoryImpl, appLevelMetricsRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl) @@ -540,7 +541,7 @@ func InitializeApp() (*App, error) { pipelineConfigRouterImpl := router.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, appWorkflowRestHandlerImpl, webhookDataRestHandlerImpl, pipelineHistoryRestHandlerImpl, pipelineStatusTimelineRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) - k8sResourceHistoryRepositoryImpl := repository14.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) @@ -549,7 +550,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartTemplateServiceImpl, refChartProxyDir, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, attributesRepositoryImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, appStoreDeploymentArgoCdServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig) + installedAppServiceImpl, err := service.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig) if err != nil { return nil, err } @@ -667,9 +668,9 @@ func InitializeApp() (*App, error) { workflowActionImpl := batch.NewWorkflowActionImpl(sugaredLogger, appRepositoryImpl, appWorkflowServiceImpl, buildActionImpl, deploymentActionImpl) batchOperationRestHandlerImpl := restHandler.NewBatchOperationRestHandlerImpl(userServiceImpl, enforcerImpl, workflowActionImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, argoUserServiceImpl) batchOperationRouterImpl := router.NewBatchOperationRouterImpl(batchOperationRestHandlerImpl, sugaredLogger) - chartGroupEntriesRepositoryImpl := repository3.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) - chartGroupReposotoryImpl := repository3.NewChartGroupReposotoryImpl(db, sugaredLogger) - chartGroupServiceImpl := service.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) + chartGroupEntriesRepositoryImpl := repository11.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) + chartGroupReposotoryImpl := repository11.NewChartGroupReposotoryImpl(db, sugaredLogger) + chartGroupServiceImpl := chartGroup.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) chartGroupRestHandlerImpl := restHandler.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) chartGroupRouterImpl := router.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) scanToolExecutionHistoryMappingRepositoryImpl := security.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) From 9e36312c0a677ee7376f3ed69eea76e38aa01a68 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 18:00:51 +0530 Subject: [PATCH 06/83] chart ref refactoring --- Wire.go | 12 +- api/chartRepo/ChartRepositoryRestHandler.go | 7 +- api/deployment/DeploymentConfigRestHandler.go | 47 +- api/restHandler/ChartRefRestHandler.go | 15 +- .../app/DeploymentPipelineRestHandler.go | 9 +- .../app/PipelineConfigRestHandler.go | 10 +- cmd/external-app/wire.go | 6 - cmd/external-app/wire_gen.go | 17 +- internal/util/ChartService.go | 28 +- pkg/app/AppService.go | 139 +---- pkg/app/ManifestPushService.go | 12 +- pkg/app/integrationTest/AppService_test.go | 3 +- pkg/appStore/bean/bean.go | 4 + .../common/AppStoreDeploymentCommonService.go | 5 +- .../AppStoreDeploymentFullModeService.go | 6 +- .../deployment/service/InstalledAppService.go | 16 +- .../service/InstalledAppService_test.go | 9 +- pkg/bulkAction/BulkUpdateService.go | 57 +- pkg/chart/ChartCompatibility_test.go | 18 +- pkg/chart/ChartService.go | 558 ++---------------- pkg/chart/ChartUtils.go | 21 +- pkg/chart/bean.go | 5 - .../repository/ChartRefRepository.go | 5 +- .../deployedAppMetrics/DeployedAppMetrics.go | 12 +- .../chartRef}/ChartCompatibility.go | 14 +- .../chartRef/ChartRefService.go | 494 ++++++++++++++++ .../chartRef/adapter/adapter.go | 45 ++ .../deploymentTemplate/chartRef/bean/bean.go | 95 +++ .../manifest/wire_deployment_manifest.go | 17 + .../DeployementTemplateService.go | 7 +- pkg/pipeline/DeploymentConfigService.go | 17 +- pkg/pipeline/PropertiesConfig.go | 14 - pkg/pipeline/WorkflowDagExecutor.go | 43 +- .../DeploymentTemplateHistoryService.go | 46 +- wire_gen.go | 256 ++++---- 35 files changed, 989 insertions(+), 1080 deletions(-) rename pkg/{chart => deployment/manifest/deploymentTemplate/chartRef}/ChartCompatibility.go (67%) create mode 100644 pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go create mode 100644 pkg/deployment/manifest/deploymentTemplate/chartRef/adapter/adapter.go create mode 100644 pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go create mode 100644 pkg/deployment/manifest/wire_deployment_manifest.go diff --git a/Wire.go b/Wire.go index b4ef34b994..0625125515 100644 --- a/Wire.go +++ b/Wire.go @@ -85,7 +85,6 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone" "github.com/devtron-labs/devtron/pkg/appClone/batch" "github.com/devtron-labs/devtron/pkg/appStatus" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" @@ -97,7 +96,7 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" - "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -158,6 +157,8 @@ func InitializeApp() (*App, error) { apiToken.ApiTokenWireSet, webhookHelm.WebhookHelmWireSet, terminal.TerminalWireSet, + manifest.DeploymentManifestWireSet, + // -------wireset end ---------- //------- gitSensor.GetConfig, @@ -171,10 +172,6 @@ func InitializeApp() (*App, error) { //sql.NewDbConnection, //app.GetACDAuthConfig, util3.GetACDAuthConfig, - wire.Value(chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts")), - wire.Value(appStoreBean.RefChartProxyDir("scripts/devtron-reference-helm-charts")), - wire.Value(chart.DefaultChart("reference-app-rolling")), - wire.Value(util.ChartWorkingDir("/tmp/charts/")), connection.SettingsManager, //auth.GetConfig, @@ -290,9 +287,6 @@ func InitializeApp() (*App, error) { //end - deployedAppMetrics.NewDeployedAppMetricsServiceImpl, - wire.Bind(new(deployedAppMetrics.DeployedAppMetricsService), new(*deployedAppMetrics.DeployedAppMetricsServiceImpl)), - chart.NewChartServiceImpl, wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)), bulkAction.NewBulkUpdateServiceImpl, diff --git a/api/chartRepo/ChartRepositoryRestHandler.go b/api/chartRepo/ChartRepositoryRestHandler.go index 495fa5b2bb..b7c0486d5f 100644 --- a/api/chartRepo/ChartRepositoryRestHandler.go +++ b/api/chartRepo/ChartRepositoryRestHandler.go @@ -30,7 +30,6 @@ import ( "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/chartRepo" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/gorilla/mux" "go.uber.org/zap" @@ -64,14 +63,12 @@ type ChartRepositoryRestHandlerImpl struct { enforcer casbin.Enforcer validator *validator.Validate deleteService delete2.DeleteService - chartRefRepository chartRepoRepository.ChartRefRepository - refChartDir chartRepoRepository.RefChartDir attributesService attributes.AttributesService } func NewChartRepositoryRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, chartRepositoryService chartRepo.ChartRepositoryService, enforcer casbin.Enforcer, validator *validator.Validate, deleteService delete2.DeleteService, - chartRefRepository chartRepoRepository.ChartRefRepository, refChartDir chartRepoRepository.RefChartDir, attributesService attributes.AttributesService) *ChartRepositoryRestHandlerImpl { + attributesService attributes.AttributesService) *ChartRepositoryRestHandlerImpl { return &ChartRepositoryRestHandlerImpl{ Logger: Logger, chartRepositoryService: chartRepositoryService, @@ -79,8 +76,6 @@ func NewChartRepositoryRestHandlerImpl(Logger *zap.SugaredLogger, userAuthServic enforcer: enforcer, validator: validator, deleteService: deleteService, - chartRefRepository: chartRefRepository, - refChartDir: refChartDir, attributesService: attributesService, } } diff --git a/api/deployment/DeploymentConfigRestHandler.go b/api/deployment/DeploymentConfigRestHandler.go index 53be9a4b6a..d9d819959e 100644 --- a/api/deployment/DeploymentConfigRestHandler.go +++ b/api/deployment/DeploymentConfigRestHandler.go @@ -3,6 +3,8 @@ package deployment import ( "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "io/ioutil" "net/http" "os" @@ -20,7 +22,6 @@ import ( "github.com/gorilla/mux" "github.com/juju/errors" "go.uber.org/zap" - "gopkg.in/go-playground/validator.v9" ) type DeploymentConfigRestHandler interface { @@ -34,10 +35,8 @@ type DeploymentConfigRestHandlerImpl struct { Logger *zap.SugaredLogger userAuthService user.UserService enforcer casbin.Enforcer - validator *validator.Validate - refChartDir chartRepoRepository.RefChartDir - chartService chart.ChartService - chartRefRepository chartRepoRepository.ChartRefRepository + chartService chart.ChartService + chartRefService chartRef.ChartRefService } type DeploymentChartInfo struct { @@ -49,16 +48,14 @@ type DeploymentChartInfo struct { Message string `json:"message"` } -func NewDeploymentConfigRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, enforcer casbin.Enforcer, validator *validator.Validate, - refChartDir chartRepoRepository.RefChartDir, chartService chart.ChartService, chartRefRepository chartRepoRepository.ChartRefRepository) *DeploymentConfigRestHandlerImpl { +func NewDeploymentConfigRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, enforcer casbin.Enforcer, + chartService chart.ChartService, chartRefService chartRef.ChartRefService) *DeploymentConfigRestHandlerImpl { return &DeploymentConfigRestHandlerImpl{ - Logger: Logger, - userAuthService: userAuthService, - enforcer: enforcer, - validator: validator, - refChartDir: refChartDir, - chartService: chartService, - chartRefRepository: chartRefRepository, + Logger: Logger, + userAuthService: userAuthService, + enforcer: enforcer, + chartService: chartService, + chartRefService: chartRefService, } } @@ -102,7 +99,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo return } - chartInfo, err := handler.chartService.ExtractChartIfMissing(fileBytes, string(handler.refChartDir), "") + chartInfo, err := handler.chartRefService.ExtractChartIfMissing(fileBytes, chartRepoRepository.RefChartDirPath, "") if err != nil { if chartInfo != nil && chartInfo.TemporaryFolder != "" { @@ -111,7 +108,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo handler.Logger.Errorw("error in deleting temp dir ", "err", err1) } } - if err.Error() == chart.CHART_ALREADY_EXISTS_INTERNAL_ERROR || err.Error() == chart.CHART_NAME_RESERVED_INTERNAL_ERROR { + if err.Error() == bean.CHART_ALREADY_EXISTS_INTERNAL_ERROR || err.Error() == bean.CHART_NAME_RESERVED_INTERNAL_ERROR { common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } @@ -119,7 +116,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo return } - chartRefs := &chartRepoRepository.ChartRef{ + chartRefs := &bean.CustomChartRefDto{ Name: chartInfo.ChartName, Version: chartInfo.ChartVersion, Location: chartInfo.ChartLocation, @@ -178,7 +175,7 @@ func (handler *DeploymentConfigRestHandlerImpl) SaveChart(w http.ResponseWriter, return } - location := filepath.Join(string(handler.refChartDir), request.FileId) + location := filepath.Join(chartRepoRepository.RefChartDirPath, request.FileId) if request.Action == "Save" { file, err := ioutil.ReadFile(filepath.Join(location, "output.json")) if err != nil { @@ -186,17 +183,17 @@ func (handler *DeploymentConfigRestHandlerImpl) SaveChart(w http.ResponseWriter, common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - chartRefs := &chartRepoRepository.ChartRef{} - err = json.Unmarshal(file, &chartRefs) + customChartRefDto := &bean.CustomChartRefDto{} + err = json.Unmarshal(file, &customChartRefDto) if err != nil { handler.Logger.Errorw("unmarshall err", "err", err) common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - chartRefs.ChartDescription = request.Description - err = handler.chartRefRepository.Save(chartRefs) + customChartRefDto.ChartDescription = request.Description + err = handler.chartRefService.SaveCustomChart(customChartRefDto) if err != nil { - handler.Logger.Errorw("error in saving Chart", "err", err) + handler.Logger.Errorw("error in saving Chart", "err", err, "request", customChartRefDto) common.WriteJsonResp(w, err, "Chart couldn't be saved", http.StatusInternalServerError) return } @@ -234,7 +231,7 @@ func (handler *DeploymentConfigRestHandlerImpl) DownloadChart(w http.ResponseWri common.WriteJsonResp(w, fmt.Errorf("error in parsing chartRefId : %s must be integer", chartRefId), nil, http.StatusBadRequest) return } - manifestByteArr, err := handler.chartService.GetCustomChartInBytes(chartRefId) + manifestByteArr, err := handler.chartRefService.GetCustomChartInBytes(chartRefId) if err != nil { handler.Logger.Errorw("error in converting chart to bytes", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -258,7 +255,7 @@ func (handler *DeploymentConfigRestHandlerImpl) GetUploadedCharts(w http.Respons return } - charts, err := handler.chartService.FetchCustomChartsInfo() + charts, err := handler.chartRefService.FetchCustomChartsInfo() if err != nil { common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return diff --git a/api/restHandler/ChartRefRestHandler.go b/api/restHandler/ChartRefRestHandler.go index 9e85cdc09c..decebfbfe7 100644 --- a/api/restHandler/ChartRefRestHandler.go +++ b/api/restHandler/ChartRefRestHandler.go @@ -19,7 +19,8 @@ package restHandler import ( "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/chart" + chartService "github.com/devtron-labs/devtron/pkg/chart" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/gorilla/mux" "go.uber.org/zap" "net/http" @@ -33,17 +34,19 @@ type ChartRefRestHandler interface { } type ChartRefRestHandlerImpl struct { - chartService chart.ChartService - logger *zap.SugaredLogger + logger *zap.SugaredLogger + chartRefService chartRef.ChartRefService + chartService chartService.ChartService } -func NewChartRefRestHandlerImpl(chartService chart.ChartService, logger *zap.SugaredLogger) *ChartRefRestHandlerImpl { - handler := &ChartRefRestHandlerImpl{chartService: chartService, logger: logger} +func NewChartRefRestHandlerImpl(logger *zap.SugaredLogger, chartRefService chartRef.ChartRefService, + chartService chartService.ChartService) *ChartRefRestHandlerImpl { + handler := &ChartRefRestHandlerImpl{logger: logger, chartRefService: chartRefService, chartService: chartService} return handler } func (handler ChartRefRestHandlerImpl) ChartRefAutocomplete(w http.ResponseWriter, r *http.Request) { - result, err := handler.chartService.ChartRefAutocomplete() + result, err := handler.chartRefService.ChartRefAutocomplete() if err != nil { handler.logger.Errorw("service err, ChartRefAutocomplete", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 6516880e78..8889f2d5ea 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + bean4 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "io" "net/http" "strconv" @@ -185,7 +186,7 @@ func (handler PipelineConfigRestHandlerImpl) CreateCdPipeline(w http.ResponseWri return } handler.Logger.Infow("request payload, CreateCdPipeline", "payload", cdPipeline) - userUploaded, err := handler.chartService.CheckCustomChartByAppId(cdPipeline.AppId) + userUploaded, err := handler.chartService.CheckIfChartRefUserUploadedByAppId(cdPipeline.AppId) if !userUploaded { err = handler.validator.Struct(cdPipeline) if err != nil { @@ -541,7 +542,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite common.WriteJsonResp(w, err, "specific environment is not overriden", http.StatusUnprocessableEntity) return } - compatible, oldChartType, newChartType := handler.chartService.ChartRefIdsCompatible(envConfigProperties.ChartRefId, request.TargetChartRefId) + compatible, oldChartType, newChartType := handler.chartRefService.ChartRefIdsCompatible(envConfigProperties.ChartRefId, request.TargetChartRefId) if !compatible { common.WriteJsonResp(w, fmt.Errorf("charts not compatible"), "chart not compatible", http.StatusUnprocessableEntity) return @@ -553,7 +554,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite return } - if newChartType == chart.RolloutChartType { + if newChartType == bean4.RolloutChartType { enabled, err := handler.chartService.FlaggerCanaryEnabled(envConfigProperties.EnvOverrideValues) if err != nil || enabled { handler.Logger.Errorw("rollout charts do not support flaggerCanary, ChangeChartRef", "err", err, "payload", request) @@ -989,7 +990,7 @@ func (handler PipelineConfigRestHandlerImpl) GetDeploymentTemplate(w http.Respon appConfigResponse := make(map[string]interface{}) appConfigResponse["globalConfig"] = nil - err = handler.chartService.CheckChartExists(chartRefId) + err = handler.chartRefService.CheckChartExists(chartRefId) if err != nil { handler.Logger.Errorw("refChartDir Not Found err, JsonSchemaExtractFromFile", err) common.WriteJsonResp(w, err, nil, http.StatusForbidden) diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/PipelineConfigRestHandler.go index 13ff4f3e37..d58c9464d5 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/PipelineConfigRestHandler.go @@ -23,6 +23,7 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "io" "net/http" "strconv" @@ -43,7 +44,6 @@ import ( "go.opentelemetry.io/otel" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/security" @@ -110,7 +110,6 @@ type PipelineConfigRestHandlerImpl struct { chartService chart.ChartService propertiesConfigService pipeline.PropertiesConfigService dbMigrationService pipeline.DbMigrationService - application application.ServiceClient userAuthService user.UserService validator *validator.Validate teamService team.TeamService @@ -134,13 +133,13 @@ type PipelineConfigRestHandlerImpl struct { pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig ciArtifactRepository repository.CiArtifactRepository deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger, chartService chart.ChartService, propertiesConfigService pipeline.PropertiesConfigService, dbMigrationService pipeline.DbMigrationService, - application application.ServiceClient, userAuthService user.UserService, teamService team.TeamService, enforcer casbin.Enforcer, @@ -159,7 +158,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger argoUserService argo.ArgoUserService, ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, imageTaggingService pipeline.ImageTaggingService, ciArtifactRepository repository.CiArtifactRepository, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *PipelineConfigRestHandlerImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) *PipelineConfigRestHandlerImpl { envConfig := &PipelineRestHandlerEnvConfig{} err := env.Parse(envConfig) if err != nil { @@ -171,7 +171,6 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger chartService: chartService, propertiesConfigService: propertiesConfigService, dbMigrationService: dbMigrationService, - application: application, userAuthService: userAuthService, validator: validator, teamService: teamService, @@ -198,6 +197,7 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger pipelineRestHandlerEnvConfig: envConfig, ciArtifactRepository: ciArtifactRepository, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } } diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 044f9c0d98..45c6a0f225 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -38,12 +38,10 @@ import ( security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" "github.com/devtron-labs/devtron/pkg/attributes" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" @@ -140,8 +138,6 @@ func InitializeApp() (*App, error) { // binding gitops to helm (for hyperion) wire.Bind(new(appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentTool.AppStoreDeploymentHelmServiceImpl)), - wire.Value(chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts")), - router.NewTelemetryRouterImpl, wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), restHandler.NewTelemetryRestHandlerImpl, @@ -179,8 +175,6 @@ func InitializeApp() (*App, error) { util.NewChartTemplateServiceImpl, wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - wire.Value(util.ChartWorkingDir("/tmp/charts/")), - wire.Value(appStoreBean.RefChartProxyDir("scripts/devtron-reference-helm-charts")), util.NewGitFactory, util.NewGitCliUtil, diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index c95ee93e35..de881eb3d0 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -45,7 +45,6 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" - "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" @@ -229,7 +228,6 @@ func InitializeApp() (*App, error) { return nil, err } dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) - chartWorkingDir := _wireChartWorkingDirValue gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) gitCliUtil := util.NewGitCliUtil(sugaredLogger) gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) @@ -241,9 +239,8 @@ func InitializeApp() (*App, error) { return nil, err } chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) - chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, chartWorkingDir, httpClient, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) - refChartProxyDir := _wireRefChartProxyDirValue - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, refChartProxyDir, gitFactory, gitOpsConfigRepositoryImpl) + chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigRepositoryImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) @@ -263,9 +260,7 @@ func InitializeApp() (*App, error) { enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) k8sApplicationRestHandlerImpl := application2.NewK8sApplicationRestHandlerImpl(sugaredLogger, k8sApplicationServiceImpl, pumpImpl, terminalSessionHandlerImpl, enforcerImpl, enforcerUtilHelmImpl, enforcerUtilImpl, helmAppServiceImpl, userServiceImpl, k8sCommonServiceImpl, validate) k8sApplicationRouterImpl := application2.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) - chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) - refChartDir := _wireRefChartDirValue - chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceImpl, chartRefRepositoryImpl, refChartDir, attributesServiceImpl) + chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceImpl, attributesServiceImpl) chartRepositoryRouterImpl := chartRepo2.NewChartRepositoryRouterImpl(chartRepositoryRestHandlerImpl) appStoreServiceImpl := service.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) appStoreRestHandlerImpl := appStoreDiscover.NewAppStoreRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreServiceImpl, enforcerImpl) @@ -384,9 +379,3 @@ func InitializeApp() (*App, error) { mainApp := NewApp(db, sessionManager, muxRouter, telemetryEventClientImpl, posthogClient, sugaredLogger) return mainApp, nil } - -var ( - _wireChartWorkingDirValue = util.ChartWorkingDir("/tmp/charts/") - _wireRefChartProxyDirValue = appStoreBean.RefChartProxyDir("scripts/devtron-reference-helm-charts") - _wireRefChartDirValue = chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts") -) diff --git a/internal/util/ChartService.go b/internal/util/ChartService.go index e3329be2f5..2deb276c30 100644 --- a/internal/util/ChartService.go +++ b/internal/util/ChartService.go @@ -23,7 +23,6 @@ import ( "fmt" "io/ioutil" "math/rand" - "net/http" "os" "path/filepath" "regexp" @@ -48,11 +47,12 @@ import ( "sigs.k8s.io/yaml" ) -type ChartWorkingDir string - -const PIPELINE_DEPLOYMENT_TYPE_ACD string = "argo_cd" -const PIPELINE_DEPLOYMENT_TYPE_HELM string = "helm" -const PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD string = "manifest_download" +const ( + PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd" + PIPELINE_DEPLOYMENT_TYPE_HELM = "helm" + PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD = "manifest_download" + ChartWorkingDirPath = "/tmp/charts/" +) type ChartCreateRequest struct { ChartMetaData *chart.Metadata @@ -89,9 +89,7 @@ type ChartTemplateService interface { type ChartTemplateServiceImpl struct { randSource rand.Source logger *zap.SugaredLogger - chartWorkingDir ChartWorkingDir gitFactory *GitFactory - client *http.Client globalEnvVariables *util.GlobalEnvVariables gitOpsConfigRepository repository.GitOpsConfigRepository userRepository repository2.UserRepository @@ -108,16 +106,12 @@ type ChartValues struct { } func NewChartTemplateServiceImpl(logger *zap.SugaredLogger, - chartWorkingDir ChartWorkingDir, - client *http.Client, gitFactory *GitFactory, globalEnvVariables *util.GlobalEnvVariables, gitOpsConfigRepository repository.GitOpsConfigRepository, userRepository repository2.UserRepository, chartRepository chartRepoRepository.ChartRepository) *ChartTemplateServiceImpl { return &ChartTemplateServiceImpl{ randSource: rand.NewSource(time.Now().UnixNano()), logger: logger, - chartWorkingDir: chartWorkingDir, - client: client, gitFactory: gitFactory, globalEnvVariables: globalEnvVariables, gitOpsConfigRepository: gitOpsConfigRepository, @@ -154,7 +148,7 @@ func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, e func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - chartDir := filepath.Join(string(impl.chartWorkingDir), dir) + chartDir := filepath.Join(ChartWorkingDirPath, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -194,7 +188,7 @@ func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - tempReferenceTemplateDir := filepath.Join(string(impl.chartWorkingDir), dir) + tempReferenceTemplateDir := filepath.Join(ChartWorkingDirPath, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir) err := os.MkdirAll(tempReferenceTemplateDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -222,7 +216,7 @@ func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateReque chartMetaData := chartCreateRequest.ChartMetaData chartMetaData.ApiVersion = "v2" // ensure always v2 dir := impl.GetDir() - chartDir := filepath.Join(string(impl.chartWorkingDir), dir) + chartDir := filepath.Join(ChartWorkingDirPath, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -488,7 +482,7 @@ func (impl ChartTemplateServiceImpl) GetDir() string { func (impl ChartTemplateServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error) { chartMetaData.ApiVersion = "v2" // ensure always v2 dir := impl.GetDir() - chartDir := filepath.Join(string(impl.chartWorkingDir), dir) + chartDir := filepath.Join(ChartWorkingDirPath, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -670,7 +664,7 @@ func (impl ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - tempReferenceTemplateDir := filepath.Join(string(impl.chartWorkingDir), dir) + tempReferenceTemplateDir := filepath.Join(ChartWorkingDirPath, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir) err := os.MkdirAll(tempReferenceTemplateDir, os.ModePerm) //hack for concurrency handling if err != nil { diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 5148a4279d..5a17c7dfcd 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "io/ioutil" "net/url" "os" @@ -33,18 +34,9 @@ import ( "github.com/caarlos0/env" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8s/health" - client2 "github.com/devtron-labs/devtron/api/helm-app" status2 "github.com/devtron-labs/devtron/pkg/app/status" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" - "github.com/devtron-labs/devtron/pkg/auth/user" bean2 "github.com/devtron-labs/devtron/pkg/bean" - "github.com/devtron-labs/devtron/pkg/chart" - "github.com/devtron-labs/devtron/pkg/dockerRegistry" - "github.com/devtron-labs/devtron/pkg/k8s" - 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/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" _ "github.com/devtron-labs/devtron/pkg/variables/repository" @@ -53,14 +45,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" chart2 "k8s.io/helm/pkg/proto/hapi/chart" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/pkg/appStatus" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" - repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" - history2 "github.com/devtron-labs/devtron/pkg/pipeline/history" - "github.com/devtron-labs/devtron/pkg/sql" - util3 "github.com/devtron-labs/devtron/pkg/util" - application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/devtron-labs/devtron/api/bean" @@ -68,14 +52,16 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" client "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" . "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStatus" + chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/commonService" + "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" util "github.com/devtron-labs/devtron/util/event" - "github.com/devtron-labs/devtron/util/rbac" "github.com/go-pg/pg" "go.uber.org/zap" ) @@ -108,62 +94,29 @@ type AppServiceImpl struct { pipelineOverrideRepository chartConfig.PipelineOverrideRepository mergeUtil *MergeUtil logger *zap.SugaredLogger - ciArtifactRepository repository.CiArtifactRepository pipelineRepository pipelineConfig.PipelineRepository - gitFactory *GitFactory - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository eventClient client.EventClient eventFactory client.EventFactory acdClient application.ServiceClient - tokenCache *util3.TokenCache - acdAuthConfig *util3.ACDAuthConfig - enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - user user.UserService - appListingRepository repository.AppListingRepository appRepository app.AppRepository - envRepository repository2.EnvironmentRepository - pipelineConfigRepository chartConfig.PipelineConfigRepository configMapRepository chartConfig.ConfigMapRepository chartRepository chartRepoRepository.ChartRepository - ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository cdWorkflowRepository pipelineConfig.CdWorkflowRepository commonService commonService.CommonService - imageScanDeployInfoRepository security.ImageScanDeployInfoRepository - imageScanHistoryRepository security.ImageScanHistoryRepository - ArgoK8sClient argocdServer.ArgoK8sClient - pipelineStrategyHistoryService history2.PipelineStrategyHistoryService - configMapHistoryService history2.ConfigMapHistoryService - deploymentTemplateHistoryService history2.DeploymentTemplateHistoryService chartTemplateService ChartTemplateService - refChartDir chartRepoRepository.RefChartDir - helmAppClient client2.HelmAppClient - helmAppService client2.HelmAppService - chartRefRepository chartRepoRepository.ChartRefRepository - chartService chart.ChartService argoUserService argo.ArgoUserService pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository - appCrudOperationService AppCrudOperationService - configMapHistoryRepository repository3.ConfigMapHistoryRepository - strategyHistoryRepository repository3.PipelineStrategyHistoryRepository - deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository - dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService pipelineStatusTimelineResourcesService status2.PipelineStatusTimelineResourcesService pipelineStatusSyncDetailService status2.PipelineStatusSyncDetailService pipelineStatusTimelineService status2.PipelineStatusTimelineService appStatusConfig *AppServiceConfig - gitOpsConfigRepository repository.GitOpsConfigRepository appStatusService appStatus.AppStatusService installedAppRepository repository4.InstalledAppRepository - AppStoreDeploymentService service.AppStoreDeploymentService - K8sCommonService k8s.K8sCommonService installedAppVersionHistoryRepository repository4.InstalledAppVersionHistoryRepository globalEnvVariables *util2.GlobalEnvVariables - manifestPushConfigRepository repository5.ManifestPushConfigRepository - GitOpsManifestPushService GitOpsPushService scopedVariableManager variables.ScopedVariableCMCSManager - argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig + chartRefService chartRef.ChartRefService } type AppService interface { @@ -196,119 +149,55 @@ func NewAppService( pipelineOverrideRepository chartConfig.PipelineOverrideRepository, mergeUtil *MergeUtil, logger *zap.SugaredLogger, - ciArtifactRepository repository.CiArtifactRepository, pipelineRepository pipelineConfig.PipelineRepository, - dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, eventClient client.EventClient, eventFactory client.EventFactory, acdClient application.ServiceClient, - cache *util3.TokenCache, authConfig *util3.ACDAuthConfig, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, user user.UserService, - appListingRepository repository.AppListingRepository, appRepository app.AppRepository, - envRepository repository2.EnvironmentRepository, - pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository, chartRepository chartRepoRepository.ChartRepository, - ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, commonService commonService.CommonService, - imageScanDeployInfoRepository security.ImageScanDeployInfoRepository, - imageScanHistoryRepository security.ImageScanHistoryRepository, - ArgoK8sClient argocdServer.ArgoK8sClient, - gitFactory *GitFactory, - pipelineStrategyHistoryService history2.PipelineStrategyHistoryService, - configMapHistoryService history2.ConfigMapHistoryService, - deploymentTemplateHistoryService history2.DeploymentTemplateHistoryService, chartTemplateService ChartTemplateService, - refChartDir chartRepoRepository.RefChartDir, - chartRefRepository chartRepoRepository.ChartRefRepository, - chartService chart.ChartService, - helmAppClient client2.HelmAppClient, argoUserService argo.ArgoUserService, cdPipelineStatusTimelineRepo pipelineConfig.PipelineStatusTimelineRepository, - appCrudOperationService AppCrudOperationService, - configMapHistoryRepository repository3.ConfigMapHistoryRepository, - strategyHistoryRepository repository3.PipelineStrategyHistoryRepository, - deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository, - dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService, pipelineStatusTimelineResourcesService status2.PipelineStatusTimelineResourcesService, pipelineStatusSyncDetailService status2.PipelineStatusSyncDetailService, pipelineStatusTimelineService status2.PipelineStatusTimelineService, appStatusConfig *AppServiceConfig, - gitOpsConfigRepository repository.GitOpsConfigRepository, appStatusService appStatus.AppStatusService, installedAppRepository repository4.InstalledAppRepository, - AppStoreDeploymentService service.AppStoreDeploymentService, - k8sCommonService k8s.K8sCommonService, installedAppVersionHistoryRepository repository4.InstalledAppVersionHistoryRepository, - globalEnvVariables *util2.GlobalEnvVariables, helmAppService client2.HelmAppService, - manifestPushConfigRepository repository5.ManifestPushConfigRepository, - GitOpsManifestPushService GitOpsPushService, - argoClientWrapperService argocdServer.ArgoClientWrapperService, + globalEnvVariables *util2.GlobalEnvVariables, scopedVariableManager variables.ScopedVariableCMCSManager, - acdConfig *argocdServer.ACDConfig, -) *AppServiceImpl { + acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService) *AppServiceImpl { appServiceImpl := &AppServiceImpl{ environmentConfigRepository: environmentConfigRepository, mergeUtil: mergeUtil, pipelineOverrideRepository: pipelineOverrideRepository, logger: logger, - ciArtifactRepository: ciArtifactRepository, pipelineRepository: pipelineRepository, - dbMigrationConfigRepository: dbMigrationConfigRepository, eventClient: eventClient, eventFactory: eventFactory, acdClient: acdClient, - tokenCache: cache, - acdAuthConfig: authConfig, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - user: user, - appListingRepository: appListingRepository, appRepository: appRepository, - envRepository: envRepository, - pipelineConfigRepository: pipelineConfigRepository, configMapRepository: configMapRepository, chartRepository: chartRepository, - ciPipelineMaterialRepository: ciPipelineMaterialRepository, cdWorkflowRepository: cdWorkflowRepository, commonService: commonService, - imageScanDeployInfoRepository: imageScanDeployInfoRepository, - imageScanHistoryRepository: imageScanHistoryRepository, - ArgoK8sClient: ArgoK8sClient, - gitFactory: gitFactory, - pipelineStrategyHistoryService: pipelineStrategyHistoryService, - configMapHistoryService: configMapHistoryService, - deploymentTemplateHistoryService: deploymentTemplateHistoryService, chartTemplateService: chartTemplateService, - refChartDir: refChartDir, - chartRefRepository: chartRefRepository, - chartService: chartService, - helmAppClient: helmAppClient, argoUserService: argoUserService, pipelineStatusTimelineRepository: cdPipelineStatusTimelineRepo, - appCrudOperationService: appCrudOperationService, - configMapHistoryRepository: configMapHistoryRepository, - strategyHistoryRepository: strategyHistoryRepository, - deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, - dockerRegistryIpsConfigService: dockerRegistryIpsConfigService, pipelineStatusTimelineResourcesService: pipelineStatusTimelineResourcesService, pipelineStatusSyncDetailService: pipelineStatusSyncDetailService, pipelineStatusTimelineService: pipelineStatusTimelineService, appStatusConfig: appStatusConfig, - gitOpsConfigRepository: gitOpsConfigRepository, appStatusService: appStatusService, installedAppRepository: installedAppRepository, - AppStoreDeploymentService: AppStoreDeploymentService, - K8sCommonService: k8sCommonService, installedAppVersionHistoryRepository: installedAppVersionHistoryRepository, globalEnvVariables: globalEnvVariables, - helmAppService: helmAppService, - manifestPushConfigRepository: manifestPushConfigRepository, - GitOpsManifestPushService: GitOpsManifestPushService, - argoClientWrapperService: argoClientWrapperService, scopedVariableManager: scopedVariableManager, acdConfig: acdConfig, + chartRefService: chartRefService, } return appServiceImpl } @@ -984,16 +873,16 @@ func (impl *AppServiceImpl) BuildChartAndGetPath(appName string, envOverride *ch Name: appName, Version: envOverride.Chart.ChartVersion, } - referenceTemplatePath := path.Join(string(impl.refChartDir), envOverride.Chart.ReferenceTemplate) + referenceTemplatePath := path.Join(chartRepoRepository.RefChartDirPath, envOverride.Chart.ReferenceTemplate) // Load custom charts to referenceTemplatePath if not exists if _, err := os.Stat(referenceTemplatePath); os.IsNotExist(err) { - chartRefValue, err := impl.chartRefRepository.FindById(envOverride.Chart.ChartRefId) + chartRefValue, err := impl.chartRefService.FindById(envOverride.Chart.ChartRefId) if err != nil { impl.logger.Errorw("error in fetching ChartRef data", "err", err) return "", err } if chartRefValue.ChartData != nil { - chartInfo, err := impl.chartService.ExtractChartIfMissing(chartRefValue.ChartData, string(impl.refChartDir), chartRefValue.Location) + chartInfo, err := impl.chartRefService.ExtractChartIfMissing(chartRefValue.ChartData, chartRepoRepository.RefChartDirPath, chartRefValue.Location) if chartInfo != nil && chartInfo.TemporaryFolder != "" { err1 := os.RemoveAll(chartInfo.TemporaryFolder) if err1 != nil { @@ -1065,7 +954,7 @@ func (impl *AppServiceImpl) autoHealChartLocationInChart(ctx context.Context, en // get chart ref from DB (to get location) chartRefId := chart.ChartRefId _, span = otel.Tracer("orchestrator").Start(ctx, "chartRefRepository.FindById") - chartRef, err := impl.chartRefRepository.FindById(chartRefId) + chartRefDto, err := impl.chartRefService.FindById(chartRefId) span.End() if err != nil { impl.logger.Errorw("error occurred while fetching chartRef from DB", "chartRefId", chartRefId, "err", err) @@ -1073,7 +962,7 @@ func (impl *AppServiceImpl) autoHealChartLocationInChart(ctx context.Context, en } // build new chart location - newChartLocation := filepath.Join(chartRef.Location, envOverride.Chart.ChartVersion) + newChartLocation := filepath.Join(chartRefDto.Location, envOverride.Chart.ChartVersion) impl.logger.Infow("new chart location build", "chartId", chartId, "newChartLocation", newChartLocation) // update chart in DB diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 7f370435e4..f52731b204 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -11,7 +11,7 @@ import ( . "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" - chartService "github.com/devtron-labs/devtron/pkg/chart" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/go-pg/pg" "go.opentelemetry.io/otel" "go.uber.org/zap" @@ -29,33 +29,31 @@ type GitOpsPushService interface { type GitOpsManifestPushServiceImpl struct { logger *zap.SugaredLogger chartTemplateService util.ChartTemplateService - chartService chartService.ChartService gitOpsConfigRepository repository.GitOpsConfigRepository gitFactory *GitFactory pipelineStatusTimelineService status2.PipelineStatusTimelineService pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository acdConfig *argocdServer.ACDConfig + chartRefService chartRef.ChartRefService } func NewGitOpsManifestPushServiceImpl( logger *zap.SugaredLogger, chartTemplateService util.ChartTemplateService, - chartService chartService.ChartService, gitOpsConfigRepository repository.GitOpsConfigRepository, gitFactory *GitFactory, pipelineStatusTimelineService status2.PipelineStatusTimelineService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, - acdConfig *argocdServer.ACDConfig, -) *GitOpsManifestPushServiceImpl { + acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, chartTemplateService: chartTemplateService, - chartService: chartService, gitOpsConfigRepository: gitOpsConfigRepository, gitFactory: gitFactory, pipelineStatusTimelineService: pipelineStatusTimelineService, pipelineStatusTimelineRepository: pipelineStatusTimelineRepository, acdConfig: acdConfig, + chartRefService: chartRefService, } } @@ -110,7 +108,7 @@ func (impl *GitOpsManifestPushServiceImpl) PushChartToGitRepo(manifestPushTempla gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(manifestPushTemplate.AppName) span.End() _, span = otel.Tracer("orchestrator").Start(ctx, "chartService.CheckChartExists") - err := impl.chartService.CheckChartExists(manifestPushTemplate.ChartRefId) + err := impl.chartRefService.CheckChartExists(manifestPushTemplate.ChartRefId) span.End() if err != nil { impl.logger.Errorw("err in getting chart info", "err", err) diff --git a/pkg/app/integrationTest/AppService_test.go b/pkg/app/integrationTest/AppService_test.go index 9c78b5b783..03ed6b6423 100644 --- a/pkg/app/integrationTest/AppService_test.go +++ b/pkg/app/integrationTest/AppService_test.go @@ -155,12 +155,11 @@ func InitAppService() *app2.AppServiceImpl { pipelineStatusSyncDetailRepository := pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl(dbConnection, logger) pipelineStatusSyncDetailService := status.NewPipelineStatusSyncDetailServiceImpl(logger, pipelineStatusSyncDetailRepository) pipelineStatusTimelineService := status.NewPipelineStatusTimelineServiceImpl(logger, pipelineStatusTimelineRepository, cdWorkflowRepository, nil, pipelineStatusTimelineResourcesService, pipelineStatusSyncDetailService, nil, nil) - refChartDir := chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts") appService := app2.NewAppService(nil, pipelineOverrideRepository, nil, logger, nil, pipelineRepository, nil, eventClient, eventFactory, nil, nil, nil, nil, nil, nil, appListingRepository, appRepository, nil, nil, nil, nil, nil, chartRepository, nil, cdWorkflowRepository, nil, nil, nil, nil, - nil, nil, nil, nil, nil, refChartDir, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, pipelineStatusTimelineRepository, nil, nil, nil, nil, nil, pipelineStatusTimelineResourcesService, pipelineStatusSyncDetailService, pipelineStatusTimelineService, nil, nil, nil, nil, nil, nil, nil, diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 19dde14013..e9763577f3 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -150,6 +150,10 @@ type ChartGroupInstallAppRes struct { // / type RefChartProxyDir string +const ( + RefChartProxyDirPath = "scripts/devtron-reference-helm-charts" +) + var CHART_PROXY_TEMPLATE = "reference-chart-proxy" var REQUIREMENTS_YAML_FILE = "requirements.yaml" var VALUES_YAML_FILE = "values.yaml" diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 44ca59836e..ab912fda04 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -66,7 +66,6 @@ type AppStoreDeploymentCommonServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository2.EnvironmentRepository chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir gitFactory *util.GitFactory gitOpsConfigRepository repository3.GitOpsConfigRepository } @@ -77,7 +76,6 @@ func NewAppStoreDeploymentCommonServiceImpl( appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository2.EnvironmentRepository, chartTemplateService util.ChartTemplateService, - refChartDir appStoreBean.RefChartProxyDir, gitFactory *util.GitFactory, gitOpsConfigRepository repository3.GitOpsConfigRepository, ) *AppStoreDeploymentCommonServiceImpl { @@ -87,7 +85,6 @@ func NewAppStoreDeploymentCommonServiceImpl( appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, chartTemplateService: chartTemplateService, - refChartDir: refChartDir, gitFactory: gitFactory, gitOpsConfigRepository: gitOpsConfigRepository, } @@ -352,7 +349,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateChartProxyAndGetPath(insta ChartCreateResponse := &util.ChartCreateResponse{} template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(string(impl.refChartDir), template) + chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) valid, err := chartutil.IsChartDir(chartPath) if err != nil || !valid { impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 179c59463b..77d651bf19 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -72,7 +72,6 @@ type AppStoreDeploymentFullModeService interface { type AppStoreDeploymentFullModeServiceImpl struct { logger *zap.SugaredLogger chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir repositoryService repository.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository5.EnvironmentRepository @@ -94,7 +93,7 @@ type AppStoreDeploymentFullModeServiceImpl struct { } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, - chartTemplateService util.ChartTemplateService, refChartDir appStoreBean.RefChartProxyDir, + chartTemplateService util.ChartTemplateService, repositoryService repository.ServiceClient, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, @@ -114,7 +113,6 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ logger: logger, chartTemplateService: chartTemplateService, - refChartDir: refChartDir, repositoryService: repositoryService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, @@ -156,7 +154,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationGIT(ins //STEP 1: Commit and PUSH on Gitlab template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(string(impl.refChartDir), template) + chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) valid, err := chartutil.IsChartDir(chartPath) if err != nil || !valid { impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 47af5f5dc3..f97b19e5eb 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -52,7 +52,6 @@ import ( appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -109,7 +108,6 @@ type InstalledAppServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository2.InstalledAppRepository chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir repositoryService repository.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository5.EnvironmentRepository @@ -124,15 +122,14 @@ type InstalledAppServiceImpl struct { ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService + gitOpsRepository repository3.GitOpsConfigRepository + userService user.UserService + appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository argoUserService argo.ArgoUserService helmAppClient client.HelmAppClient helmAppService client.HelmAppService - attributesRepository repository3.AttributesRepository appStatusService appStatus.AppStatusService K8sUtil *util4.K8sUtil pipelineStatusTimelineService status.PipelineStatusTimelineService @@ -144,7 +141,7 @@ type InstalledAppServiceImpl struct { func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository, - chartTemplateService util.ChartTemplateService, refChartDir appStoreBean.RefChartProxyDir, + chartTemplateService util.ChartTemplateService, repositoryService repository.ServiceClient, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, @@ -160,17 +157,15 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, argoUserService argo.ArgoUserService, helmAppClient client.HelmAppClient, helmAppService client.HelmAppService, - attributesRepository repository3.AttributesRepository, appStatusService appStatus.AppStatusService, K8sUtil *util4.K8sUtil, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, + k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, acdConfig *argocdServer.ACDConfig) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, chartTemplateService: chartTemplateService, - refChartDir: refChartDir, repositoryService: repositoryService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, @@ -193,7 +188,6 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, argoUserService: argoUserService, helmAppClient: helmAppClient, helmAppService: helmAppService, - attributesRepository: attributesRepository, appStatusService: appStatusService, K8sUtil: K8sUtil, pipelineStatusTimelineService: pipelineStatusTimelineService, diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index 3f8bb5d4de..13743864df 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -10,7 +10,6 @@ import ( repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" @@ -28,7 +27,6 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { logger *zap.SugaredLogger installedAppRepository repository4.InstalledAppRepository chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir repositoryService repository2.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository.EnvironmentRepository @@ -43,9 +41,9 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService + gitOpsRepository repository3.GitOpsConfigRepository + userService user.UserService + appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService } type args struct { @@ -67,7 +65,6 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { logger: tt.fields.logger, installedAppRepository: tt.fields.installedAppRepository, chartTemplateService: tt.fields.chartTemplateService, - refChartDir: tt.fields.refChartDir, repositoryService: tt.fields.repositoryService, appStoreApplicationVersionRepository: tt.fields.appStoreApplicationVersionRepository, environmentRepository: tt.fields.environmentRepository, diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index 9991ca32ee..4ae831d949 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -12,7 +12,6 @@ import ( client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" @@ -22,10 +21,11 @@ import ( "github.com/devtron-labs/devtron/internal/util" appWorkflow2 "github.com/devtron-labs/devtron/pkg/appWorkflow" bean2 "github.com/devtron-labs/devtron/pkg/bean" - "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + bean3 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "github.com/devtron-labs/devtron/pkg/pipeline" pipeline1 "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -66,27 +66,14 @@ type BulkUpdateServiceImpl struct { bulkUpdateRepository bulkUpdate.BulkUpdateRepository chartRepository chartRepoRepository.ChartRepository logger *zap.SugaredLogger - repoRepository chartRepoRepository.ChartRepoRepository - chartTemplateService util.ChartTemplateService - mergeUtil util.MergeUtil - repositoryService repository.ServiceClient - defaultChart chart.DefaultChart - chartRefRepository chartRepoRepository.ChartRefRepository - envOverrideRepository chartConfig.EnvConfigOverrideRepository - pipelineConfigRepository chartConfig.PipelineConfigRepository - configMapRepository chartConfig.ConfigMapRepository environmentRepository repository2.EnvironmentRepository pipelineRepository pipelineConfig.PipelineRepository - client *http.Client appRepository app.AppRepository deploymentTemplateHistoryService history.DeploymentTemplateHistoryService configMapHistoryService history.ConfigMapHistoryService workflowDagExecutor pipeline.WorkflowDagExecutor - cdWorkflowRepository pipelineConfig.CdWorkflowRepository pipelineBuilder pipeline.PipelineBuilder - helmAppService client.HelmAppService enforcerUtil rbac.EnforcerUtil - enforcerUtilHelm rbac.EnforcerUtilHelm ciHandler pipeline.CiHandler ciPipelineRepository pipelineConfig.CiPipelineRepository appWorkflowRepository appWorkflow.AppWorkflowRepository @@ -95,61 +82,40 @@ type BulkUpdateServiceImpl struct { argoUserService argo.ArgoUserService scopedVariableManager variables.ScopedVariableManager deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateRepository, chartRepository chartRepoRepository.ChartRepository, logger *zap.SugaredLogger, - chartTemplateService util.ChartTemplateService, - repoRepository chartRepoRepository.ChartRepoRepository, - defaultChart chart.DefaultChart, - mergeUtil util.MergeUtil, - repositoryService repository.ServiceClient, - chartRefRepository chartRepoRepository.ChartRefRepository, - envOverrideRepository chartConfig.EnvConfigOverrideRepository, - pipelineConfigRepository chartConfig.PipelineConfigRepository, - configMapRepository chartConfig.ConfigMapRepository, environmentRepository repository2.EnvironmentRepository, pipelineRepository pipelineConfig.PipelineRepository, - client *http.Client, appRepository app.AppRepository, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, configMapHistoryService history.ConfigMapHistoryService, workflowDagExecutor pipeline.WorkflowDagExecutor, - cdWorkflowRepository pipelineConfig.CdWorkflowRepository, pipelineBuilder pipeline.PipelineBuilder, - helmAppService client.HelmAppService, enforcerUtil rbac.EnforcerUtil, - enforcerUtilHelm rbac.EnforcerUtilHelm, ciHandler pipeline.CiHandler, + pipelineBuilder pipeline.PipelineBuilder, + enforcerUtil rbac.EnforcerUtil, + ciHandler pipeline.CiHandler, ciPipelineRepository pipelineConfig.CiPipelineRepository, appWorkflowRepository appWorkflow.AppWorkflowRepository, appWorkflowService appWorkflow2.AppWorkflowService, pubsubClient *pubsub.PubSubClientServiceImpl, argoUserService argo.ArgoUserService, scopedVariableManager variables.ScopedVariableManager, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) (*BulkUpdateServiceImpl, error) { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) (*BulkUpdateServiceImpl, error) { impl := &BulkUpdateServiceImpl{ bulkUpdateRepository: bulkUpdateRepository, chartRepository: chartRepository, logger: logger, - chartTemplateService: chartTemplateService, - repoRepository: repoRepository, - mergeUtil: mergeUtil, - defaultChart: defaultChart, - repositoryService: repositoryService, - chartRefRepository: chartRefRepository, - envOverrideRepository: envOverrideRepository, - pipelineConfigRepository: pipelineConfigRepository, - configMapRepository: configMapRepository, environmentRepository: environmentRepository, pipelineRepository: pipelineRepository, - client: client, appRepository: appRepository, deploymentTemplateHistoryService: deploymentTemplateHistoryService, configMapHistoryService: configMapHistoryService, workflowDagExecutor: workflowDagExecutor, - cdWorkflowRepository: cdWorkflowRepository, pipelineBuilder: pipelineBuilder, - helmAppService: helmAppService, enforcerUtil: enforcerUtil, - enforcerUtilHelm: enforcerUtilHelm, ciHandler: ciHandler, ciPipelineRepository: ciPipelineRepository, appWorkflowRepository: appWorkflowRepository, @@ -158,6 +124,7 @@ func NewBulkUpdateServiceImpl(bulkUpdateRepository bulkUpdate.BulkUpdateReposito argoUserService: argoUserService, scopedVariableManager: scopedVariableManager, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } err := impl.SubscribeToCdBulkTriggerTopic() @@ -1099,14 +1066,14 @@ func (impl BulkUpdateServiceImpl) buildHibernateUnHibernateRequestForHelmPipelin } hibernateRequest := &openapi.HibernateRequest{} - chartInfo, err := impl.chartRefRepository.FetchInfoOfChartConfiguredInApp(pipeline.AppId) + chartInfo, err := impl.chartRefService.FetchInfoOfChartConfiguredInApp(pipeline.AppId) if err != nil { impl.logger.Errorw("error in getting chart info for chart configured in app", "err", err, "appId", pipeline.AppId) return nil, nil, err } var group, kind, version, name string name = fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name) - if chartInfo.Name == "" && chartInfo.UserUploaded == false { + if chartInfo.Name == bean3.RolloutChartType && chartInfo.UserUploaded == false { // rollout type chart group = "argoproj.io" kind = "Rollout" @@ -1122,7 +1089,7 @@ func (impl BulkUpdateServiceImpl) buildHibernateUnHibernateRequestForHelmPipelin }, }, } - } else if chartInfo.Name == "Deployment" { + } else if chartInfo.Name == bean3.DeploymentChartType { //deployment type chart group = "apps" kind = "Deployment" diff --git a/pkg/chart/ChartCompatibility_test.go b/pkg/chart/ChartCompatibility_test.go index 95005d1916..5bafe12b0f 100644 --- a/pkg/chart/ChartCompatibility_test.go +++ b/pkg/chart/ChartCompatibility_test.go @@ -1,6 +1,8 @@ package chart import ( + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "reflect" "testing" ) @@ -18,8 +20,8 @@ func Test_checkCompatibility(t *testing.T) { { name: "when charts are compatible, it should return true", args: args{ - oldChartType: DeploymentChartType, - newChartType: RolloutChartType, + oldChartType: bean.DeploymentChartType, + newChartType: bean.RolloutChartType, }, want: true, }, @@ -27,14 +29,14 @@ func Test_checkCompatibility(t *testing.T) { name: "when oldChart is not found, it should return false", args: args{ oldChartType: "Sdfasdf", - newChartType: RolloutChartType, + newChartType: bean.RolloutChartType, }, want: false, }, { name: "when newChart is not found, it should return false", args: args{ - oldChartType: DeploymentChartType, + oldChartType: bean.DeploymentChartType, newChartType: "random sdfasdf saldfj", }, want: false, @@ -42,7 +44,7 @@ func Test_checkCompatibility(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := CheckCompatibility(tt.args.oldChartType, tt.args.newChartType); got != tt.want { + if got := chartRef.CheckCompatibility(tt.args.oldChartType, tt.args.newChartType); got != tt.want { t.Errorf("checkCompatibility() = %v, want %v", got, tt.want) } }) @@ -68,14 +70,14 @@ func TestCompatibleChartsWith(t *testing.T) { { name: "when chart is found, it should return a slice of all cpmpatible chartIds", args: args{ - chartType: DeploymentChartType, + chartType: bean.DeploymentChartType, }, - want: []string{RolloutChartType}, + want: []string{bean.RolloutChartType}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := CompatibleChartsWith(tt.args.chartType); !reflect.DeepEqual(got, tt.want) { + if got := chartRef.CompatibleChartsWith(tt.args.chartType); !reflect.DeepEqual(got, tt.want) { t.Errorf("CompatibleChartsWith() = %v, want %v", got, tt.want) } }) diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index ceb5956051..0212bc570a 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -24,6 +24,8 @@ import ( "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + bean2 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/variables/parsers" @@ -31,8 +33,6 @@ import ( "go.opentelemetry.io/otel" - "github.com/devtron-labs/devtron/internal/constants" - //"github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/internal/sql/repository/app" @@ -40,29 +40,22 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/history" "io/ioutil" - "net/http" "os" - "path" "path/filepath" "strconv" "strings" "time" - repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository" - "github.com/devtron-labs/devtron/pkg/sql" - dirCopy "github.com/otiai10/copy" - - "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" + repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "github.com/juju/errors" "github.com/xeipuuv/gojsonschema" "go.uber.org/zap" - "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/proto/hapi/chart" "sigs.k8s.io/yaml" ) @@ -75,28 +68,17 @@ type ChartService interface { GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) UpdateAppOverride(ctx context.Context, templateRequest *TemplateRequest) (*TemplateRequest, error) IsReadyToTrigger(appId int, envId int, pipelineId int) (IsReady, error) - ChartRefAutocomplete() ([]ChartRef, error) - ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*ChartRefResponse, error) FindPreviousChartByAppId(appId int) (chartTemplate *TemplateRequest, err error) UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) DeploymentTemplateValidate(ctx context.Context, templatejson interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) (schema []byte, readme []byte, err error) - ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*ChartDataInfo, error) - CheckChartExists(chartRefId int) error - CheckIsAppMetricsSupported(chartRefId int) (bool, error) - GetLocationFromChartNameAndVersion(chartName string, chartVersion string) string - FormatChartName(chartName string) string ValidateUploadedFileFormat(fileName string) error - ReadChartMetaDataForLocation(chartDir string, fileName string) (*ChartYamlStruct, error) - FetchCustomChartsInfo() ([]*ChartDto, error) - CheckCustomChartByAppId(id int) (bool, error) - CheckCustomChartByChartId(id int) (bool, error) - ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) + CheckIfChartRefUserUploadedByAppId(id int) (bool, error) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) - GetCustomChartInBytes(chatRefId int) ([]byte, error) - GetRefChart(templateRequest TemplateRequest) (string, string, error, string, string) + + ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*bean2.ChartRefAutocompleteResponse, error) } type ChartServiceImpl struct { @@ -106,19 +88,13 @@ type ChartServiceImpl struct { chartTemplateService util.ChartTemplateService pipelineGroupRepository app.AppRepository mergeUtil util.MergeUtil - repositoryService repository.ServiceClient - refChartDir chartRepoRepository.RefChartDir - defaultChart DefaultChart - chartRefRepository chartRepoRepository.ChartRefRepository envOverrideRepository chartConfig.EnvConfigOverrideRepository pipelineConfigRepository chartConfig.PipelineConfigRepository - configMapRepository chartConfig.ConfigMapRepository environmentRepository repository4.EnvironmentRepository - pipelineRepository pipelineConfig.PipelineRepository - client *http.Client deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, @@ -126,24 +102,14 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, chartTemplateService util.ChartTemplateService, repoRepository chartRepoRepository.ChartRepoRepository, pipelineGroupRepository app.AppRepository, - refChartDir chartRepoRepository.RefChartDir, - defaultChart DefaultChart, mergeUtil util.MergeUtil, - repositoryService repository.ServiceClient, - chartRefRepository chartRepoRepository.ChartRefRepository, envOverrideRepository chartConfig.EnvConfigOverrideRepository, pipelineConfigRepository chartConfig.PipelineConfigRepository, - configMapRepository chartConfig.ConfigMapRepository, environmentRepository repository4.EnvironmentRepository, - pipelineRepository pipelineConfig.PipelineRepository, - client *http.Client, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *ChartServiceImpl { - - // cache devtron reference charts list - devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) - SetReservedChartList(devtronChartList) + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) *ChartServiceImpl { return &ChartServiceImpl{ chartRepository: chartRepository, logger: logger, @@ -151,40 +117,16 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, repoRepository: repoRepository, pipelineGroupRepository: pipelineGroupRepository, mergeUtil: mergeUtil, - refChartDir: refChartDir, - defaultChart: defaultChart, - repositoryService: repositoryService, - chartRefRepository: chartRefRepository, envOverrideRepository: envOverrideRepository, pipelineConfigRepository: pipelineConfigRepository, - configMapRepository: configMapRepository, environmentRepository: environmentRepository, - pipelineRepository: pipelineRepository, - client: client, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } } -func (impl ChartServiceImpl) ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) { - oldChart, err := impl.chartRefRepository.FindById(oldChartRefId) - if err != nil { - return false, "", "" - } - newChart, err := impl.chartRefRepository.FindById(newChartRefId) - if err != nil { - return false, "", "" - } - if len(oldChart.Name) == 0 { - oldChart.Name = RolloutChartType - } - if len(newChart.Name) == 0 { - newChart.Name = RolloutChartType - } - return CheckCompatibility(oldChart.Name, newChart.Name), oldChart.Name, newChart.Name -} - func (impl ChartServiceImpl) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) { var jsonMap map[string]json.RawMessage if err := json.Unmarshal([]byte(values), &jsonMap); err != nil { @@ -210,14 +152,14 @@ func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartT } func (impl ChartServiceImpl) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) { - refChart, _, err, _, _ := impl.GetRefChart(TemplateRequest{ChartRefId: chartRefId}) + refChart, _, err, _, _ := impl.chartRefService.GetRefChart(chartRefId) if err != nil { impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) return nil, nil, err } var schemaByte []byte var readmeByte []byte - err = impl.CheckChartExists(chartRefId) + err = impl.chartRefService.CheckChartExists(chartRefId) if err != nil { impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) return nil, nil, err @@ -234,13 +176,13 @@ func (impl ChartServiceImpl) GetSchemaAndReadmeForTemplateByChartRefId(chartRefI } func (impl ChartServiceImpl) GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) { - err := impl.CheckChartExists(chartRefId) + err := impl.chartRefService.CheckChartExists(chartRefId) if err != nil { impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") return nil, "", err } - refChart, _, err, _, _ := impl.GetRefChart(TemplateRequest{ChartRefId: chartRefId}) + refChart, _, err, _, _ := impl.chartRefService.GetRefChart(chartRefId) if err != nil { return nil, "", err } @@ -292,7 +234,7 @@ type AppMetricsEnabled struct { } func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context.Context) (*TemplateRequest, error) { - err := impl.CheckChartExists(templateRequest.ChartRefId) + err := impl.chartRefService.CheckChartExists(templateRequest.ChartRefId) if err != nil { impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") return nil, err @@ -310,7 +252,7 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context return nil, err } - refChart, templateName, err, _, pipelineStrategyPath := impl.GetRefChart(templateRequest) + refChart, templateName, err, _, pipelineStrategyPath := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) if err != nil { return nil, err } @@ -455,7 +397,7 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context } func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest TemplateRequest, ctx context.Context) (*TemplateRequest, error) { - err := impl.CheckChartExists(templateRequest.ChartRefId) + err := impl.chartRefService.CheckChartExists(templateRequest.ChartRefId) if err != nil { impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") return nil, err @@ -476,7 +418,7 @@ func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest Template return nil, err } - refChart, templateName, err, _, pipelineStrategyPath := impl.GetRefChart(templateRequest) + refChart, templateName, err, _, pipelineStrategyPath := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) if err != nil { return nil, err } @@ -600,75 +542,24 @@ func (impl ChartServiceImpl) getChartMetaData(templateRequest TemplateRequest) ( } return metadata, err } -func (impl ChartServiceImpl) GetRefChart(templateRequest TemplateRequest) (string, string, error, string, string) { - var template string - var version string - //path of file in chart from where strategy config is to be taken - var pipelineStrategyPath string - if templateRequest.ChartRefId > 0 { - chartRef, err := impl.chartRefRepository.FindById(templateRequest.ChartRefId) - if err != nil { - chartRef, err = impl.chartRefRepository.GetDefault() - if err != nil { - return "", "", err, "", "" - } - } else if chartRef.UserUploaded { - refChartLocation := filepath.Join(string(impl.refChartDir), chartRef.Location) - if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { - chartInfo, err := impl.ExtractChartIfMissing(chartRef.ChartData, string(impl.refChartDir), chartRef.Location) - if chartInfo != nil && chartInfo.TemporaryFolder != "" { - err1 := os.RemoveAll(chartInfo.TemporaryFolder) - if err1 != nil { - impl.logger.Errorw("error in deleting temp dir ", "err", err) - } - } - if err != nil { - impl.logger.Errorw("Error regarding uploaded chart", "err", err) - return "", "", err, "", "" - } - - } - } - template = chartRef.Location - version = chartRef.Version - pipelineStrategyPath = chartRef.DeploymentStrategyPath - } else { - chartRef, err := impl.chartRefRepository.GetDefault() - if err != nil { - return "", "", err, "", "" - } - template = chartRef.Location - version = chartRef.Version - pipelineStrategyPath = chartRef.DeploymentStrategyPath - } - - //TODO VIKI- fetch from chart ref table - chartPath := path.Join(string(impl.refChartDir), template) - valid, err := chartutil.IsChartDir(chartPath) - if err != nil || !valid { - impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) - return "", "", err, "", "" - } - return chartPath, template, nil, version, pipelineStrategyPath -} func (impl ChartServiceImpl) getRefChartVersion(templateRequest TemplateRequest) (string, error) { var version string if templateRequest.ChartRefId > 0 { - chartRef, err := impl.chartRefRepository.FindById(templateRequest.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(templateRequest.ChartRefId) if err != nil { - chartRef, err = impl.chartRefRepository.GetDefault() + chartRefDto, err = impl.chartRefService.GetDefault() if err != nil { return "", err } } - version = chartRef.Version + version = chartRefDto.Version } else { - chartRef, err := impl.chartRefRepository.GetDefault() + chartRefDto, err := impl.chartRefService.GetDefault() if err != nil { return "", err } - version = chartRef.Location + version = chartRefDto.Location } return version, nil } @@ -863,31 +754,6 @@ func (impl ChartServiceImpl) UpdateAppOverride(ctx context.Context, templateRequ return templateRequest, nil } -func (impl ChartServiceImpl) handleChartTypeChange(currentLatestChart *chartRepoRepository.Chart, templateRequest *TemplateRequest) (json.RawMessage, error) { - var oldChartRef, newChartRef *chartRepoRepository.ChartRef - var err error - if oldChartRef, err = impl.chartRefRepository.FindById(currentLatestChart.ChartRefId); err != nil { - return nil, fmt.Errorf("chartRef not found for %v", currentLatestChart.ChartRefId) - } - if newChartRef, err = impl.chartRefRepository.FindById(templateRequest.ChartRefId); err != nil { - return nil, fmt.Errorf("chartRef not found for %v", templateRequest.ChartRefId) - } - if len(oldChartRef.Name) == 0 { - oldChartRef.Name = RolloutChartType - } - if len(newChartRef.Name) == 0 { - oldChartRef.Name = RolloutChartType - } - if !CheckCompatibility(oldChartRef.Name, newChartRef.Name) { - return nil, fmt.Errorf("charts are not compatible") - } - updatedOverride, err := PatchWinterSoldierConfig(templateRequest.ValuesOverride, newChartRef.Name) - if err != nil { - return nil, err - } - return updatedOverride, nil -} - type IsReady struct { Flag bool `json:"flag"` Message string `json:"message"` @@ -924,101 +790,25 @@ func (impl ChartServiceImpl) IsReadyToTrigger(appId int, envId int, pipelineId i return isReady, nil } -type ChartRef struct { - Id int `json:"id"` - Version string `json:"version"` - Name string `json:"name"` - Description string `json:"description"` - UserUploaded bool `json:"userUploaded"` - IsAppMetricsSupported bool `json:"isAppMetricsSupported"` -} +func (impl ChartServiceImpl) ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*bean2.ChartRefAutocompleteResponse, error) { + chartRefResponse := &bean2.ChartRefAutocompleteResponse{} + var chartRefs []bean2.ChartRefAutocompleteDto -type ChartRefMetaData struct { - ChartDescription string `json:"chartDescription"` -} - -type ChartRefResponse struct { - ChartRefs []ChartRef `json:"chartRefs"` - LatestChartRef int `json:"latestChartRef"` - LatestAppChartRef int `json:"latestAppChartRef"` - LatestEnvChartRef int `json:"latestEnvChartRef,omitempty"` - ChartsMetadata map[string]ChartRefMetaData `json:"chartMetadata"` // chartName vs Metadata - CompatibleChartTypes []string `json:"compatibleChartTypes,omitempty"` -} - -type ChartYamlStruct struct { - Name string `yaml:"name"` - Version string `yaml:"version"` - Description string `yaml:"description"` -} - -type ChartDataInfo struct { - ChartLocation string `json:"chartLocation"` - ChartName string `json:"chartName"` - ChartVersion string `json:"chartVersion"` - TemporaryFolder string `json:"temporaryFolder"` - Description string `json:"description"` - Message string `json:"message"` -} - -type ChartDto struct { - Id int `json:"id"` - Name string `json:"name"` - ChartDescription string `json:"chartDescription"` - Version string `json:"version"` - IsUserUploaded bool `json:"isUserUploaded"` -} - -func (impl ChartServiceImpl) ChartRefAutocomplete() ([]ChartRef, error) { - var chartRefs []ChartRef - results, err := impl.chartRefRepository.GetAll() + results, err := impl.chartRefService.GetAll() if err != nil { - impl.logger.Errorw("error in fetching chart config", "err", err) - return chartRefs, err - } - - for _, result := range results { - chartRefs = append(chartRefs, ChartRef{ - Id: result.Id, - Version: result.Version, - Description: result.ChartDescription, - UserUploaded: result.UserUploaded, - IsAppMetricsSupported: result.IsAppMetricsSupported, - }) - } - - return chartRefs, nil -} - -func (impl ChartServiceImpl) ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*ChartRefResponse, error) { - chartRefResponse := &ChartRefResponse{ - ChartsMetadata: make(map[string]ChartRefMetaData), - } - var chartRefs []ChartRef - - results, err := impl.chartRefRepository.GetAll() - if err != nil { - impl.logger.Errorw("error in fetching chart config", "err", err) + impl.logger.Errorw("error in fetching chart ref", "err", err) return chartRefResponse, err } - resultsMetadata, err := impl.chartRefRepository.GetAllChartMetadata() + resultsMetadataMap, err := impl.chartRefService.GetAllChartMetadata() if err != nil { impl.logger.Errorw("error in fetching chart metadata", "err", err) return chartRefResponse, err } - for _, resultMetadata := range resultsMetadata { - chartRefMetadata := ChartRefMetaData{ - ChartDescription: resultMetadata.ChartDescription, - } - chartRefResponse.ChartsMetadata[resultMetadata.ChartName] = chartRefMetadata - } + chartRefResponse.ChartsMetadata = resultsMetadataMap var LatestAppChartRef int for _, result := range results { - if len(result.Name) == 0 { - result.Name = "Rollout Deployment" - } - chartRefs = append(chartRefs, ChartRef{ + chartRefs = append(chartRefs, bean2.ChartRefAutocompleteDto{ Id: result.Id, Version: result.Version, Name: result.Name, @@ -1236,13 +1026,13 @@ func (impl ChartServiceImpl) DeploymentTemplateValidate(ctx context.Context, tem } func (impl ChartServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) { - err := impl.CheckChartExists(chartRefId) + err := impl.chartRefService.CheckChartExists(chartRefId) if err != nil { impl.logger.Errorw("refChartDir Not Found", "err", err) return nil, "", err } - refChartDir, _, err, version, _ := impl.GetRefChart(TemplateRequest{ChartRefId: chartRefId}) + refChartDir, _, err, version, _ := impl.chartRefService.GetRefChart(chartRefId) if err != nil { impl.logger.Errorw("refChartDir Not Found err, JsonSchemaExtractFromFile", err) return nil, "", err @@ -1273,53 +1063,6 @@ func (impl ChartServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[stri } } -func (impl ChartServiceImpl) CheckChartExists(chartRefId int) error { - chartRefValue, err := impl.chartRefRepository.FindById(chartRefId) - if err != nil { - impl.logger.Errorw("error in finding ref chart by id", "err", err) - return err - } - refChartLocation := filepath.Join(string(impl.refChartDir), chartRefValue.Location) - if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { - chartInfo, err := impl.ExtractChartIfMissing(chartRefValue.ChartData, string(impl.refChartDir), chartRefValue.Location) - if chartInfo != nil && chartInfo.TemporaryFolder != "" { - err1 := os.RemoveAll(chartInfo.TemporaryFolder) - if err1 != nil { - impl.logger.Errorw("error in deleting temp dir ", "err", err) - } - } - return err - } - return nil -} - -func (impl ChartServiceImpl) CheckIsAppMetricsSupported(chartRefId int) (bool, error) { - chartRefValue, err := impl.chartRefRepository.FindById(chartRefId) - if err != nil { - impl.logger.Errorw("error in finding ref chart by id", "err", err) - return false, nil - } - return chartRefValue.IsAppMetricsSupported, nil -} - -func (impl *ChartServiceImpl) GetLocationFromChartNameAndVersion(chartName string, chartVersion string) string { - var chartLocation string - chartname := impl.FormatChartName(chartName) - chartversion := strings.ReplaceAll(chartVersion, ".", "-") - if !strings.Contains(chartname, chartversion) { - chartLocation = chartname + "_" + chartversion - } else { - chartLocation = chartname - } - return chartLocation -} - -func (impl *ChartServiceImpl) FormatChartName(chartName string) string { - chartname := strings.ReplaceAll(chartName, ".", "-") - chartname = strings.ReplaceAll(chartname, " ", "_") - return chartname -} - func (impl *ChartServiceImpl) ValidateUploadedFileFormat(fileName string) error { if !strings.HasSuffix(fileName, ".tgz") { return errors.New("unsupported format") @@ -1327,243 +1070,14 @@ func (impl *ChartServiceImpl) ValidateUploadedFileFormat(fileName string) error return nil } -func (impl ChartServiceImpl) ReadChartMetaDataForLocation(chartDir string, fileName string) (*ChartYamlStruct, error) { - chartLocation := filepath.Clean(filepath.Join(chartDir, fileName)) - - chartYamlPath := filepath.Clean(filepath.Join(chartLocation, "Chart.yaml")) - if _, err := os.Stat(chartYamlPath); os.IsNotExist(err) { - return nil, fmt.Errorf("Chart.yaml file not present in the directory") - } - - data, err := ioutil.ReadFile(chartYamlPath) - if err != nil { - impl.logger.Errorw("failed reading data from file", "err", err) - return nil, err - } - //println(data) - var chartYaml ChartYamlStruct - err = yaml.Unmarshal(data, &chartYaml) - if err != nil { - impl.logger.Errorw("Unmarshal error of yaml file", "err", err) - return nil, err - } - if chartYaml.Name == "" || chartYaml.Version == "" { - impl.logger.Errorw("Missing values in yaml file either name or version", "err", err) - return nil, errors.New("Missing values in yaml file either name or version") - } - ver := strings.Split(chartYaml.Version, ".") - if len(ver) == 3 { - for _, verObject := range ver { - if _, err := strconv.ParseInt(verObject, 10, 64); err != nil { - return nil, errors.New("Version should contain integers (Ex: 1.1.0)") - } - } - return &chartYaml, nil - } - return nil, errors.New("Version should be of length 3 integers with dot seperated (Ex: 1.1.0)") -} - -func (impl ChartServiceImpl) ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*ChartDataInfo, error) { - binaryDataReader := bytes.NewReader(chartData) - dir := impl.chartTemplateService.GetDir() - chartInfo := &ChartDataInfo{ - ChartName: "", - ChartVersion: "", - ChartLocation: "", - TemporaryFolder: "", - Description: "", - Message: "", - } - temporaryChartWorkingDir := filepath.Clean(filepath.Join(refChartDir, dir)) - err := os.MkdirAll(temporaryChartWorkingDir, os.ModePerm) - if err != nil { - impl.logger.Errorw("error in creating directory, CallbackConfigMap", "err", err) - return chartInfo, err - } - chartInfo.TemporaryFolder = temporaryChartWorkingDir - err = util2.ExtractTarGz(binaryDataReader, temporaryChartWorkingDir) - if err != nil { - impl.logger.Errorw("error in extracting binary data of charts", "err", err) - return chartInfo, err - } - - var chartLocation string - var chartName string - var chartVersion string - var fileName string - - files, err := ioutil.ReadDir(temporaryChartWorkingDir) - if err != nil { - impl.logger.Errorw("error in reading err dir", "err", err) - return chartInfo, err - } - - fileName = files[0].Name() - if strings.HasPrefix(files[0].Name(), ".") { - fileName = files[1].Name() - } - - currentChartWorkingDir := filepath.Clean(filepath.Join(temporaryChartWorkingDir, fileName)) - - if location == "" { - chartYaml, err := impl.ReadChartMetaDataForLocation(temporaryChartWorkingDir, fileName) - var errorList error - if err != nil { - impl.logger.Errorw("Chart yaml file or content not found") - errorList = err - } - - err = util2.CheckForMissingFiles(currentChartWorkingDir) - if err != nil { - impl.logger.Errorw("Missing files in the folder", "err", err) - if errorList != nil { - errorList = errors.New(errorList.Error() + "; " + err.Error()) - } else { - errorList = err - } - - } - - if errorList != nil { - return chartInfo, errorList - } - - chartName = chartYaml.Name - chartVersion = chartYaml.Version - chartInfo.Description = chartYaml.Description - chartLocation = impl.GetLocationFromChartNameAndVersion(chartName, chartVersion) - location = chartLocation - - // Validate: chart name shouldn't conflict with Devtron charts (no user uploaded chart names should contain any devtron chart names as the prefix) - isReservedChart, _ := impl.ValidateReservedChartName(chartName) - if isReservedChart { - impl.logger.Errorw("request err, chart name is reserved by Devtron") - err = &util.ApiError{ - Code: constants.ChartNameAlreadyReserved, - InternalMessage: CHART_NAME_RESERVED_INTERNAL_ERROR, - UserMessage: fmt.Sprintf("The name '%s' is reserved for a chart provided by Devtron", chartName), - } - return chartInfo, err - } - - // Validate: chart location should be unique - exists, err := impl.chartRefRepository.CheckIfDataExists(location) - if err != nil { - impl.logger.Errorw("Error in searching the database") - return chartInfo, err - } - if exists { - impl.logger.Errorw("request err, chart name and version exists already in the database") - err = &util.ApiError{ - Code: constants.ChartCreatedAlreadyExists, - InternalMessage: CHART_ALREADY_EXISTS_INTERNAL_ERROR, - UserMessage: fmt.Sprintf("%s of %s exists already in the database", chartVersion, chartName), - } - return chartInfo, err - } - - //User Info Message: uploading new version of the existing chart name - existingChart, err := impl.chartRefRepository.FetchChart(chartName) - if err == nil && existingChart != nil { - chartInfo.Message = "New Version detected for " + existingChart[0].Name - } - - } else { - err = dirCopy.Copy(currentChartWorkingDir, filepath.Clean(filepath.Join(refChartDir, location))) - if err != nil { - impl.logger.Errorw("error in copying chart from temp dir to ref chart dir", "err", err) - return chartInfo, err - } - } - - chartInfo.ChartLocation = location - chartInfo.ChartName = chartName - chartInfo.ChartVersion = chartVersion - return chartInfo, nil -} - -func (impl ChartServiceImpl) ValidateReservedChartName(chartName string) (isReservedChart bool, err error) { - formattedChartName := impl.FormatChartName(chartName) - for _, reservedChart := range *ReservedChartRefNamesList { - isReservedChart = (reservedChart.LocationPrefix != "" && strings.HasPrefix(formattedChartName, reservedChart.LocationPrefix)) || - (reservedChart.Name != "" && strings.HasPrefix(strings.ToLower(chartName), reservedChart.Name)) - if isReservedChart { - return true, nil - } - } - return false, nil -} - -func (impl ChartServiceImpl) FetchCustomChartsInfo() ([]*ChartDto, error) { - resultsMetadata, err := impl.chartRefRepository.GetAllChartMetadata() - if err != nil { - impl.logger.Errorw("error in fetching chart metadata", "err", err) - return nil, err - } - chartsMetadata := make(map[string]string) - for _, resultMetadata := range resultsMetadata { - chartsMetadata[resultMetadata.ChartName] = resultMetadata.ChartDescription - } - repo, err := impl.chartRefRepository.GetAll() - if err != nil { - return nil, err - } - var chartDtos []*ChartDto - for _, ref := range repo { - if len(ref.Name) == 0 { - ref.Name = RolloutChartType - } - if description, ok := chartsMetadata[ref.Name]; ref.ChartDescription == "" && ok { - ref.ChartDescription = description - } - chartDto := &ChartDto{ - Id: ref.Id, - Name: ref.Name, - ChartDescription: ref.ChartDescription, - Version: ref.Version, - IsUserUploaded: ref.UserUploaded, - } - chartDtos = append(chartDtos, chartDto) - } - return chartDtos, err -} - -func (impl ChartServiceImpl) CheckCustomChartByAppId(id int) (bool, error) { +func (impl ChartServiceImpl) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) { chartInfo, err := impl.chartRepository.FindLatestChartForAppByAppId(id) if err != nil { return false, err } - chartData, err := impl.chartRefRepository.FindById(chartInfo.ChartRefId) + chartData, err := impl.chartRefService.FindById(chartInfo.ChartRefId) if err != nil { return false, err } return chartData.UserUploaded, err } - -func (impl ChartServiceImpl) CheckCustomChartByChartId(id int) (bool, error) { - chartData, err := impl.chartRefRepository.FindById(id) - if err != nil { - return false, err - } - return chartData.UserUploaded, nil -} - -func (impl ChartServiceImpl) GetCustomChartInBytes(chartRefId int) ([]byte, error) { - chartRef, err := impl.chartRefRepository.FindById(chartRefId) - if err != nil { - impl.logger.Errorw("error getting chart data", "chartRefId", chartRefId, "err", err) - return nil, err - } - // For user uploaded charts ChartData will be retrieved from DB - if chartRef.ChartData != nil { - return chartRef.ChartData, nil - } - // For Devtron reference charts the chart will be load from the directory location - refChartPath := filepath.Join(string(impl.refChartDir), chartRef.Location) - manifestByteArr, err := impl.chartTemplateService.LoadChartInBytes(refChartPath, false) - if err != nil { - impl.logger.Errorw("error in converting chart to bytes", "err", err) - return nil, err - } - return manifestByteArr, nil -} diff --git a/pkg/chart/ChartUtils.go b/pkg/chart/ChartUtils.go index 0d8b180b01..4702060352 100644 --- a/pkg/chart/ChartUtils.go +++ b/pkg/chart/ChartUtils.go @@ -2,8 +2,7 @@ package chart import ( "encoding/json" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" - "strings" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" ) func PatchWinterSoldierConfig(override json.RawMessage, newChartType string) (json.RawMessage, error) { @@ -38,9 +37,9 @@ func PatchWinterSoldierIfExists(newChartType string, jsonMap map[string]json.Raw return jsonMap, nil } switch newChartType { - case DeploymentChartType: + case bean.DeploymentChartType: winterSoldierUnmarshalled["type"] = json.RawMessage("\"Deployment\"") - case RolloutChartType: + case bean.RolloutChartType: winterSoldierUnmarshalled["type"] = json.RawMessage("\"Rollout\"") } @@ -52,20 +51,6 @@ func PatchWinterSoldierIfExists(newChartType string, jsonMap map[string]json.Raw return jsonMap, nil } -func SetReservedChartList(devtronChartList []*chartRepoRepository.ChartRef) { - reservedChartRefNamesList := []ReservedChartList{ - {Name: strings.ToLower(RolloutChartType), LocationPrefix: ""}, - {Name: "", LocationPrefix: ReferenceChart}, - } - for _, devtronChart := range devtronChartList { - reservedChartRefNamesList = append(reservedChartRefNamesList, ReservedChartList{ - Name: strings.ToLower(devtronChart.Name), - LocationPrefix: strings.Split(devtronChart.Location, "_")[0], - }) - } - ReservedChartRefNamesList = &reservedChartRefNamesList -} - //func IsFlaggerCanaryEnabled(override json.RawMessage) (bool, error) { // //} diff --git a/pkg/chart/bean.go b/pkg/chart/bean.go index c3dce0a3b1..fbedc8b0c2 100644 --- a/pkg/chart/bean.go +++ b/pkg/chart/bean.go @@ -5,11 +5,6 @@ import ( "github.com/devtron-labs/devtron/internal/sql/models" ) -const ( - CHART_ALREADY_EXISTS_INTERNAL_ERROR = "Chart exists already, try uploading another chart" - CHART_NAME_RESERVED_INTERNAL_ERROR = "Change the name of the chart and try uploading again" -) - var ReservedChartRefNamesList *[]ReservedChartList type ReservedChartList struct { diff --git a/pkg/chartRepo/repository/ChartRefRepository.go b/pkg/chartRepo/repository/ChartRefRepository.go index 4c4c9adfc1..33f9d69fc5 100644 --- a/pkg/chartRepo/repository/ChartRefRepository.go +++ b/pkg/chartRepo/repository/ChartRefRepository.go @@ -7,7 +7,10 @@ import ( "strings" ) -type RefChartDir string +const ( + RefChartDirPath = "scripts/devtron-reference-helm-charts" +) + type ChartRef struct { tableName struct{} `sql:"chart_ref" pg:",discard_unknown_columns"` Id int `sql:"id,pk"` diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index b04de22cff..d62d5a5fd1 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -4,8 +4,8 @@ import ( "context" interalRepo "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.opentelemetry.io/otel" @@ -23,20 +23,20 @@ type DeployedAppMetricsService interface { type DeployedAppMetricsServiceImpl struct { logger *zap.SugaredLogger - chartRefRepository chartRepoRepository.ChartRefRepository appLevelMetricsRepository interalRepo.AppLevelMetricsRepository envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository + chartRefService chartRef.ChartRefService } func NewDeployedAppMetricsServiceImpl(logger *zap.SugaredLogger, - chartRefRepository chartRepoRepository.ChartRefRepository, appLevelMetricsRepository interalRepo.AppLevelMetricsRepository, - envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository) *DeployedAppMetricsServiceImpl { + envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository, + chartRefService chartRef.ChartRefService) *DeployedAppMetricsServiceImpl { return &DeployedAppMetricsServiceImpl{ logger: logger, - chartRefRepository: chartRefRepository, appLevelMetricsRepository: appLevelMetricsRepository, envLevelMetricsRepository: envLevelMetricsRepository, + chartRefService: chartRefService, } } @@ -134,7 +134,7 @@ func (impl *DeployedAppMetricsServiceImpl) DeleteEnvLevelMetricsIfPresent(appId, } func (impl *DeployedAppMetricsServiceImpl) checkIsAppMetricsSupported(chartRefId int) (bool, error) { - chartRefValue, err := impl.chartRefRepository.FindById(chartRefId) + chartRefValue, err := impl.chartRefService.FindById(chartRefId) if err != nil { impl.logger.Errorw("error in finding reference chart by id", "err", err) return false, nil diff --git a/pkg/chart/ChartCompatibility.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartCompatibility.go similarity index 67% rename from pkg/chart/ChartCompatibility.go rename to pkg/deployment/manifest/deploymentTemplate/chartRef/ChartCompatibility.go index 4c1fb3cd71..cee6fcfff9 100644 --- a/pkg/chart/ChartCompatibility.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartCompatibility.go @@ -1,16 +1,12 @@ -package chart +package chartRef -type stringSet map[string]struct{} +import "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" -const ( - DeploymentChartType = "Deployment" - RolloutChartType = "Rollout Deployment" - ReferenceChart = "reference-chart" -) +type stringSet map[string]struct{} var chartCompatibilityMatrix = map[string]stringSet{ - DeploymentChartType: {RolloutChartType: {}, DeploymentChartType: {}}, - RolloutChartType: {DeploymentChartType: {}, RolloutChartType: {}}, + bean.DeploymentChartType: {bean.RolloutChartType: {}, bean.DeploymentChartType: {}}, + bean.RolloutChartType: {bean.DeploymentChartType: {}, bean.RolloutChartType: {}}, } func CheckCompatibility(oldChartType, newChartType string) bool { diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go new file mode 100644 index 0000000000..0bfd0bd278 --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -0,0 +1,494 @@ +package chartRef + +import ( + "bytes" + "errors" + "fmt" + "github.com/devtron-labs/devtron/internal/constants" + "github.com/devtron-labs/devtron/internal/util" + chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/adapter" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" + util2 "github.com/devtron-labs/devtron/util" + dirCopy "github.com/otiai10/copy" + "go.uber.org/zap" + "io/ioutil" + "k8s.io/helm/pkg/chartutil" + "os" + "path" + "path/filepath" + "sigs.k8s.io/yaml" + "strconv" + "strings" +) + +type ChartRefService interface { + GetDefault() (*bean.ChartRefDto, error) + GetAll() ([]*bean.ChartRefDto, error) + GetAllChartMetadata() (map[string]bean.ChartRefMetaData, error) + FindById(chartRefId int) (*bean.ChartRefDto, error) + FindByVersionAndName(version, name string) (*bean.ChartRefDto, error) + FetchInfoOfChartConfiguredInApp(appId int) (*bean.ChartRefDto, error) + ChartRefAutocomplete() ([]*bean.ChartRefAutocompleteDto, error) + + SaveCustomChart(req *bean.CustomChartRefDto) error + FetchCustomChartsInfo() ([]*bean.ChartDto, error) + + ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) + + CheckChartExists(chartRefId int) error + GetRefChart(chartRefId int) (string, string, error, string, string) + ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*bean.ChartDataInfo, error) + GetCustomChartInBytes(chartRefId int) ([]byte, error) +} + +type ChartRefServiceImpl struct { + logger *zap.SugaredLogger + chartRefRepository chartRepoRepository.ChartRefRepository + chartTemplateService util.ChartTemplateService +} + +func NewChartRefServiceImpl(logger *zap.SugaredLogger, + chartRefRepository chartRepoRepository.ChartRefRepository, + chartTemplateService util.ChartTemplateService) *ChartRefServiceImpl { + // cache devtron reference charts list + devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) + setReservedChartList(devtronChartList) + return &ChartRefServiceImpl{ + logger: logger, + chartRefRepository: chartRefRepository, + chartTemplateService: chartTemplateService, + } +} + +func (impl *ChartRefServiceImpl) GetDefault() (*bean.ChartRefDto, error) { + chartRef, err := impl.chartRefRepository.GetDefault() + if err != nil { + impl.logger.Errorw("error in getting default chartRef", "err", err) + return nil, err + } + return adapter.ConvertChartRefDbObjToBean(chartRef), nil +} + +func (impl *ChartRefServiceImpl) GetAll() ([]*bean.ChartRefDto, error) { + chartRefs, err := impl.chartRefRepository.GetAll() + if err != nil { + impl.logger.Errorw("error in getting all chartRefs", "err", err) + return nil, err + } + chartRefDtos := make([]*bean.ChartRefDto, 0, len(chartRefs)) + for _, chartRef := range chartRefs { + chartRefDtos = append(chartRefDtos, adapter.ConvertChartRefDbObjToBean(chartRef)) + } + return chartRefDtos, nil +} + +func (impl *ChartRefServiceImpl) GetAllChartMetadata() (map[string]bean.ChartRefMetaData, error) { + chartRefMetadatas, err := impl.chartRefRepository.GetAllChartMetadata() + if err != nil { + impl.logger.Errorw("error in getting all chart metadatas", "err", err) + return nil, err + } + chartsMetadataMap := make(map[string]bean.ChartRefMetaData, len(chartRefMetadatas)) + for _, chartRefMetadata := range chartRefMetadatas { + metadataDto := bean.ChartRefMetaData{ + ChartDescription: chartRefMetadata.ChartDescription, + } + chartsMetadataMap[chartRefMetadata.ChartName] = metadataDto + } + return chartsMetadataMap, nil +} +func (impl *ChartRefServiceImpl) ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) { + oldChart, err := impl.FindById(oldChartRefId) + if err != nil { + return false, "", "" + } + newChart, err := impl.FindById(newChartRefId) + if err != nil { + return false, "", "" + } + return CheckCompatibility(oldChart.Name, newChart.Name), oldChart.Name, newChart.Name +} + +func (impl *ChartRefServiceImpl) FindById(chartRefId int) (*bean.ChartRefDto, error) { + chartRef, err := impl.chartRefRepository.FindById(chartRefId) + if err != nil { + impl.logger.Errorw("error in getting chartRef by id", "err", err, "chartRefId", chartRefId) + return nil, err + } + return adapter.ConvertChartRefDbObjToBean(chartRef), nil +} + +func (impl *ChartRefServiceImpl) FindByVersionAndName(version, name string) (*bean.ChartRefDto, error) { + chartRef, err := impl.chartRefRepository.FindByVersionAndName(name, version) + if err != nil { + impl.logger.Errorw("error in getting chartRef by version and name", "err", err, "version", version, "name", name) + return nil, err + } + return adapter.ConvertChartRefDbObjToBean(chartRef), nil +} + +func (impl *ChartRefServiceImpl) FetchInfoOfChartConfiguredInApp(appId int) (*bean.ChartRefDto, error) { + chartRef, err := impl.chartRefRepository.FetchInfoOfChartConfiguredInApp(appId) + if err != nil { + impl.logger.Errorw("error in getting chart info for chart configured in app", "err", err, "appId", appId) + return nil, err + } + return adapter.ConvertChartRefDbObjToBean(chartRef), nil +} + +func (impl *ChartRefServiceImpl) SaveCustomChart(req *bean.CustomChartRefDto) error { + chartRefDbObj := adapter.ConvertCustomChartRefDtoToDbObj(req) + err := impl.chartRefRepository.Save(chartRefDbObj) + if err != nil { + impl.logger.Errorw("error in saving chart ref", "err", err, "chartRef", chartRefDbObj) + return err + } + return nil +} + +func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, error, string, string) { + var template string + var version string + //path of file in chart from where strategy config is to be taken + var pipelineStrategyPath string + if chartRefId > 0 { + chartRef, err := impl.chartRefRepository.FindById(chartRefId) + if err != nil { + chartRef, err = impl.chartRefRepository.GetDefault() + if err != nil { + return "", "", err, "", "" + } + } else if chartRef.UserUploaded { + refChartLocation := filepath.Join(chartRepoRepository.RefChartDirPath, chartRef.Location) + if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { + chartInfo, err := impl.ExtractChartIfMissing(chartRef.ChartData, chartRepoRepository.RefChartDirPath, chartRef.Location) + if chartInfo != nil && chartInfo.TemporaryFolder != "" { + err1 := os.RemoveAll(chartInfo.TemporaryFolder) + if err1 != nil { + impl.logger.Errorw("error in deleting temp dir ", "err", err) + } + } + if err != nil { + impl.logger.Errorw("Error regarding uploaded chart", "err", err) + return "", "", err, "", "" + } + + } + } + template = chartRef.Location + version = chartRef.Version + pipelineStrategyPath = chartRef.DeploymentStrategyPath + } else { + chartRef, err := impl.chartRefRepository.GetDefault() + if err != nil { + return "", "", err, "", "" + } + template = chartRef.Location + version = chartRef.Version + pipelineStrategyPath = chartRef.DeploymentStrategyPath + } + + //TODO VIKI- fetch from chart ref table + chartPath := path.Join(chartRepoRepository.RefChartDirPath, template) + valid, err := chartutil.IsChartDir(chartPath) + if err != nil || !valid { + impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) + return "", "", err, "", "" + } + return chartPath, template, nil, version, pipelineStrategyPath +} + +func (impl *ChartRefServiceImpl) ChartRefAutocomplete() ([]*bean.ChartRefAutocompleteDto, error) { + var chartRefs []*bean.ChartRefAutocompleteDto + results, err := impl.chartRefRepository.GetAll() + if err != nil { + impl.logger.Errorw("error in fetching chart config", "err", err) + return chartRefs, err + } + + for _, result := range results { + chartRefs = append(chartRefs, &bean.ChartRefAutocompleteDto{ + Id: result.Id, + Version: result.Version, + Description: result.ChartDescription, + UserUploaded: result.UserUploaded, + IsAppMetricsSupported: result.IsAppMetricsSupported, + }) + } + + return chartRefs, nil +} + +func (impl *ChartRefServiceImpl) GetCustomChartInBytes(chartRefId int) ([]byte, error) { + chartRef, err := impl.chartRefRepository.FindById(chartRefId) + if err != nil { + impl.logger.Errorw("error getting chart data", "chartRefId", chartRefId, "err", err) + return nil, err + } + // For user uploaded charts ChartData will be retrieved from DB + if chartRef.ChartData != nil { + return chartRef.ChartData, nil + } + // For Devtron reference charts the chart will be load from the directory location + refChartPath := filepath.Join(chartRepoRepository.RefChartDirPath, chartRef.Location) + manifestByteArr, err := impl.chartTemplateService.LoadChartInBytes(refChartPath, false) + if err != nil { + impl.logger.Errorw("error in converting chart to bytes", "err", err) + return nil, err + } + return manifestByteArr, nil +} + +func (impl *ChartRefServiceImpl) FetchCustomChartsInfo() ([]*bean.ChartDto, error) { + resultsMetadata, err := impl.chartRefRepository.GetAllChartMetadata() + if err != nil { + impl.logger.Errorw("error in fetching chart metadata", "err", err) + return nil, err + } + chartsMetadata := make(map[string]string) + for _, resultMetadata := range resultsMetadata { + chartsMetadata[resultMetadata.ChartName] = resultMetadata.ChartDescription + } + repo, err := impl.chartRefRepository.GetAll() + if err != nil { + return nil, err + } + var chartDtos []*bean.ChartDto + for _, ref := range repo { + if len(ref.Name) == 0 { + ref.Name = bean.RolloutChartType + } + if description, ok := chartsMetadata[ref.Name]; ref.ChartDescription == "" && ok { + ref.ChartDescription = description + } + chartDto := &bean.ChartDto{ + Id: ref.Id, + Name: ref.Name, + ChartDescription: ref.ChartDescription, + Version: ref.Version, + IsUserUploaded: ref.UserUploaded, + } + chartDtos = append(chartDtos, chartDto) + } + return chartDtos, err +} + +func (impl *ChartRefServiceImpl) CheckChartExists(chartRefId int) error { + chartRefValue, err := impl.chartRefRepository.FindById(chartRefId) + if err != nil { + impl.logger.Errorw("error in finding ref chart by id", "err", err) + return err + } + refChartLocation := filepath.Join(chartRepoRepository.RefChartDirPath, chartRefValue.Location) + if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { + chartInfo, err := impl.ExtractChartIfMissing(chartRefValue.ChartData, chartRepoRepository.RefChartDirPath, chartRefValue.Location) + if chartInfo != nil && chartInfo.TemporaryFolder != "" { + err1 := os.RemoveAll(chartInfo.TemporaryFolder) + if err1 != nil { + impl.logger.Errorw("error in deleting temp dir ", "err", err) + } + } + return err + } + return nil +} + +func (impl *ChartRefServiceImpl) ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*bean.ChartDataInfo, error) { + binaryDataReader := bytes.NewReader(chartData) + dir := impl.chartTemplateService.GetDir() + chartInfo := &bean.ChartDataInfo{ + ChartName: "", + ChartVersion: "", + ChartLocation: "", + TemporaryFolder: "", + Description: "", + Message: "", + } + temporaryChartWorkingDir := filepath.Clean(filepath.Join(refChartDir, dir)) + err := os.MkdirAll(temporaryChartWorkingDir, os.ModePerm) + if err != nil { + impl.logger.Errorw("error in creating directory, CallbackConfigMap", "err", err) + return chartInfo, err + } + chartInfo.TemporaryFolder = temporaryChartWorkingDir + err = util2.ExtractTarGz(binaryDataReader, temporaryChartWorkingDir) + if err != nil { + impl.logger.Errorw("error in extracting binary data of charts", "err", err) + return chartInfo, err + } + + var chartLocation string + var chartName string + var chartVersion string + var fileName string + + files, err := ioutil.ReadDir(temporaryChartWorkingDir) + if err != nil { + impl.logger.Errorw("error in reading err dir", "err", err) + return chartInfo, err + } + + fileName = files[0].Name() + if strings.HasPrefix(files[0].Name(), ".") { + fileName = files[1].Name() + } + + currentChartWorkingDir := filepath.Clean(filepath.Join(temporaryChartWorkingDir, fileName)) + + if location == "" { + chartYaml, err := impl.readChartMetaDataForLocation(temporaryChartWorkingDir, fileName) + var errorList error + if err != nil { + impl.logger.Errorw("Chart yaml file or content not found") + errorList = err + } + + err = util2.CheckForMissingFiles(currentChartWorkingDir) + if err != nil { + impl.logger.Errorw("Missing files in the folder", "err", err) + if errorList != nil { + errorList = errors.New(errorList.Error() + "; " + err.Error()) + } else { + errorList = err + } + + } + + if errorList != nil { + return chartInfo, errorList + } + + chartName = chartYaml.Name + chartVersion = chartYaml.Version + chartInfo.Description = chartYaml.Description + chartLocation = impl.getLocationFromChartNameAndVersion(chartName, chartVersion) + location = chartLocation + + // Validate: chart name shouldn't conflict with Devtron charts (no user uploaded chart names should contain any devtron chart names as the prefix) + isReservedChart, _ := impl.validateReservedChartName(chartName) + if isReservedChart { + impl.logger.Errorw("request err, chart name is reserved by Devtron") + err = &util.ApiError{ + Code: constants.ChartNameAlreadyReserved, + InternalMessage: bean.CHART_NAME_RESERVED_INTERNAL_ERROR, + UserMessage: fmt.Sprintf("The name '%s' is reserved for a chart provided by Devtron", chartName), + } + return chartInfo, err + } + + // Validate: chart location should be unique + exists, err := impl.chartRefRepository.CheckIfDataExists(location) + if err != nil { + impl.logger.Errorw("Error in searching the database") + return chartInfo, err + } + if exists { + impl.logger.Errorw("request err, chart name and version exists already in the database") + err = &util.ApiError{ + Code: constants.ChartCreatedAlreadyExists, + InternalMessage: bean.CHART_ALREADY_EXISTS_INTERNAL_ERROR, + UserMessage: fmt.Sprintf("%s of %s exists already in the database", chartVersion, chartName), + } + return chartInfo, err + } + + //User Info Message: uploading new version of the existing chart name + existingChart, err := impl.chartRefRepository.FetchChart(chartName) + if err == nil && existingChart != nil { + chartInfo.Message = "New Version detected for " + existingChart[0].Name + } + + } else { + err = dirCopy.Copy(currentChartWorkingDir, filepath.Clean(filepath.Join(refChartDir, location))) + if err != nil { + impl.logger.Errorw("error in copying chart from temp dir to ref chart dir", "err", err) + return chartInfo, err + } + } + + chartInfo.ChartLocation = location + chartInfo.ChartName = chartName + chartInfo.ChartVersion = chartVersion + return chartInfo, nil +} + +func (impl *ChartRefServiceImpl) readChartMetaDataForLocation(chartDir string, fileName string) (*bean.ChartYamlStruct, error) { + chartLocation := filepath.Clean(filepath.Join(chartDir, fileName)) + + chartYamlPath := filepath.Clean(filepath.Join(chartLocation, "Chart.yaml")) + if _, err := os.Stat(chartYamlPath); os.IsNotExist(err) { + return nil, fmt.Errorf("Chart.yaml file not present in the directory") + } + + data, err := ioutil.ReadFile(chartYamlPath) + if err != nil { + impl.logger.Errorw("failed reading data from file", "err", err) + return nil, err + } + //println(data) + var chartYaml bean.ChartYamlStruct + err = yaml.Unmarshal(data, &chartYaml) + if err != nil { + impl.logger.Errorw("Unmarshal error of yaml file", "err", err) + return nil, err + } + if chartYaml.Name == "" || chartYaml.Version == "" { + impl.logger.Errorw("Missing values in yaml file either name or version", "err", err) + return nil, errors.New("Missing values in yaml file either name or version") + } + ver := strings.Split(chartYaml.Version, ".") + if len(ver) == 3 { + for _, verObject := range ver { + if _, err := strconv.ParseInt(verObject, 10, 64); err != nil { + return nil, errors.New("Version should contain integers (Ex: 1.1.0)") + } + } + return &chartYaml, nil + } + return nil, errors.New("Version should be of length 3 integers with dot seperated (Ex: 1.1.0)") +} + +func (impl *ChartRefServiceImpl) validateReservedChartName(chartName string) (isReservedChart bool, err error) { + formattedChartName := impl.formatChartName(chartName) + for _, reservedChart := range *bean.ReservedChartRefNamesList { + isReservedChart = (reservedChart.LocationPrefix != "" && strings.HasPrefix(formattedChartName, reservedChart.LocationPrefix)) || + (reservedChart.Name != "" && strings.HasPrefix(strings.ToLower(chartName), reservedChart.Name)) + if isReservedChart { + return true, nil + } + } + return false, nil +} + +func (impl *ChartRefServiceImpl) getLocationFromChartNameAndVersion(chartName string, chartVersion string) string { + var chartLocation string + chartname := impl.formatChartName(chartName) + chartversion := strings.ReplaceAll(chartVersion, ".", "-") + if !strings.Contains(chartname, chartversion) { + chartLocation = chartname + "_" + chartversion + } else { + chartLocation = chartname + } + return chartLocation +} + +func (impl *ChartRefServiceImpl) formatChartName(chartName string) string { + chartname := strings.ReplaceAll(chartName, ".", "-") + chartname = strings.ReplaceAll(chartname, " ", "_") + return chartname +} + +func setReservedChartList(devtronChartList []*chartRepoRepository.ChartRef) { + reservedChartRefNamesList := []bean.ReservedChartList{ + {Name: strings.ToLower(bean.RolloutChartType), LocationPrefix: ""}, + {Name: "", LocationPrefix: bean.ReferenceChart}, + } + for _, devtronChart := range devtronChartList { + reservedChartRefNamesList = append(reservedChartRefNamesList, bean.ReservedChartList{ + Name: strings.ToLower(devtronChart.Name), + LocationPrefix: strings.Split(devtronChart.Location, "_")[0], + }) + } + bean.ReservedChartRefNamesList = &reservedChartRefNamesList +} diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/adapter/adapter.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/adapter/adapter.go new file mode 100644 index 0000000000..6e2ec31658 --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/adapter/adapter.go @@ -0,0 +1,45 @@ +package adapter + +import ( + chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" +) + +func ConvertChartRefDbObjToBean(ref *chartRepoRepository.ChartRef) *bean.ChartRefDto { + dto := &bean.ChartRefDto{ + Id: ref.Id, + Location: ref.Location, + Version: ref.Version, + Default: ref.Default, + ChartData: ref.ChartData, + ChartDescription: ref.ChartDescription, + UserUploaded: ref.UserUploaded, + IsAppMetricsSupported: ref.IsAppMetricsSupported, + DeploymentStrategyPath: ref.DeploymentStrategyPath, + JsonPathForStrategy: ref.JsonPathForStrategy, + } + if len(ref.Name) == 0 { + dto.Name = bean.RolloutChartType + } else { + dto.Name = ref.Name + } + return dto +} + +func ConvertCustomChartRefDtoToDbObj(ref *bean.CustomChartRefDto) *chartRepoRepository.ChartRef { + return &chartRepoRepository.ChartRef{ + Id: ref.Id, + Location: ref.Location, + Version: ref.Version, + Active: ref.Active, + Default: ref.Default, + Name: ref.Name, + ChartData: ref.ChartData, + ChartDescription: ref.ChartDescription, + UserUploaded: ref.UserUploaded, + IsAppMetricsSupported: ref.IsAppMetricsSupported, + DeploymentStrategyPath: ref.DeploymentStrategyPath, + JsonPathForStrategy: ref.JsonPathForStrategy, + AuditLog: ref.AuditLog, + } +} diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go new file mode 100644 index 0000000000..b0f662e04e --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go @@ -0,0 +1,95 @@ +package bean + +import "github.com/devtron-labs/devtron/pkg/sql" + +const ( + DeploymentChartType = "Deployment" + RolloutChartType = "Rollout Deployment" + ReferenceChart = "reference-chart" + CHART_ALREADY_EXISTS_INTERNAL_ERROR = "Chart exists already, try uploading another chart" + CHART_NAME_RESERVED_INTERNAL_ERROR = "Change the name of the chart and try uploading again" +) + +type ChartDataInfo struct { + ChartLocation string `json:"chartLocation"` + ChartName string `json:"chartName"` + ChartVersion string `json:"chartVersion"` + TemporaryFolder string `json:"temporaryFolder"` + Description string `json:"description"` + Message string `json:"message"` +} + +type ChartYamlStruct struct { + Name string `yaml:"name"` + Version string `yaml:"version"` + Description string `yaml:"description"` +} + +var ReservedChartRefNamesList *[]ReservedChartList + +type ReservedChartList struct { + LocationPrefix string + Name string +} + +type ChartRefDto struct { + Id int `json:"id"` + Location string `json:"location"` + Version string `json:"version"` + Default bool `json:"isDefault"` + Name string `json:"name"` + ChartData []byte `json:"chartData"` + ChartDescription string `json:"chartDescription"` + UserUploaded bool `json:"userUploaded,notnull"` + IsAppMetricsSupported bool `json:"isAppMetricsSupported"` + DeploymentStrategyPath string `json:"deploymentStrategyPath"` + JsonPathForStrategy string `json:"jsonPathForStrategy"` +} + +// TODO: below objects are created/moved while refactoring to remove db object usage, to remove/replace them with the common objects mentioned above + +type CustomChartRefDto struct { + Id int `sql:"id,pk"` + Location string `sql:"location"` + Version string `sql:"version"` + Active bool `sql:"active,notnull"` + Default bool `sql:"is_default,notnull"` + Name string `sql:"name"` + ChartData []byte `sql:"chart_data"` + ChartDescription string `sql:"chart_description"` + UserUploaded bool `sql:"user_uploaded,notnull"` + IsAppMetricsSupported bool `sql:"is_app_metrics_supported,notnull"` + DeploymentStrategyPath string `sql:"deployment_strategy_path"` + JsonPathForStrategy string `sql:"json_path_for_strategy"` + sql.AuditLog +} + +type ChartRefAutocompleteDto struct { + Id int `json:"id"` + Version string `json:"version"` + Name string `json:"name"` + Description string `json:"description"` + UserUploaded bool `json:"userUploaded"` + IsAppMetricsSupported bool `json:"isAppMetricsSupported"` +} + +type ChartRefMetaData struct { + ChartDescription string `json:"chartDescription"` +} + +type ChartRefAutocompleteResponse struct { + ChartRefs []ChartRefAutocompleteDto `json:"chartRefs"` + LatestChartRef int `json:"latestChartRef"` + LatestAppChartRef int `json:"latestAppChartRef"` + LatestEnvChartRef int `json:"latestEnvChartRef,omitempty"` + ChartsMetadata map[string]ChartRefMetaData `json:"chartMetadata"` // chartName vs Metadata + CompatibleChartTypes []string `json:"compatibleChartTypes,omitempty"` +} + +type ChartDto struct { + Id int `json:"id"` + Name string `json:"name"` + ChartDescription string `json:"chartDescription"` + Version string `json:"version"` + IsUserUploaded bool `json:"isUserUploaded"` +} diff --git a/pkg/deployment/manifest/wire_deployment_manifest.go b/pkg/deployment/manifest/wire_deployment_manifest.go new file mode 100644 index 0000000000..fe6d1a6e61 --- /dev/null +++ b/pkg/deployment/manifest/wire_deployment_manifest.go @@ -0,0 +1,17 @@ +package manifest + +import ( + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + "github.com/google/wire" +) + +var DeploymentManifestWireSet = wire.NewSet( + deployedAppMetrics.NewDeployedAppMetricsServiceImpl, + wire.Bind(new(deployedAppMetrics.DeployedAppMetricsService), new(*deployedAppMetrics.DeployedAppMetricsServiceImpl)), + deploymentTemplate.NewDeploymentTemplateServiceImpl, + wire.Bind(new(deploymentTemplate.DeploymentTemplateService), new(*deploymentTemplate.DeploymentTemplateServiceImpl)), + chartRef.NewChartRefServiceImpl, + wire.Bind(new(chartRef.ChartRefService), new(*chartRef.ChartRefServiceImpl)), +) diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index be120b5daa..1cb3023bf7 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -13,6 +13,7 @@ import ( "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/history" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" @@ -84,6 +85,7 @@ type DeploymentTemplateServiceImpl struct { environmentRepository repository3.EnvironmentRepository appRepository appRepository.AppRepository scopedVariableManager variables.ScopedVariableManager + chartRefService chartRef.ChartRefService } func NewDeploymentTemplateServiceImpl(Logger *zap.SugaredLogger, chartService chart.ChartService, @@ -100,7 +102,7 @@ func NewDeploymentTemplateServiceImpl(Logger *zap.SugaredLogger, chartService ch environmentRepository repository3.EnvironmentRepository, appRepository appRepository.AppRepository, scopedVariableManager variables.ScopedVariableManager, -) *DeploymentTemplateServiceImpl { + chartRefService chartRef.ChartRefService) *DeploymentTemplateServiceImpl { return &DeploymentTemplateServiceImpl{ Logger: Logger, chartService: chartService, @@ -117,6 +119,7 @@ func NewDeploymentTemplateServiceImpl(Logger *zap.SugaredLogger, chartService ch environmentRepository: environmentRepository, appRepository: appRepository, scopedVariableManager: scopedVariableManager, + chartRefService: chartRefService, } } @@ -301,7 +304,7 @@ func (impl DeploymentTemplateServiceImpl) extractScopeData(request DeploymentTem } func (impl DeploymentTemplateServiceImpl) GenerateManifest(ctx context.Context, chartRefId int, valuesYaml string) (*openapi2.TemplateChartResponse, error) { - refChart, template, err, version, _ := impl.chartService.GetRefChart(chart.TemplateRequest{ChartRefId: chartRefId}) + refChart, template, err, version, _ := impl.chartRefService.GetRefChart(chartRefId) if err != nil { impl.Logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) return nil, err diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index 1e5a57c615..f12c90c9e0 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -8,6 +8,7 @@ import ( "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/pipeline/history" repository2 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" @@ -31,9 +32,9 @@ type DeploymentConfigServiceImpl struct { pipelineConfigRepository chartConfig.PipelineConfigRepository configMapRepository chartConfig.ConfigMapRepository configMapHistoryService history.ConfigMapHistoryService - chartRefRepository chartRepoRepository.ChartRefRepository scopedVariableManager variables.ScopedVariableCMCSManager deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, @@ -43,9 +44,9 @@ func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, pipelineConfigRepository chartConfig.PipelineConfigRepository, configMapRepository chartConfig.ConfigMapRepository, configMapHistoryService history.ConfigMapHistoryService, - chartRefRepository chartRepoRepository.ChartRefRepository, scopedVariableManager variables.ScopedVariableCMCSManager, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentConfigServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) *DeploymentConfigServiceImpl { return &DeploymentConfigServiceImpl{ logger: logger, envConfigOverrideRepository: envConfigOverrideRepository, @@ -54,9 +55,9 @@ func NewDeploymentConfigServiceImpl(logger *zap.SugaredLogger, pipelineConfigRepository: pipelineConfigRepository, configMapRepository: configMapRepository, configMapHistoryService: configMapHistoryService, - chartRefRepository: chartRefRepository, scopedVariableManager: scopedVariableManager, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } } @@ -107,7 +108,7 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx c deploymentTemplateConfig := &history.HistoryDetailDto{} if envOverride != nil && envOverride.Id > 0 && envOverride.IsOverride { if envOverride.Chart != nil { - chartRef, err := impl.chartRefRepository.FindById(envOverride.Chart.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(envOverride.Chart.ChartRefId) if err != nil { impl.logger.Errorw("error in getting chartRef by id", "err", err, "chartRefId", envOverride.Chart.ChartRefId) return nil, err @@ -132,7 +133,7 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx c deploymentTemplateConfig = &history.HistoryDetailDto{ TemplateName: envOverride.Chart.ChartName, - TemplateVersion: chartRef.Version, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: &isAppMetricsEnabled, CodeEditorValue: &history.HistoryDetailConfig{ DisplayName: "values.yaml", @@ -148,7 +149,7 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx c impl.logger.Errorw("error in getting chart by appId", "err", err, "appId", pipeline.AppId) return nil, err } - chartRef, err := impl.chartRefRepository.FindById(chart.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(chart.ChartRefId) if err != nil { impl.logger.Errorw("error in getting chartRef by id", "err", err, "chartRefId", envOverride.Chart.ChartRefId) return nil, err @@ -173,7 +174,7 @@ func (impl *DeploymentConfigServiceImpl) GetLatestDeploymentTemplateConfig(ctx c } deploymentTemplateConfig = &history.HistoryDetailDto{ TemplateName: chart.ChartName, - TemplateVersion: chartRef.Version, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: &isAppMetricsEnabled, CodeEditorValue: &history.HistoryDetailConfig{ DisplayName: "values.yaml", diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 686042bd65..24bdf83fc4 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -34,10 +34,8 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/history" "github.com/devtron-labs/devtron/pkg/sql" - "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/util" "github.com/go-pg/pg" "github.com/juju/errors" "go.uber.org/zap" @@ -62,11 +60,7 @@ type PropertiesConfigServiceImpl struct { logger *zap.SugaredLogger envConfigRepo chartConfig.EnvConfigOverrideRepository chartRepo chartRepoRepository.ChartRepository - chartRefRepository chartRepoRepository.ChartRefRepository - mergeUtil util.MergeUtil environmentRepository repository2.EnvironmentRepository - ciCdPipelineOrchestrator CiCdPipelineOrchestrator - application application.ServiceClient deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService @@ -75,11 +69,7 @@ type PropertiesConfigServiceImpl struct { func NewPropertiesConfigServiceImpl(logger *zap.SugaredLogger, envConfigRepo chartConfig.EnvConfigOverrideRepository, chartRepo chartRepoRepository.ChartRepository, - chartRefRepository chartRepoRepository.ChartRefRepository, - mergeUtil util.MergeUtil, environmentRepository repository2.EnvironmentRepository, - ciCdPipelineOrchestrator CiCdPipelineOrchestrator, - application application.ServiceClient, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *PropertiesConfigServiceImpl { @@ -87,11 +77,7 @@ func NewPropertiesConfigServiceImpl(logger *zap.SugaredLogger, logger: logger, envConfigRepo: envConfigRepo, chartRepo: chartRepo, - chartRefRepository: chartRefRepository, - mergeUtil: mergeUtil, environmentRepository: environmentRepository, - ciCdPipelineOrchestrator: ciCdPipelineOrchestrator, - application: application, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, deployedAppMetricsService: deployedAppMetricsService, diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 7a86482794..8e45fdbe51 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -23,6 +23,7 @@ import ( errors3 "errors" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "path" "strconv" "strings" @@ -42,10 +43,8 @@ import ( application2 "github.com/devtron-labs/devtron/client/argocdServer/application" gitSensorClient "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/internal/middleware" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" bean4 "github.com/devtron-labs/devtron/pkg/app/bean" "github.com/devtron-labs/devtron/pkg/app/status" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/dockerRegistry" @@ -130,11 +129,8 @@ type WorkflowDagExecutorImpl struct { pipelineOverrideRepository chartConfig.PipelineOverrideRepository ciArtifactRepository repository.CiArtifactRepository user user.UserService - enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil groupRepository repository.DeploymentGroupRepository - tokenCache *util3.TokenCache - acdAuthConfig *util3.ACDAuthConfig envRepository repository2.EnvironmentRepository eventFactory client.EventFactory eventClient client.EventClient @@ -150,15 +146,13 @@ type WorkflowDagExecutorImpl struct { appLabelRepository pipelineConfig.AppLabelRepository gitSensorGrpcClient gitSensorClient.Client k8sCommonService k8s.K8sCommonService - pipelineStageRepository repository4.PipelineStageRepository pipelineStageService PipelineStageService config *types.CdConfig appServiceConfig *app.AppServiceConfig globalPluginService plugin.GlobalPluginService - scopedVariableManager variables.ScopedVariableCMCSManager - variableSnapshotHistoryService variables.VariableSnapshotHistoryService - pluginInputVariableParser PluginInputVariableParser + scopedVariableManager variables.ScopedVariableCMCSManager + pluginInputVariableParser PluginInputVariableParser devtronAsyncHelmInstallRequestMap map[int]bool devtronAsyncHelmInstallRequestLock *sync.Mutex @@ -179,15 +173,12 @@ type WorkflowDagExecutorImpl struct { chartRepository chartRepoRepository.ChartRepository chartTemplateService util.ChartTemplateService strategyHistoryRepository repository3.PipelineStrategyHistoryRepository - appRepository app2.AppRepository deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository argoK8sClient argocdServer.ArgoK8sClient configMapRepository chartConfig.ConfigMapRepository configMapHistoryRepository repository3.ConfigMapHistoryRepository - refChartDir chartRepoRepository.RefChartDir helmAppService client2.HelmAppService helmAppClient client2.HelmAppClient - chartRefRepository chartRepoRepository.ChartRefRepository environmentConfigRepository chartConfig.EnvConfigOverrideRepository dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil @@ -195,10 +186,10 @@ type WorkflowDagExecutorImpl struct { gitFactory *util.GitFactory acdClient application2.ServiceClient argoClientWrapperService argocdServer.ArgoClientWrapperService - pipelineConfigListenerService PipelineConfigListenerService customTagService CustomTagService ACDConfig *argocdServer.ACDConfig deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } const kedaAutoscaling = "kedaAutoscaling" @@ -254,8 +245,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi user user.UserService, groupRepository repository.DeploymentGroupRepository, envRepository repository2.EnvironmentRepository, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, tokenCache *util3.TokenCache, - acdAuthConfig *util3.ACDAuthConfig, eventFactory client.EventFactory, + enforcerUtil rbac.EnforcerUtil, eventFactory client.EventFactory, eventClient client.EventClient, cvePolicyRepository security.CvePolicyRepository, scanResultRepository security.ImageScanResultRepository, appWorkflowRepository appWorkflow.AppWorkflowRepository, @@ -267,7 +257,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi ciWorkflowRepository pipelineConfig.CiWorkflowRepository, appLabelRepository pipelineConfig.AppLabelRepository, gitSensorGrpcClient gitSensorClient.Client, pipelineStageService PipelineStageService, k8sCommonService k8s.K8sCommonService, - variableSnapshotHistoryService variables.VariableSnapshotHistoryService, globalPluginService plugin.GlobalPluginService, pluginInputVariableParser PluginInputVariableParser, scopedVariableManager variables.ScopedVariableCMCSManager, @@ -286,15 +275,12 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi chartRepository chartRepoRepository.ChartRepository, chartTemplateService util.ChartTemplateService, strategyHistoryRepository repository3.PipelineStrategyHistoryRepository, - appRepository app2.AppRepository, deploymentTemplateHistoryRepository repository3.DeploymentTemplateHistoryRepository, ArgoK8sClient argocdServer.ArgoK8sClient, configMapRepository chartConfig.ConfigMapRepository, configMapHistoryRepository repository3.ConfigMapHistoryRepository, - refChartDir chartRepoRepository.RefChartDir, helmAppService client2.HelmAppService, helmAppClient client2.HelmAppClient, - chartRefRepository chartRepoRepository.ChartRefRepository, environmentConfigRepository chartConfig.EnvConfigOverrideRepository, dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, @@ -305,7 +291,8 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi pipelineConfigListenerService PipelineConfigListenerService, customTagService CustomTagService, ACDConfig *argocdServer.ACDConfig, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *WorkflowDagExecutorImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, @@ -317,11 +304,8 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi materialRepository: materialRepository, pipelineOverrideRepository: pipelineOverrideRepository, user: user, - enforcer: enforcer, enforcerUtil: enforcerUtil, groupRepository: groupRepository, - tokenCache: tokenCache, - acdAuthConfig: acdAuthConfig, envRepository: envRepository, eventFactory: eventFactory, eventClient: eventClient, @@ -361,15 +345,12 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi chartRepository: chartRepository, chartTemplateService: chartTemplateService, strategyHistoryRepository: strategyHistoryRepository, - appRepository: appRepository, deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, argoK8sClient: ArgoK8sClient, configMapRepository: configMapRepository, configMapHistoryRepository: configMapHistoryRepository, - refChartDir: refChartDir, helmAppService: helmAppService, helmAppClient: helmAppClient, - chartRefRepository: chartRefRepository, environmentConfigRepository: environmentConfigRepository, dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, @@ -377,10 +358,10 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi gitFactory: gitFactory, acdClient: acdClient, argoClientWrapperService: argoClientWrapperService, - pipelineConfigListenerService: pipelineConfigListenerService, customTagService: customTagService, ACDConfig: ACDConfig, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } config, err := types.GetCdConfig() if err != nil { @@ -3471,7 +3452,7 @@ func (impl *WorkflowDagExecutorImpl) createHelmAppForCdPipeline(overrideRequest Name: pipeline.App.AppName, Version: envOverride.Chart.ChartVersion, } - referenceTemplatePath := path.Join(string(impl.refChartDir), envOverride.Chart.ReferenceTemplate) + referenceTemplatePath := path.Join(chartRepoRepository.RefChartDirPath, envOverride.Chart.ReferenceTemplate) if util.IsHelmApp(pipeline.DeploymentAppType) { referenceChartByte := envOverride.Chart.ReferenceChart @@ -3653,7 +3634,7 @@ func (impl *WorkflowDagExecutorImpl) GetEnvOverrideByTriggerType(overrideRequest } //getting chart_ref by id _, span = otel.Tracer("orchestrator").Start(ctx, "chartRefRepository.FindByVersionAndName") - chartRef, err := impl.chartRefRepository.FindByVersionAndName(templateName, templateVersion) + chartRefDto, err := impl.chartRefService.FindByVersionAndName(templateName, templateVersion) span.End() if err != nil { impl.logger.Errorw("error in getting chartRef by version and name", "err", err, "version", templateVersion, "name", templateName) @@ -3661,10 +3642,10 @@ func (impl *WorkflowDagExecutorImpl) GetEnvOverrideByTriggerType(overrideRequest } //assuming that if a chartVersion is deployed then it's envConfigOverride will be available _, span = otel.Tracer("orchestrator").Start(ctx, "environmentConfigRepository.GetByAppIdEnvIdAndChartRefId") - envOverride, err = impl.environmentConfigRepository.GetByAppIdEnvIdAndChartRefId(overrideRequest.AppId, overrideRequest.EnvId, chartRef.Id) + envOverride, err = impl.environmentConfigRepository.GetByAppIdEnvIdAndChartRefId(overrideRequest.AppId, overrideRequest.EnvId, chartRefDto.Id) span.End() if err != nil { - impl.logger.Errorw("error in getting envConfigOverride for pipeline for specific chartVersion", "err", err, "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "chartRefId", chartRef.Id) + impl.logger.Errorw("error in getting envConfigOverride for pipeline for specific chartVersion", "err", err, "appId", overrideRequest.AppId, "envId", overrideRequest.EnvId, "chartRefId", chartRefDto.Id) return nil, err } diff --git a/pkg/pipeline/history/DeploymentTemplateHistoryService.go b/pkg/pipeline/history/DeploymentTemplateHistoryService.go index beeae5af84..8871f9cd98 100644 --- a/pkg/pipeline/history/DeploymentTemplateHistoryService.go +++ b/pkg/pipeline/history/DeploymentTemplateHistoryService.go @@ -3,6 +3,7 @@ package history import ( "context" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "time" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" @@ -38,28 +39,28 @@ type DeploymentTemplateHistoryServiceImpl struct { deploymentTemplateHistoryRepository repository.DeploymentTemplateHistoryRepository pipelineRepository pipelineConfig.PipelineRepository chartRepository chartRepoRepository.ChartRepository - chartRefRepository chartRepoRepository.ChartRefRepository userService user.UserService cdWorkflowRepository pipelineConfig.CdWorkflowRepository scopedVariableManager variables.ScopedVariableManager deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewDeploymentTemplateHistoryServiceImpl(logger *zap.SugaredLogger, deploymentTemplateHistoryRepository repository.DeploymentTemplateHistoryRepository, pipelineRepository pipelineConfig.PipelineRepository, chartRepository chartRepoRepository.ChartRepository, - chartRefRepository chartRepoRepository.ChartRefRepository, userService user.UserService, - cdWorkflowRepository pipelineConfig.CdWorkflowRepository, scopedVariableManager variables.ScopedVariableManager, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *DeploymentTemplateHistoryServiceImpl { + userService user.UserService, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, + scopedVariableManager variables.ScopedVariableManager, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + chartRefService chartRef.ChartRefService) *DeploymentTemplateHistoryServiceImpl { return &DeploymentTemplateHistoryServiceImpl{ logger: logger, deploymentTemplateHistoryRepository: deploymentTemplateHistoryRepository, pipelineRepository: pipelineRepository, chartRepository: chartRepository, - chartRefRepository: chartRefRepository, userService: userService, cdWorkflowRepository: cdWorkflowRepository, scopedVariableManager: scopedVariableManager, deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } } @@ -70,22 +71,19 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory impl.logger.Errorw("err in getting pipelines, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chart", chart) return err } - chartRef, err := impl.chartRefRepository.FindById(chart.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(chart.ChartRefId) if err != nil { impl.logger.Errorw("err in getting chartRef, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chart", chart) return err } - if len(chartRef.Name) == 0 { - chartRef.Name = "Rollout Deployment" - } //creating history without pipeline id historyModel := &repository.DeploymentTemplateHistory{ AppId: chart.AppId, ImageDescriptorTemplate: chart.ImageDescriptorTemplate, Template: chart.GlobalOverride, Deployed: false, - TemplateName: chartRef.Name, - TemplateVersion: chartRef.Version, + TemplateName: chartRefDto.Name, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: IsAppMetricsEnabled, AuditLog: sql.AuditLog{ CreatedOn: chart.CreatedOn, @@ -111,8 +109,8 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory ImageDescriptorTemplate: chart.ImageDescriptorTemplate, Template: chart.GlobalOverride, Deployed: false, - TemplateName: chartRef.Name, - TemplateVersion: chartRef.Version, + TemplateName: chartRefDto.Name, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: IsAppMetricsEnabled, AuditLog: sql.AuditLog{ CreatedOn: chart.CreatedOn, @@ -141,14 +139,11 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory impl.logger.Errorw("err in getting global deployment template", "err", err, "chart", chart) return err } - chartRef, err := impl.chartRefRepository.FindById(chart.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(chart.ChartRefId) if err != nil { - impl.logger.Errorw("err in getting chartRef, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chartRef", chartRef) + impl.logger.Errorw("err in getting chartRef, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chartRef", chartRefDto) return err } - if len(chartRef.Name) == 0 { - chartRef.Name = "Rollout Deployment" - } if pipelineId == 0 { pipeline, err := impl.pipelineRepository.GetByEnvOverrideIdAndEnvId(envOverride.Id, envOverride.TargetEnvironment) if err != nil && err != pg.ErrNoRows { @@ -163,8 +158,8 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory ImageDescriptorTemplate: chart.ImageDescriptorTemplate, TargetEnvironment: envOverride.TargetEnvironment, Deployed: false, - TemplateName: chartRef.Name, - TemplateVersion: chartRef.Version, + TemplateName: chartRefDto.Name, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: IsAppMetricsEnabled, AuditLog: sql.AuditLog{ CreatedOn: envOverride.CreatedOn, @@ -193,14 +188,11 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory } func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistoryForDeploymentTrigger(pipeline *pipelineConfig.Pipeline, envOverride *chartConfig.EnvConfigOverride, renderedImageTemplate string, deployedOn time.Time, deployedBy int32) (*repository.DeploymentTemplateHistory, error) { - chartRef, err := impl.chartRefRepository.FindById(envOverride.Chart.ChartRefId) + chartRefDto, err := impl.chartRefService.FindById(envOverride.Chart.ChartRefId) if err != nil { - impl.logger.Errorw("err in getting chartRef, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chartRef", chartRef) + impl.logger.Errorw("err in getting chartRef, CreateDeploymentTemplateHistoryFromGlobalTemplate", "err", err, "chartRef", chartRefDto) return nil, err } - if len(chartRef.Name) == 0 { - chartRef.Name = "Rollout Deployment" - } isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagForAPipelineByAppIdAndEnvId(pipeline.AppId, pipeline.EnvironmentId) if err != nil { impl.logger.Errorw("error, GetMetricsFlagForAPipelineByAppIdAndEnvId", "err", err, "appId", pipeline.AppId, "envId", pipeline.EnvironmentId) @@ -214,8 +206,8 @@ func (impl DeploymentTemplateHistoryServiceImpl) CreateDeploymentTemplateHistory Deployed: true, DeployedBy: deployedBy, DeployedOn: deployedOn, - TemplateName: chartRef.Name, - TemplateVersion: chartRef.Version, + TemplateName: chartRefDto.Name, + TemplateVersion: chartRefDto.Version, IsAppMetricsEnabled: isAppMetricsEnabled, AuditLog: sql.AuditLog{ CreatedOn: deployedOn, diff --git a/wire_gen.go b/wire_gen.go index d330b3674e..f32319b90d 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -45,7 +45,7 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/cluster" "github.com/devtron-labs/devtron/client/argocdServer/connection" - repository9 "github.com/devtron-labs/devtron/client/argocdServer/repository" + repository12 "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/client/dashboard" "github.com/devtron-labs/devtron/client/events" @@ -74,18 +74,17 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone" "github.com/devtron-labs/devtron/pkg/appClone/batch" appStatus2 "github.com/devtron-labs/devtron/pkg/appStatus" - "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + service2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service3 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" - service2 "github.com/devtron-labs/devtron/pkg/appStore/values/service" + "github.com/devtron-labs/devtron/pkg/appStore/values/service" appWorkflow2 "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authentication" @@ -103,14 +102,15 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" - repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" + repository7 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" "github.com/devtron-labs/devtron/pkg/dockerRegistry" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/genericNotes" - repository10 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" + repository11 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" jira2 "github.com/devtron-labs/devtron/pkg/jira" @@ -127,11 +127,11 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/history" - repository6 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - repository11 "github.com/devtron-labs/devtron/pkg/pipeline/repository" + repository8 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + repository9 "github.com/devtron-labs/devtron/pkg/pipeline/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" - repository12 "github.com/devtron-labs/devtron/pkg/plugin/repository" + repository10 "github.com/devtron-labs/devtron/pkg/plugin/repository" "github.com/devtron-labs/devtron/pkg/projectManagementService/jira" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" @@ -142,12 +142,12 @@ import ( "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" "github.com/devtron-labs/devtron/pkg/terminal" - util2 "github.com/devtron-labs/devtron/pkg/util" + util3 "github.com/devtron-labs/devtron/pkg/util" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/variables/parsers" - repository7 "github.com/devtron-labs/devtron/pkg/variables/repository" + repository6 "github.com/devtron-labs/devtron/pkg/variables/repository" "github.com/devtron-labs/devtron/pkg/webhook/helm" - util3 "github.com/devtron-labs/devtron/util" + util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" "github.com/devtron-labs/devtron/util/rbac" ) @@ -178,9 +178,7 @@ func InitializeApp() (*App, error) { mergeUtil := &util.MergeUtil{ Logger: sugaredLogger, } - ciArtifactRepositoryImpl := repository.NewCiArtifactRepositoryImpl(db, sugaredLogger) pipelineRepositoryImpl := pipelineConfig.NewPipelineRepositoryImpl(db, sugaredLogger) - dbMigrationConfigRepositoryImpl := pipelineConfig.NewDbMigrationConfigRepositoryImpl(db, sugaredLogger) httpClient := util.NewHttpClient() eventClientConfig, err := client.GetEventClientConfig() if err != nil { @@ -292,143 +290,85 @@ func InitializeApp() (*App, error) { cdWorkflowRepositoryImpl := pipelineConfig.NewCdWorkflowRepositoryImpl(db, sugaredLogger) ciWorkflowRepositoryImpl := pipelineConfig.NewCiWorkflowRepositoryImpl(db, sugaredLogger) ciPipelineMaterialRepositoryImpl := pipelineConfig.NewCiPipelineMaterialRepositoryImpl(db, sugaredLogger) + ciArtifactRepositoryImpl := repository.NewCiArtifactRepositoryImpl(db, sugaredLogger) eventSimpleFactoryImpl := client.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, ciArtifactRepositoryImpl) applicationServiceClientImpl := application.NewApplicationClientImpl(sugaredLogger, argoCDConnectionManagerImpl) - acdAuthConfig, err := util2.GetACDAuthConfig() - if err != nil { - return nil, err - } - tokenCache := util2.NewTokenCache(sugaredLogger, acdAuthConfig, userAuthServiceImpl) - syncedEnforcer := casbin.Create() - enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) - enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) - appListingRepositoryQueryBuilder := helper.NewAppListingRepositoryQueryBuilder(sugaredLogger) - appListingRepositoryImpl := repository.NewAppListingRepositoryImpl(sugaredLogger, db, appListingRepositoryQueryBuilder, environmentRepositoryImpl) - pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) configMapRepositoryImpl := chartConfig.NewConfigMapRepositoryImpl(sugaredLogger, db) chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) gitProviderRepositoryImpl := repository.NewGitProviderRepositoryImpl(db) commonServiceImpl := commonService.NewCommonServiceImpl(sugaredLogger, chartRepositoryImpl, envConfigOverrideRepositoryImpl, gitOpsConfigRepositoryImpl, dockerArtifactStoreRepositoryImpl, attributesRepositoryImpl, gitProviderRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl) - imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) - imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) - argoK8sClientImpl := argocdServer.NewArgoK8sClientImpl(sugaredLogger) gitCliUtil := util.NewGitCliUtil(sugaredLogger) gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) if err != nil { return nil, err } - pipelineStrategyHistoryRepositoryImpl := repository6.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) - pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) - configMapHistoryRepositoryImpl := repository6.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db) - scopedVariableRepositoryImpl := repository7.NewScopedVariableRepository(db, sugaredLogger) - qualifiersMappingRepositoryImpl, err := resourceQualifiers.NewQualifiersMappingRepositoryImpl(db, sugaredLogger) + globalEnvVariables, err := util2.GetGlobalEnvVariables() if err != nil { return nil, err } - devtronResourceSearchableKeyRepositoryImpl := repository8.NewDevtronResourceSearchableKeyRepositoryImpl(sugaredLogger, db) - devtronResourceSearchableKeyServiceImpl, err := devtronResource.NewDevtronResourceSearchableKeyServiceImpl(sugaredLogger, devtronResourceSearchableKeyRepositoryImpl) - if err != nil { - return nil, err - } - qualifierMappingServiceImpl, err := resourceQualifiers.NewQualifierMappingServiceImpl(sugaredLogger, qualifiersMappingRepositoryImpl, devtronResourceSearchableKeyServiceImpl) + chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) + devtronSecretConfig, err := util2.GetDevtronSecretName() if err != nil { return nil, err } - scopedVariableServiceImpl, err := variables.NewScopedVariableServiceImpl(sugaredLogger, scopedVariableRepositoryImpl, qualifierMappingServiceImpl) + versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) + argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, gitOpsConfigRepositoryImpl, argoCDConnectionManagerImpl, versionServiceImpl, k8sUtil) if err != nil { return nil, err } - variableEntityMappingRepositoryImpl := repository7.NewVariableEntityMappingRepository(sugaredLogger, db) - variableEntityMappingServiceImpl := variables.NewVariableEntityMappingServiceImpl(variableEntityMappingRepositoryImpl, sugaredLogger) - variableSnapshotHistoryRepositoryImpl := repository7.NewVariableSnapshotHistoryRepository(sugaredLogger, db) - variableSnapshotHistoryServiceImpl := variables.NewVariableSnapshotHistoryServiceImpl(variableSnapshotHistoryRepositoryImpl, sugaredLogger) - variableTemplateParserImpl, err := parsers.NewVariableTemplateParserImpl(sugaredLogger) + pipelineStatusTimelineRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineRepositoryImpl(db, sugaredLogger) + pipelineStatusTimelineResourcesRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl(db, sugaredLogger) + pipelineStatusTimelineResourcesServiceImpl := status.NewPipelineStatusTimelineResourcesServiceImpl(db, sugaredLogger, pipelineStatusTimelineResourcesRepositoryImpl) + pipelineStatusSyncDetailRepositoryImpl := pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl(db, sugaredLogger) + pipelineStatusSyncDetailServiceImpl := status.NewPipelineStatusSyncDetailServiceImpl(sugaredLogger, pipelineStatusSyncDetailRepositoryImpl) + installedAppVersionHistoryRepositoryImpl := repository3.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) + pipelineStatusTimelineServiceImpl := status.NewPipelineStatusTimelineServiceImpl(sugaredLogger, pipelineStatusTimelineRepositoryImpl, cdWorkflowRepositoryImpl, userServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl) + appServiceConfig, err := app2.GetAppServiceConfig() if err != nil { return nil, err } - scopedVariableCMCSManagerImpl, err := variables.NewScopedVariableCMCSManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) + syncedEnforcer := casbin.Create() + enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) + enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) + appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) + scopedVariableRepositoryImpl := repository6.NewScopedVariableRepository(db, sugaredLogger) + qualifiersMappingRepositoryImpl, err := resourceQualifiers.NewQualifiersMappingRepositoryImpl(db, sugaredLogger) if err != nil { return nil, err } - configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) - deploymentTemplateHistoryRepositoryImpl := repository6.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) - chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) - scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) + devtronResourceSearchableKeyRepositoryImpl := repository7.NewDevtronResourceSearchableKeyRepositoryImpl(sugaredLogger, db) + devtronResourceSearchableKeyServiceImpl, err := devtronResource.NewDevtronResourceSearchableKeyServiceImpl(sugaredLogger, devtronResourceSearchableKeyRepositoryImpl) if err != nil { return nil, err } - appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) - envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) - deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, chartRefRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl) - deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) - chartWorkingDir := _wireChartWorkingDirValue - globalEnvVariables, err := util3.GetGlobalEnvVariables() + qualifierMappingServiceImpl, err := resourceQualifiers.NewQualifierMappingServiceImpl(sugaredLogger, qualifiersMappingRepositoryImpl, devtronResourceSearchableKeyServiceImpl) if err != nil { return nil, err } - chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, chartWorkingDir, httpClient, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) - refChartDir := _wireRefChartDirValue - chartRepoRepositoryImpl := chartRepoRepository.NewChartRepoRepositoryImpl(db) - defaultChart := _wireDefaultChartValue - utilMergeUtil := util.MergeUtil{ - Logger: sugaredLogger, - } - repositoryServiceClientImpl := repository9.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) - chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) - devtronSecretConfig, err := util3.GetDevtronSecretName() + scopedVariableServiceImpl, err := variables.NewScopedVariableServiceImpl(sugaredLogger, scopedVariableRepositoryImpl, qualifierMappingServiceImpl) if err != nil { return nil, err } - versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) - argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, gitOpsConfigRepositoryImpl, argoCDConnectionManagerImpl, versionServiceImpl, k8sUtil) + variableEntityMappingRepositoryImpl := repository6.NewVariableEntityMappingRepository(sugaredLogger, db) + variableEntityMappingServiceImpl := variables.NewVariableEntityMappingServiceImpl(variableEntityMappingRepositoryImpl, sugaredLogger) + variableSnapshotHistoryRepositoryImpl := repository6.NewVariableSnapshotHistoryRepository(sugaredLogger, db) + variableSnapshotHistoryServiceImpl := variables.NewVariableSnapshotHistoryServiceImpl(variableSnapshotHistoryRepositoryImpl, sugaredLogger) + variableTemplateParserImpl, err := parsers.NewVariableTemplateParserImpl(sugaredLogger) if err != nil { return nil, err } - pipelineStatusTimelineRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineRepositoryImpl(db, sugaredLogger) - appLabelRepositoryImpl := pipelineConfig.NewAppLabelRepositoryImpl(db) - genericNoteRepositoryImpl := repository10.NewGenericNoteRepositoryImpl(db) - genericNoteHistoryRepositoryImpl := repository10.NewGenericNoteHistoryRepositoryImpl(db) - genericNoteHistoryServiceImpl := genericNotes.NewGenericNoteHistoryServiceImpl(genericNoteHistoryRepositoryImpl, sugaredLogger) - genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) - materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) - appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, materialRepositoryImpl) - dockerRegistryIpsConfigRepositoryImpl := repository5.NewDockerRegistryIpsConfigRepositoryImpl(db) - ciTemplateOverrideRepositoryImpl := pipelineConfig.NewCiTemplateOverrideRepositoryImpl(db, sugaredLogger) - dockerRegistryIpsConfigServiceImpl := dockerRegistry.NewDockerRegistryIpsConfigServiceImpl(sugaredLogger, dockerRegistryIpsConfigRepositoryImpl, k8sUtil, clusterServiceImplExtended, ciPipelineRepositoryImpl, dockerArtifactStoreRepositoryImpl, ciTemplateOverrideRepositoryImpl) - pipelineStatusTimelineResourcesRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl(db, sugaredLogger) - pipelineStatusTimelineResourcesServiceImpl := status.NewPipelineStatusTimelineResourcesServiceImpl(db, sugaredLogger, pipelineStatusTimelineResourcesRepositoryImpl) - pipelineStatusSyncDetailRepositoryImpl := pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl(db, sugaredLogger) - pipelineStatusSyncDetailServiceImpl := status.NewPipelineStatusSyncDetailServiceImpl(sugaredLogger, pipelineStatusSyncDetailRepositoryImpl) - installedAppVersionHistoryRepositoryImpl := repository3.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) - pipelineStatusTimelineServiceImpl := status.NewPipelineStatusTimelineServiceImpl(sugaredLogger, pipelineStatusTimelineRepositoryImpl, cdWorkflowRepositoryImpl, userServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl) - appServiceConfig, err := app2.GetAppServiceConfig() + scopedVariableCMCSManagerImpl, err := variables.NewScopedVariableCMCSManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) if err != nil { return nil, err } - appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) - chartGroupDeploymentRepositoryImpl := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - refChartProxyDir := _wireRefChartProxyDirValue - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, refChartProxyDir, gitFactory, gitOpsConfigRepositoryImpl) - ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } - argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, refChartProxyDir, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, applicationServiceClientImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, globalEnvVariables, installedAppRepositoryImpl, tokenCache, argoUserServiceImpl, gitOpsConfigRepositoryImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, chartTemplateServiceImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, gitOpsConfigRepositoryImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) - deploymentServiceTypeConfig, err := service.GetDeploymentServiceTypeConfig() - if err != nil { - return nil, err - } - appStoreDeploymentServiceImpl := service.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) - k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) - manifestPushConfigRepositoryImpl := repository11.NewManifestPushConfigRepository(sugaredLogger, db) - gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, chartServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, dbMigrationConfigRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) + chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) + chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl) validate, err := util.IntValidator() if err != nil { return nil, err @@ -441,17 +381,22 @@ func InitializeApp() (*App, error) { globalCMCSServiceImpl := pipeline.NewGlobalCMCSServiceImpl(sugaredLogger, globalCMCSRepositoryImpl) argoWorkflowExecutorImpl := executors.NewArgoWorkflowExecutorImpl(sugaredLogger) systemWorkflowExecutorImpl := executors.NewSystemWorkflowExecutorImpl(sugaredLogger, k8sUtil) + k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) workflowServiceImpl, err := pipeline.NewWorkflowServiceImpl(sugaredLogger, environmentRepositoryImpl, ciCdConfig, appServiceImpl, globalCMCSServiceImpl, argoWorkflowExecutorImpl, k8sUtil, systemWorkflowExecutorImpl, k8sCommonServiceImpl) if err != nil { return nil, err } + materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) deploymentGroupRepositoryImpl := repository.NewDeploymentGroupRepositoryImpl(sugaredLogger, db) cvePolicyRepositoryImpl := security.NewPolicyRepositoryImpl(db) imageScanResultRepositoryImpl := security.NewImageScanResultRepositoryImpl(db, sugaredLogger) appWorkflowRepositoryImpl := appWorkflow.NewAppWorkflowRepositoryImpl(sugaredLogger, db) - prePostCdScriptHistoryRepositoryImpl := repository6.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) + prePostCdScriptHistoryRepositoryImpl := repository8.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) + configMapHistoryRepositoryImpl := repository8.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db) + configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) prePostCdScriptHistoryServiceImpl := history.NewPrePostCdScriptHistoryServiceImpl(sugaredLogger, prePostCdScriptHistoryRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl) ciTemplateRepositoryImpl := pipelineConfig.NewCiTemplateRepositoryImpl(db, sugaredLogger) + appLabelRepositoryImpl := pipelineConfig.NewAppLabelRepositoryImpl(db) clientConfig, err := gitSensor.GetConfig() if err != nil { return nil, err @@ -460,38 +405,73 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - pipelineStageRepositoryImpl := repository11.NewPipelineStageRepository(sugaredLogger, db) - globalPluginRepositoryImpl := repository12.NewGlobalPluginRepository(sugaredLogger, db) + pipelineStageRepositoryImpl := repository9.NewPipelineStageRepository(sugaredLogger, db) + globalPluginRepositoryImpl := repository10.NewGlobalPluginRepository(sugaredLogger, db) + scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) + if err != nil { + return nil, err + } pipelineStageServiceImpl := pipeline.NewPipelineStageService(sugaredLogger, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, pipelineRepositoryImpl, scopedVariableManagerImpl) globalPluginServiceImpl := plugin.NewGlobalPluginService(sugaredLogger, globalPluginRepositoryImpl, pipelineStageRepositoryImpl) + dockerRegistryIpsConfigRepositoryImpl := repository5.NewDockerRegistryIpsConfigRepositoryImpl(db) + ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) dockerRegistryConfigImpl := pipeline.NewDockerRegistryConfigImpl(sugaredLogger, helmAppServiceImpl, dockerArtifactStoreRepositoryImpl, dockerRegistryIpsConfigRepositoryImpl, ociRegistryConfigRepositoryImpl) imageTagRepositoryImpl := repository.NewImageTagRepository(db, sugaredLogger) customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) + deploymentTemplateHistoryRepositoryImpl := repository8.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) + appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) + deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRefServiceImpl) + deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) + pipelineStrategyHistoryRepositoryImpl := repository8.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) + pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) + manifestPushConfigRepositoryImpl := repository9.NewManifestPushConfigRepository(sugaredLogger, db) + gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl) + imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) + imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) + genericNoteRepositoryImpl := repository11.NewGenericNoteRepositoryImpl(db) + genericNoteHistoryRepositoryImpl := repository11.NewGenericNoteHistoryRepositoryImpl(db) + genericNoteHistoryServiceImpl := genericNotes.NewGenericNoteHistoryServiceImpl(genericNoteHistoryRepositoryImpl, sugaredLogger) + genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) + appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, materialRepositoryImpl) + pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) + ciTemplateOverrideRepositoryImpl := pipelineConfig.NewCiTemplateOverrideRepositoryImpl(db, sugaredLogger) + dockerRegistryIpsConfigServiceImpl := dockerRegistry.NewDockerRegistryIpsConfigServiceImpl(sugaredLogger, dockerRegistryIpsConfigRepositoryImpl, k8sUtil, clusterServiceImplExtended, ciPipelineRepositoryImpl, dockerArtifactStoreRepositoryImpl, ciTemplateOverrideRepositoryImpl) + argoK8sClientImpl := argocdServer.NewArgoK8sClientImpl(sugaredLogger) + dbMigrationConfigRepositoryImpl := pipelineConfig.NewDbMigrationConfigRepositoryImpl(db, sugaredLogger) + repositoryServiceClientImpl := repository12.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) + argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerImpl, enforcerUtilImpl, tokenCache, acdAuthConfig, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, variableSnapshotHistoryServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, refChartDir, helmAppServiceImpl, helmAppClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) - deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, chartRefRepositoryImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl) + deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) pipelineTriggerRestHandlerImpl := restHandler.NewPipelineRestHandler(appServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, workflowDagExecutorImpl, deploymentGroupServiceImpl, argoUserServiceImpl, deploymentConfigServiceImpl) sseSSE := sse.NewSSE() pipelineTriggerRouterImpl := router.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) - prePostCiScriptHistoryRepositoryImpl := repository6.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) + appListingRepositoryQueryBuilder := helper.NewAppListingRepositoryQueryBuilder(sugaredLogger) + appListingRepositoryImpl := repository.NewAppListingRepositoryImpl(sugaredLogger, db, appListingRepositoryQueryBuilder, environmentRepositoryImpl) + prePostCiScriptHistoryRepositoryImpl := repository8.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) prePostCiScriptHistoryServiceImpl := history.NewPrePostCiScriptHistoryServiceImpl(sugaredLogger, prePostCiScriptHistoryRepositoryImpl) - gitMaterialHistoryRepositoryImpl := repository6.NewGitMaterialHistoryRepositoyImpl(db) + gitMaterialHistoryRepositoryImpl := repository8.NewGitMaterialHistoryRepositoyImpl(db) gitMaterialHistoryServiceImpl := history.NewGitMaterialHistoryServiceImpl(gitMaterialHistoryRepositoryImpl, sugaredLogger) - ciPipelineHistoryRepositoryImpl := repository6.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) + ciPipelineHistoryRepositoryImpl := repository8.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) ciPipelineHistoryServiceImpl := history.NewCiPipelineHistoryServiceImpl(ciPipelineHistoryRepositoryImpl, sugaredLogger, ciPipelineRepositoryImpl) ciBuildConfigRepositoryImpl := pipelineConfig.NewCiBuildConfigRepositoryImpl(db, sugaredLogger) ciBuildConfigServiceImpl := pipeline.NewCiBuildConfigServiceImpl(sugaredLogger, ciBuildConfigRepositoryImpl) ciTemplateServiceImpl := pipeline.NewCiTemplateServiceImpl(sugaredLogger, ciBuildConfigServiceImpl, ciTemplateRepositoryImpl, ciTemplateOverrideRepositoryImpl) + chartRepoRepositoryImpl := chartRepoRepository.NewChartRepoRepositoryImpl(db) + utilMergeUtil := util.MergeUtil{ + Logger: sugaredLogger, + } configMapServiceImpl := pipeline.NewConfigMapServiceImpl(chartRepositoryImpl, sugaredLogger, chartRepoRepositoryImpl, utilMergeUtil, pipelineConfigRepositoryImpl, configMapRepositoryImpl, envConfigOverrideRepositoryImpl, commonServiceImpl, appRepositoryImpl, configMapHistoryServiceImpl, environmentRepositoryImpl, scopedVariableCMCSManagerImpl) ciCdPipelineOrchestratorImpl := pipeline.NewCiCdPipelineOrchestrator(appRepositoryImpl, sugaredLogger, materialRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciCdConfig, appWorkflowRepositoryImpl, environmentRepositoryImpl, attributesServiceImpl, appListingRepositoryImpl, appCrudOperationServiceImpl, userAuthServiceImpl, prePostCdScriptHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, ciTemplateOverrideRepositoryImpl, gitMaterialHistoryServiceImpl, ciPipelineHistoryServiceImpl, ciTemplateServiceImpl, dockerArtifactStoreRepositoryImpl, ciArtifactRepositoryImpl, configMapServiceImpl, customTagServiceImpl, genericNoteServiceImpl) ecrConfig, err := pipeline.GetEcrConfig() if err != nil { return nil, err } - ciTemplateHistoryRepositoryImpl := repository6.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) + ciTemplateHistoryRepositoryImpl := repository8.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) ciTemplateHistoryServiceImpl := history.NewCiTemplateHistoryServiceImpl(ciTemplateHistoryRepositoryImpl, sugaredLogger) resourceGroupRepositoryImpl := resourceGroup.NewResourceGroupRepositoryImpl(db) resourceGroupMappingRepositoryImpl := resourceGroup.NewResourceGroupMappingRepositoryImpl(db) @@ -501,19 +481,20 @@ func InitializeApp() (*App, error) { ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) imageTaggingRepositoryImpl := repository13.NewImageTaggingRepositoryImpl(db) imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) - propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) - pipelineDeploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() + propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) + deploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, pipelineDeploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, chartTemplateServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl) devtronAppConfigServiceImpl := pipeline.NewDevtronAppConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, appRepositoryImpl, pipelineRepositoryImpl, resourceGroupServiceImpl, enforcerUtilImpl, ciMaterialConfigServiceImpl) pipelineBuilderImpl := pipeline.NewPipelineBuilderImpl(sugaredLogger, materialRepositoryImpl, chartRepositoryImpl, ciPipelineConfigServiceImpl, ciMaterialConfigServiceImpl, appArtifactManagerImpl, devtronAppCMCSServiceImpl, devtronAppStrategyServiceImpl, appDeploymentTypeChangeManagerImpl, cdPipelineConfigServiceImpl, devtronAppConfigServiceImpl) + chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) dbMigrationServiceImpl := pipeline.NewDbMogrationService(sugaredLogger, dbMigrationConfigRepositoryImpl) ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) ciLogServiceImpl, err := pipeline.NewCiLogServiceImpl(sugaredLogger, ciServiceImpl, k8sUtil) @@ -531,11 +512,11 @@ func InitializeApp() (*App, error) { appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, materialRepositoryImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, ciTemplateOverrideRepositoryImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineConfigServiceImpl) deploymentTemplateRepositoryImpl := repository.NewDeploymentTemplateRepositoryImpl(db, sugaredLogger) - deploymentTemplateServiceImpl := generateManifest.NewDeploymentTemplateServiceImpl(sugaredLogger, chartServiceImpl, appListingServiceImpl, appListingRepositoryImpl, deploymentTemplateRepositoryImpl, helmAppServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, helmAppClientImpl, k8sUtil, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl) + deploymentTemplateServiceImpl := generateManifest.NewDeploymentTemplateServiceImpl(sugaredLogger, chartServiceImpl, appListingServiceImpl, appListingRepositoryImpl, deploymentTemplateRepositoryImpl, helmAppServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, helmAppClientImpl, k8sUtil, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, chartRefServiceImpl) imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciCdConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl) - pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl) + pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) appWorkflowRestHandlerImpl := restHandler.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) webhookEventDataRepositoryImpl := repository.NewWebhookEventDataRepositoryImpl(db) webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) @@ -549,7 +530,23 @@ func InitializeApp() (*App, error) { migrateDbRestHandlerImpl := restHandler.NewMigrateDbRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, dbConfigServiceImpl, userServiceImpl, validate, dbMigrationServiceImpl, enforcerImpl) migrateDbRouterImpl := router.NewMigrateDbRouterImpl(migrateDbRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) - appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) + appStoreValuesServiceImpl := service.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) + acdAuthConfig, err := util3.GetACDAuthConfig() + if err != nil { + return nil, err + } + tokenCache := util3.NewTokenCache(sugaredLogger, acdAuthConfig, userAuthServiceImpl) + chartGroupDeploymentRepositoryImpl := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigRepositoryImpl) + appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, applicationServiceClientImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, globalEnvVariables, installedAppRepositoryImpl, tokenCache, argoUserServiceImpl, gitOpsConfigRepositoryImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) + clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, chartTemplateServiceImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, gitOpsConfigRepositoryImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) + serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() + if err != nil { + return nil, err + } + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, serviceDeploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) k8sResourceHistoryRepositoryImpl := repository14.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -559,7 +556,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartTemplateServiceImpl, refChartProxyDir, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, attributesRepositoryImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, appStoreDeploymentArgoCdServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig) + installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartTemplateServiceImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig) if err != nil { return nil, err } @@ -646,7 +643,7 @@ func InitializeApp() (*App, error) { roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) userRouterImpl := user2.NewUserRouterImpl(userRestHandlerImpl) - chartRefRestHandlerImpl := restHandler.NewChartRefRestHandlerImpl(chartServiceImpl, sugaredLogger) + chartRefRestHandlerImpl := restHandler.NewChartRefRestHandlerImpl(sugaredLogger, chartRefServiceImpl, chartServiceImpl) chartRefRouterImpl := router.NewChartRefRouterImpl(chartRefRestHandlerImpl) configMapRestHandlerImpl := restHandler.NewConfigMapRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, pipelineRepositoryImpl, enforcerUtilImpl, configMapServiceImpl) configMapRouterImpl := router.NewConfigMapRouterImpl(configMapRestHandlerImpl) @@ -662,7 +659,7 @@ func InitializeApp() (*App, error) { appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) appStoreStatusTimelineRestHandlerImpl := appStore.NewAppStoreStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) appStoreRouterImpl := appStore.NewAppStoreRouterImpl(installedAppRestHandlerImpl, appStoreValuesRouterImpl, appStoreDiscoverRouterImpl, chartProviderRouterImpl, appStoreDeploymentRouterImpl, appStoreStatusTimelineRestHandlerImpl) - chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceExtendedImpl, chartRefRepositoryImpl, refChartDir, attributesServiceImpl) + chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceExtendedImpl, attributesServiceImpl) chartRepositoryRouterImpl := chartRepo2.NewChartRepositoryRouterImpl(chartRepositoryRestHandlerImpl) lensConfig, err := lens.GetLensConfig() if err != nil { @@ -686,7 +683,7 @@ func InitializeApp() (*App, error) { batchOperationRouterImpl := router.NewBatchOperationRouterImpl(batchOperationRestHandlerImpl, sugaredLogger) chartGroupEntriesRepositoryImpl := repository3.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository3.NewChartGroupReposotoryImpl(db, sugaredLogger) - chartGroupServiceImpl := service.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) + chartGroupServiceImpl := service2.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) chartGroupRestHandlerImpl := restHandler.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) chartGroupRouterImpl := router.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) testSuitRestHandlerImpl := restHandler.NewTestSuitRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerImpl, enforcerUtilImpl, eventClientConfig, httpClient) @@ -733,7 +730,7 @@ func InitializeApp() (*App, error) { telemetryRestHandlerImpl := restHandler.NewTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImplExtended, enforcerImpl, userServiceImpl) telemetryRouterImpl := router.NewTelemetryRouterImpl(sugaredLogger, telemetryRestHandlerImpl) bulkUpdateRepositoryImpl := bulkUpdate.NewBulkUpdateRepository(db, sugaredLogger) - bulkUpdateServiceImpl, err := bulkAction.NewBulkUpdateServiceImpl(bulkUpdateRepositoryImpl, chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, httpClient, appRepositoryImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, workflowDagExecutorImpl, cdWorkflowRepositoryImpl, pipelineBuilderImpl, helmAppServiceImpl, enforcerUtilImpl, enforcerUtilHelmImpl, ciHandlerImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, appWorkflowServiceImpl, pubSubClientServiceImpl, argoUserServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) + bulkUpdateServiceImpl, err := bulkAction.NewBulkUpdateServiceImpl(bulkUpdateRepositoryImpl, chartRepositoryImpl, sugaredLogger, environmentRepositoryImpl, pipelineRepositoryImpl, appRepositoryImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, workflowDagExecutorImpl, pipelineBuilderImpl, enforcerUtilImpl, ciHandlerImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, appWorkflowServiceImpl, pubSubClientServiceImpl, argoUserServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) if err != nil { return nil, err } @@ -752,7 +749,7 @@ func InitializeApp() (*App, error) { k8sApplicationRouterImpl := application3.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) pProfRestHandlerImpl := restHandler.NewPProfRestHandler(userServiceImpl, enforcerImpl) pProfRouterImpl := router.NewPProfRouter(sugaredLogger, pProfRestHandlerImpl) - deploymentConfigRestHandlerImpl := deployment.NewDeploymentConfigRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, validate, refChartDir, chartServiceImpl, chartRefRepositoryImpl) + deploymentConfigRestHandlerImpl := deployment.NewDeploymentConfigRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, chartServiceImpl, chartRefServiceImpl) deploymentConfigRouterImpl := deployment.NewDeploymentRouterImpl(deploymentConfigRestHandlerImpl) dashboardTelemetryRestHandlerImpl := dashboardEvent.NewDashboardTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImplExtended) dashboardTelemetryRouterImpl := dashboardEvent.NewDashboardTelemetryRouterImpl(dashboardTelemetryRestHandlerImpl) @@ -826,10 +823,3 @@ func InitializeApp() (*App, error) { mainApp := NewApp(muxRouter, sugaredLogger, sseSSE, syncedEnforcer, db, pubSubClientServiceImpl, sessionManager, posthogClient, loggingMiddlewareImpl) return mainApp, nil } - -var ( - _wireChartWorkingDirValue = util.ChartWorkingDir("/tmp/charts/") - _wireRefChartDirValue = chartRepoRepository.RefChartDir("scripts/devtron-reference-helm-charts") - _wireDefaultChartValue = chart.DefaultChart("reference-app-rolling") - _wireRefChartProxyDirValue = appStoreBean.RefChartProxyDir("scripts/devtron-reference-helm-charts") -) From a1421a57260133ce60113aec356ca17bf64c9642 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 18:28:02 +0530 Subject: [PATCH 07/83] removed infra metrics db calls --- .../repository/AppLevelMetricsRepository.go | 10 ++-- .../sql/repository/AppListingRepository.go | 2 + .../EnvLevelAppMetricsRepository.go | 12 ++--- pkg/app/AppListingService.go | 53 ++++++------------- .../deployedAppMetrics/DeployedAppMetrics.go | 13 ++--- wire_gen.go | 2 +- 6 files changed, 36 insertions(+), 56 deletions(-) diff --git a/internal/sql/repository/AppLevelMetricsRepository.go b/internal/sql/repository/AppLevelMetricsRepository.go index 6e3568e11a..1a67deefdd 100644 --- a/internal/sql/repository/AppLevelMetricsRepository.go +++ b/internal/sql/repository/AppLevelMetricsRepository.go @@ -24,11 +24,11 @@ import ( ) type AppLevelMetrics struct { - tableName struct{} `sql:"app_level_metrics" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - AppId int `sql:"app_id,notnull"` - AppMetrics bool `sql:"app_metrics,notnull"` - InfraMetrics bool `sql:"infra_metrics,notnull"` + tableName struct{} `sql:"app_level_metrics" pg:",discard_unknown_columns"` + Id int `sql:"id,pk"` + AppId int `sql:"app_id,notnull"` + AppMetrics bool `sql:"app_metrics,notnull"` + //InfraMetrics bool `sql:"infra_metrics,notnull"` not being used sql.AuditLog } diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 2b4a9f84f6..c5e2583b53 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -663,6 +663,7 @@ func (impl AppListingRepositoryImpl) makeAppStageStatus(stage int, stageName str func (impl AppListingRepositoryImpl) FetchOtherEnvironment(appId int) ([]*bean.Environment, error) { // other environment tab var otherEnvironments []*bean.Environment + //TODO: remove infra metrics from query as it is not being used from here query := `select pcwr.pipeline_id, pcwr.last_deployed, pcwr.latest_cd_workflow_runner_id, pcwr.environment_id, pcwr.deployment_app_delete_request, e.cluster_id, e.environment_name, e.default as prod, e.description, ca.image as last_deployed_image, u.email_id as last_deployed_by, elam.app_metrics, elam.infra_metrics, ap.status as app_status @@ -691,6 +692,7 @@ func (impl AppListingRepositoryImpl) FetchOtherEnvironment(appId int) ([]*bean.E func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error) { impl.Logger.Debug("reached at FetchMinDetailOtherEnvironment:") var otherEnvironments []*bean.Environment + //TODO: remove infra metrics from query as it is not being used from here query := `SELECT p.environment_id,env.environment_name,env.description,env.is_virtual_environment, env.cluster_id, env.default as prod, p.deployment_app_delete_request, env_app_m.app_metrics,env_app_m.infra_metrics from (SELECT pl.id,pl.app_id,pl.environment_id,pl.deleted, pl.deployment_app_delete_request from pipeline pl diff --git a/internal/sql/repository/EnvLevelAppMetricsRepository.go b/internal/sql/repository/EnvLevelAppMetricsRepository.go index f849212fab..bb81432024 100644 --- a/internal/sql/repository/EnvLevelAppMetricsRepository.go +++ b/internal/sql/repository/EnvLevelAppMetricsRepository.go @@ -24,12 +24,12 @@ import ( ) type EnvLevelAppMetrics struct { - tableName struct{} `sql:"env_level_app_metrics" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - AppId int `sql:"app_id,notnull"` - EnvId int `sql:"env_id,notnull"` - AppMetrics *bool `sql:"app_metrics,notnull"` - InfraMetrics *bool `sql:"infra_metrics,notnull"` + tableName struct{} `sql:"env_level_app_metrics" pg:",discard_unknown_columns"` + Id int `sql:"id,pk"` + AppId int `sql:"app_id,notnull"` + EnvId int `sql:"env_id,notnull"` + AppMetrics *bool `sql:"app_metrics,notnull"` + //InfraMetrics *bool `sql:"infra_metrics,notnull"` not being used sql.AuditLog } diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 207bec1fd3..462e851cef 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "net/http" "strconv" "strings" @@ -159,7 +160,6 @@ type AppListingServiceImpl struct { pipelineRepository pipelineConfig.PipelineRepository cdWorkflowRepository pipelineConfig.CdWorkflowRepository linkoutsRepository repository.LinkoutsRepository - appLevelMetricsRepository repository.AppLevelMetricsRepository pipelineOverrideRepository chartConfig.PipelineOverrideRepository environmentRepository repository2.EnvironmentRepository argoUserService argo.ArgoUserService @@ -168,17 +168,18 @@ type AppListingServiceImpl struct { ciPipelineRepository pipelineConfig.CiPipelineRepository dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService userRepository userrepository.UserRepository + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService } func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository repository.AppListingRepository, application application2.ServiceClient, appRepository app.AppRepository, appListingViewBuilder AppListingViewBuilder, pipelineRepository pipelineConfig.PipelineRepository, - linkoutsRepository repository.LinkoutsRepository, appLevelMetricsRepository repository.AppLevelMetricsRepository, - cdWorkflowRepository pipelineConfig.CdWorkflowRepository, + linkoutsRepository repository.LinkoutsRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, pipelineOverrideRepository chartConfig.PipelineOverrideRepository, environmentRepository repository2.EnvironmentRepository, argoUserService argo.ArgoUserService, envOverrideRepository chartConfig.EnvConfigOverrideRepository, chartRepository chartRepoRepository.ChartRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, - dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService, userRepository userrepository.UserRepository) *AppListingServiceImpl { + dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService, userRepository userrepository.UserRepository, + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *AppListingServiceImpl { serviceImpl := &AppListingServiceImpl{ Logger: Logger, appListingRepository: appListingRepository, @@ -187,7 +188,6 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re appListingViewBuilder: appListingViewBuilder, pipelineRepository: pipelineRepository, linkoutsRepository: linkoutsRepository, - appLevelMetricsRepository: appLevelMetricsRepository, cdWorkflowRepository: cdWorkflowRepository, pipelineOverrideRepository: pipelineOverrideRepository, environmentRepository: environmentRepository, @@ -197,6 +197,7 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re ciPipelineRepository: ciPipelineRepository, dockerRegistryIpsConfigService: dockerRegistryIpsConfigService, userRepository: userRepository, + deployedAppMetricsService: deployedAppMetricsService, } return serviceImpl } @@ -1670,21 +1671,13 @@ func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, app impl.Logger.Errorw("err", err) return envs, err } - appLevelAppMetrics := false //default value - appLevelInfraMetrics := true //default val + appLevelInfraMetrics := true //default val, not being derived from DB. TODO: remove this from FE since this is derived from prometheus config at cluster level and this logic is already present at FE newCtx, span = otel.Tracer("appLevelMetricsRepository").Start(newCtx, "FindByAppId") - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) + appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) span.End() - if err != nil && !util.IsErrNoRows(err) { - impl.Logger.Errorw("error in fetching app metrics", "err", err) + if err != nil { + impl.Logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) return envs, err - } else if util.IsErrNoRows(err) { - //populate default val - appLevelAppMetrics = false //default value - appLevelInfraMetrics = true //default val - } else { - appLevelAppMetrics = appLevelMetrics.AppMetrics - appLevelInfraMetrics = appLevelMetrics.InfraMetrics } newCtx, span = otel.Tracer("chartRepository").Start(newCtx, "FindLatestChartForAppByAppId") chart, err := impl.chartRepository.FindLatestChartForAppByAppId(appId) @@ -1709,9 +1702,7 @@ func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, app if env.AppMetrics == nil { env.AppMetrics = &appLevelAppMetrics } - if env.InfraMetrics == nil { - env.InfraMetrics = &appLevelInfraMetrics - } + env.InfraMetrics = &appLevelInfraMetrics //using default value, discarding value got from query } return envs, nil } @@ -1722,19 +1713,11 @@ func (impl AppListingServiceImpl) FetchMinDetailOtherEnvironment(appId int) ([]* impl.Logger.Errorw("err", err) return envs, err } - appLevelAppMetrics := false //default value - appLevelInfraMetrics := true //default val - appLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) - if err != nil && !util.IsErrNoRows(err) { - impl.Logger.Errorw("error in fetching app metrics", "err", err) - return envs, err - } else if util.IsErrNoRows(err) { - //populate default val - appLevelAppMetrics = false //default value - appLevelInfraMetrics = true //default val - } else { - appLevelAppMetrics = appLevelMetrics.AppMetrics - appLevelInfraMetrics = appLevelMetrics.InfraMetrics + appLevelInfraMetrics := true //default val, not being derived from DB. TODO: remove this from FE since this is derived from prometheus config at cluster level and this logic is already present at FE + appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + if err != nil { + impl.Logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) + return nil, err } chartRefId, err := impl.chartRepository.FindChartRefIdForLatestChartForAppByAppId(appId) @@ -1764,9 +1747,7 @@ func (impl AppListingServiceImpl) FetchMinDetailOtherEnvironment(appId int) ([]* if env.AppMetrics == nil { env.AppMetrics = &appLevelAppMetrics } - if env.InfraMetrics == nil { - env.InfraMetrics = &appLevelInfraMetrics - } + env.InfraMetrics = &appLevelInfraMetrics //using default value, discarding value got from query } return envs, nil } diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index b04de22cff..1f2d38e52b 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -160,9 +160,8 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *be return existingAppLevelMetrics, nil } else { appLevelMetricsNew := &interalRepo.AppLevelMetrics{ - AppId: req.AppId, - AppMetrics: req.EnableMetrics, - InfraMetrics: true, + AppId: req.AppId, + AppMetrics: req.EnableMetrics, AuditLog: sql.AuditLog{ CreatedOn: time.Now(), UpdatedOn: time.Now(), @@ -187,12 +186,10 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *be return nil, err } if envLevelAppMetrics == nil || envLevelAppMetrics.Id == 0 { - infraMetrics := true envLevelAppMetrics = &interalRepo.EnvLevelAppMetrics{ - AppId: req.AppId, - EnvId: req.EnvId, - AppMetrics: &req.EnableMetrics, - InfraMetrics: &infraMetrics, + AppId: req.AppId, + EnvId: req.EnvId, + AppMetrics: &req.EnableMetrics, AuditLog: sql.AuditLog{ CreatedOn: time.Now(), UpdatedOn: time.Now(), diff --git a/wire_gen.go b/wire_gen.go index d330b3674e..ab2ddd83ba 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -525,7 +525,7 @@ func InitializeApp() (*App, error) { gitRegistryConfigImpl := pipeline.NewGitRegistryConfigImpl(sugaredLogger, gitProviderRepositoryImpl, clientImpl) appListingViewBuilderImpl := app2.NewAppListingViewBuilderImpl(sugaredLogger) linkoutsRepositoryImpl := repository.NewLinkoutsRepositoryImpl(sugaredLogger, db) - appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, appLevelMetricsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, argoUserServiceImpl, envConfigOverrideRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl) + appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, argoUserServiceImpl, envConfigOverrideRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl, deployedAppMetricsServiceImpl) deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, userServiceImpl, cdWorkflowRepositoryImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, resourceGroupServiceImpl, imageTaggingServiceImpl, k8sUtil, workflowServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, customTagServiceImpl, argoClientWrapperServiceImpl, appServiceConfig, acdConfig) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) From a6123c5c4bbc7787fd019594459a28651382cd86 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 18:30:24 +0530 Subject: [PATCH 08/83] moved app metrics repositories from /internal to /pkg --- Wire.go | 9 +++++---- .../mocks/AppLevelMetricsRepository.go | 2 +- .../mocks/EnvLevelAppMetricsRepository.go | 2 +- .../AppServiceDeployment_test.go | 10 +++++----- .../deployedAppMetrics/DeployedAppMetrics.go | 18 +++++++++--------- .../repository/AppLevelMetricsRepository.go | 0 .../repository/EnvLevelAppMetricsRepository.go | 0 wire_gen.go | 5 +++-- 8 files changed, 24 insertions(+), 22 deletions(-) rename {internal/sql => pkg/deployment/manifest/deployedAppMetrics}/repository/AppLevelMetricsRepository.go (100%) rename {internal/sql => pkg/deployment/manifest/deployedAppMetrics}/repository/EnvLevelAppMetricsRepository.go (100%) diff --git a/Wire.go b/Wire.go index b4ef34b994..5913a6ab95 100644 --- a/Wire.go +++ b/Wire.go @@ -98,6 +98,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + repository11 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -557,11 +558,11 @@ func InitializeApp() (*App, error) { restHandler.NewExternalCiRestHandlerImpl, wire.Bind(new(restHandler.ExternalCiRestHandler), new(*restHandler.ExternalCiRestHandlerImpl)), - repository.NewAppLevelMetricsRepositoryImpl, - wire.Bind(new(repository.AppLevelMetricsRepository), new(*repository.AppLevelMetricsRepositoryImpl)), + repository11.NewAppLevelMetricsRepositoryImpl, + wire.Bind(new(repository11.AppLevelMetricsRepository), new(*repository11.AppLevelMetricsRepositoryImpl)), - repository.NewEnvLevelAppMetricsRepositoryImpl, - wire.Bind(new(repository.EnvLevelAppMetricsRepository), new(*repository.EnvLevelAppMetricsRepositoryImpl)), + repository11.NewEnvLevelAppMetricsRepositoryImpl, + wire.Bind(new(repository11.EnvLevelAppMetricsRepository), new(*repository11.EnvLevelAppMetricsRepositoryImpl)), grafana.GetGrafanaClientConfig, grafana.NewGrafanaClientImpl, diff --git a/internal/sql/repository/mocks/AppLevelMetricsRepository.go b/internal/sql/repository/mocks/AppLevelMetricsRepository.go index 4254e30765..8e1a77c8e1 100644 --- a/internal/sql/repository/mocks/AppLevelMetricsRepository.go +++ b/internal/sql/repository/mocks/AppLevelMetricsRepository.go @@ -3,7 +3,7 @@ package mocks import ( - repository "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go b/internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go index 1037a5fd94..6561e22c68 100644 --- a/internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go +++ b/internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go @@ -3,7 +3,7 @@ package mocks import ( - repository "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" mock "github.com/stretchr/testify/mock" ) diff --git a/pkg/app/integrationTest/AppServiceDeployment_test.go b/pkg/app/integrationTest/AppServiceDeployment_test.go index b849021a99..a05fb7ce07 100644 --- a/pkg/app/integrationTest/AppServiceDeployment_test.go +++ b/pkg/app/integrationTest/AppServiceDeployment_test.go @@ -4,7 +4,6 @@ import ( "context" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/sql/models" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" mocks3 "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig/mocks" mocks5 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" @@ -14,6 +13,7 @@ import ( mocks2 "github.com/devtron-labs/devtron/pkg/chartRepo/repository/mocks" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" mocks4 "github.com/devtron-labs/devtron/pkg/cluster/repository/mocks" + repository4 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository/mocks" "github.com/devtron-labs/devtron/pkg/sql" @@ -438,7 +438,7 @@ func TestDeploymentTemplateHistoryService(t *testing.T) { mockedAppLevelMetricsRepository := mocks5.NewAppLevelMetricsRepository(t) - appLevelMetricsDBObject := &repository3.AppLevelMetrics{ + appLevelMetricsDBObject := &repository4.AppLevelMetrics{ Id: 1, AppId: 1, AppMetrics: false, @@ -452,7 +452,7 @@ func TestDeploymentTemplateHistoryService(t *testing.T) { appMetrics := true - mockedEnvLevelMetricsDBObject := &repository3.EnvLevelAppMetrics{ + mockedEnvLevelMetricsDBObject := &repository4.EnvLevelAppMetrics{ Id: 1, AppId: 1, EnvId: 1, @@ -521,7 +521,7 @@ func TestDeploymentTemplateHistoryService(t *testing.T) { mockedAppLevelMetricsRepository := mocks5.NewAppLevelMetricsRepository(t) - appLevelMetricsDBObject := &repository3.AppLevelMetrics{ + appLevelMetricsDBObject := &repository4.AppLevelMetrics{ Id: 1, AppId: 1, AppMetrics: false, @@ -533,7 +533,7 @@ func TestDeploymentTemplateHistoryService(t *testing.T) { mockedEnvLevelMetricsRepository := mocks5.NewEnvLevelAppMetricsRepository(t) - mockedEnvLevelMetricsDBObject := &repository3.EnvLevelAppMetrics{ + mockedEnvLevelMetricsDBObject := &repository4.EnvLevelAppMetrics{ Id: 0, AppId: 0, EnvId: 0, diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index 1f2d38e52b..b57eb6dafe 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -2,10 +2,10 @@ package deployedAppMetrics import ( "context" - interalRepo "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.opentelemetry.io/otel" @@ -24,14 +24,14 @@ type DeployedAppMetricsService interface { type DeployedAppMetricsServiceImpl struct { logger *zap.SugaredLogger chartRefRepository chartRepoRepository.ChartRefRepository - appLevelMetricsRepository interalRepo.AppLevelMetricsRepository - envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository + appLevelMetricsRepository repository.AppLevelMetricsRepository + envLevelMetricsRepository repository.EnvLevelAppMetricsRepository } func NewDeployedAppMetricsServiceImpl(logger *zap.SugaredLogger, chartRefRepository chartRepoRepository.ChartRefRepository, - appLevelMetricsRepository interalRepo.AppLevelMetricsRepository, - envLevelMetricsRepository interalRepo.EnvLevelAppMetricsRepository) *DeployedAppMetricsServiceImpl { + appLevelMetricsRepository repository.AppLevelMetricsRepository, + envLevelMetricsRepository repository.EnvLevelAppMetricsRepository) *DeployedAppMetricsServiceImpl { return &DeployedAppMetricsServiceImpl{ logger: logger, chartRefRepository: chartRefRepository, @@ -142,7 +142,7 @@ func (impl *DeployedAppMetricsServiceImpl) checkIsAppMetricsSupported(chartRefId return chartRefValue.IsAppMetricsSupported, nil } -func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.AppLevelMetrics, error) { +func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *bean.DeployedAppMetricsRequest) (*repository.AppLevelMetrics, error) { existingAppLevelMetrics, err := impl.appLevelMetricsRepository.FindByAppId(req.AppId) if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in app metrics app level flag", "error", err) @@ -159,7 +159,7 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *be } return existingAppLevelMetrics, nil } else { - appLevelMetricsNew := &interalRepo.AppLevelMetrics{ + appLevelMetricsNew := &repository.AppLevelMetrics{ AppId: req.AppId, AppMetrics: req.EnableMetrics, AuditLog: sql.AuditLog{ @@ -178,7 +178,7 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateAppLevelMetrics(req *be } } -func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *bean.DeployedAppMetricsRequest) (*interalRepo.EnvLevelAppMetrics, error) { +func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *bean.DeployedAppMetricsRequest) (*repository.EnvLevelAppMetrics, error) { // update and create env level app metrics envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(req.AppId, req.EnvId) if err != nil && err != pg.ErrNoRows { @@ -186,7 +186,7 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *be return nil, err } if envLevelAppMetrics == nil || envLevelAppMetrics.Id == 0 { - envLevelAppMetrics = &interalRepo.EnvLevelAppMetrics{ + envLevelAppMetrics = &repository.EnvLevelAppMetrics{ AppId: req.AppId, EnvId: req.EnvId, AppMetrics: &req.EnableMetrics, diff --git a/internal/sql/repository/AppLevelMetricsRepository.go b/pkg/deployment/manifest/deployedAppMetrics/repository/AppLevelMetricsRepository.go similarity index 100% rename from internal/sql/repository/AppLevelMetricsRepository.go rename to pkg/deployment/manifest/deployedAppMetrics/repository/AppLevelMetricsRepository.go diff --git a/internal/sql/repository/EnvLevelAppMetricsRepository.go b/pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go similarity index 100% rename from internal/sql/repository/EnvLevelAppMetricsRepository.go rename to pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go diff --git a/wire_gen.go b/wire_gen.go index ab2ddd83ba..57c5566906 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -103,6 +103,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + repository15 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -358,8 +359,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appLevelMetricsRepositoryImpl := repository.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) - envLevelAppMetricsRepositoryImpl := repository.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) + appLevelMetricsRepositoryImpl := repository15.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + envLevelAppMetricsRepositoryImpl := repository15.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, chartRefRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl) deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) chartWorkingDir := _wireChartWorkingDirValue From acfec88e50ac70b14d59c24c4d3d53326a710d55 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 15 Jan 2024 18:46:20 +0530 Subject: [PATCH 09/83] moved: const and types to bean --- pkg/appStore/bean/bean.go | 17 +++++++ .../deployment/service/InstalledAppService.go | 44 +++++++------------ 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 373cc85deb..6254551ce7 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -359,3 +359,20 @@ type HelmReleaseStatusConfig struct { IsReleaseInstalled bool ErrorInInstallation bool } + +type ChartComponents struct { + ChartComponent []*ChartComponent `json:"charts"` +} + +type ChartComponent struct { + Name string `json:"name"` + Values string `json:"values"` +} + +const ( + DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT = "devtron" + CLUSTER_COMPONENT_DIR_PATH = "/cluster/component" + HELM_RELEASE_STATUS_FAILED = "Failed" + HELM_RELEASE_STATUS_PROGRESSING = "Progressing" + HELM_RELEASE_STATUS_UNKNOWN = "Unknown" +) diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index cc426a9381..aebe347bcd 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -73,14 +73,6 @@ import ( "go.uber.org/zap" ) -const ( - DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT = "devtron" - CLUSTER_COMPONENT_DIR_PATH = "/cluster/component" - HELM_RELEASE_STATUS_FAILED = "Failed" - HELM_RELEASE_STATUS_PROGRESSING = "Progressing" - HELM_RELEASE_STATUS_UNKNOWN = "Unknown" -) - // DB operation + chart group + nats msg consume(to be removed) type InstalledAppService interface { GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) @@ -354,6 +346,7 @@ func (impl InstalledAppServiceImpl) createChartGroupEntryObject(installAppVersio }, } } + func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion *appStoreBean.InstallAppVersionDTO, ctx context.Context, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Name) chartGitAttr := &util.ChartGitAttribute{} @@ -498,6 +491,7 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion } return installedAppVersion, nil } + func (impl InstalledAppServiceImpl) performDeployStage(installedAppVersionId int, installedAppVersionHistoryId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { ctx := context.Background() installedAppVersion, err := impl.appStoreDeploymentService.GetInstalledAppVersion(installedAppVersionId, userId) @@ -640,7 +634,7 @@ func (impl *InstalledAppServiceImpl) Subscribe() error { func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) { // STEP 1 - create environment with name "devton" impl.logger.Infow("STEP 1", "create environment for cluster component", bean) - envName := fmt.Sprintf("%d-%s", bean.Id, DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) + envName := fmt.Sprintf("%d-%s", bean.Id, appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) env, err := impl.envService.FindOne(envName) if err != nil && err != pg.ErrNoRows { return false, err @@ -662,13 +656,13 @@ func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2. // STEP 2 - create project with name "devtron" impl.logger.Info("STEP 2", "create project for cluster components") - t, err := impl.teamRepository.FindByTeamName(DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) + t, err := impl.teamRepository.FindByTeamName(appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) if err != nil && err != pg.ErrNoRows { return false, err } if err == pg.ErrNoRows { t := &repository4.Team{ - Name: DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT, + Name: appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT, Active: true, AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, } @@ -681,13 +675,13 @@ func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2. // STEP 3- read the input data from env variables impl.logger.Info("STEP 3", "read the input data from env variables") - charts := &ChartComponents{} - var chartComponents []*ChartComponent - if _, err := os.Stat(CLUSTER_COMPONENT_DIR_PATH); os.IsNotExist(err) { + charts := &appStoreBean.ChartComponents{} + var chartComponents []*appStoreBean.ChartComponent + if _, err := os.Stat(appStoreBean.CLUSTER_COMPONENT_DIR_PATH); os.IsNotExist(err) { impl.logger.Infow("default cluster component directory error", "cluster", bean.ClusterName, "err", err) return false, nil } else { - fileInfo, err := ioutil.ReadDir(CLUSTER_COMPONENT_DIR_PATH) + fileInfo, err := ioutil.ReadDir(appStoreBean.CLUSTER_COMPONENT_DIR_PATH) if err != nil { impl.logger.Errorw("DeployDefaultChartOnCluster, err while reading directory", "err", err) return false, err @@ -695,12 +689,12 @@ func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2. for _, file := range fileInfo { impl.logger.Infow("file", "name", file.Name()) if strings.Contains(file.Name(), ".yaml") { - content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", CLUSTER_COMPONENT_DIR_PATH, file.Name())) + content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", appStoreBean.CLUSTER_COMPONENT_DIR_PATH, file.Name())) if err != nil { impl.logger.Errorw("DeployDefaultChartOnCluster, error on reading file", "err", err) return false, err } - chartComponent := &ChartComponent{ + chartComponent := &appStoreBean.ChartComponent{ Name: strings.ReplaceAll(file.Name(), ".yaml", ""), Values: string(content), } @@ -749,14 +743,6 @@ func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2. return true, nil } -type ChartComponents struct { - ChartComponent []*ChartComponent `json:"charts"` -} -type ChartComponent struct { - Name string `json:"name"` - Values string `json:"values"` -} - func (impl InstalledAppServiceImpl) DeployDefaultComponent(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) { impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) //save in db @@ -992,22 +978,22 @@ func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus impl.logger.Errorw("error in unmarshalling helm release install status") return releaseStatus } - if status == HELM_RELEASE_STATUS_FAILED { + if status == appStoreBean.HELM_RELEASE_STATUS_FAILED { releaseStatus.Status = status releaseStatus.Description = helmInstallStatus.Message releaseStatus.Message = "Release install/upgrade failed" - } else if status == HELM_RELEASE_STATUS_PROGRESSING { + } else if status == appStoreBean.HELM_RELEASE_STATUS_PROGRESSING { releaseStatus.Status = status releaseStatus.Description = helmInstallStatus.Message releaseStatus.Message = helmInstallStatus.Message } else { // there can be a case when helm release is created but we are not able to fetch it - releaseStatus.Status = HELM_RELEASE_STATUS_UNKNOWN + releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN releaseStatus.Description = "Unable to fetch release for app" releaseStatus.Message = "Unable to fetch release for app" } } else { - releaseStatus.Status = HELM_RELEASE_STATUS_UNKNOWN + releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN releaseStatus.Description = "Release not found" releaseStatus.Message = "Release not found " } From 0eb82b73472cb379344e3acd402ede201063afb8 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 15 Jan 2024 18:48:55 +0530 Subject: [PATCH 10/83] removed: unused const --- pkg/appStore/bean/bean.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 6254551ce7..314e0fd7f6 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -169,11 +169,6 @@ type Dependency struct { Repository string `json:"repository"` } -const BULK_APPSTORE_DEPLOY_TOPIC = "ORCHESTRATOR.APP-STORE.BULK-DEPLOY" -const BULK_APPSTORE_DEPLOY_GROUP = "ORCHESTRATOR.APP-STORE.BULK-DEPLOY-GROUP-1" - -const BULK_APPSTORE_DEPLOY_DURABLE = "ORCHESTRATOR.APP-STORE.BULK-DEPLOY.DURABLE-1" - type DeployPayload struct { InstalledAppVersionId int InstalledAppVersionHistoryId int From 765df77f07586978e874f07d24c579317d47bf2d Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 19:05:11 +0530 Subject: [PATCH 11/83] review comments --- pkg/app/AppListingService.go | 10 +++--- pkg/bulkAction/BulkUpdateService.go | 2 +- pkg/chart/ChartService.go | 8 ++--- .../deployedAppMetrics/DeployedAppMetrics.go | 24 ++++++------- .../EnvLevelAppMetricsRepository.go | 2 +- .../DeploymentPipelineConfigService.go | 4 +-- pkg/pipeline/PropertiesConfig.go | 4 +-- wire_gen.go | 34 +++++++++---------- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 462e851cef..0f67f2bad0 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -1672,11 +1672,11 @@ func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, app return envs, err } appLevelInfraMetrics := true //default val, not being derived from DB. TODO: remove this from FE since this is derived from prometheus config at cluster level and this logic is already present at FE - newCtx, span = otel.Tracer("appLevelMetricsRepository").Start(newCtx, "FindByAppId") - appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + newCtx, span = otel.Tracer("deployedAppMetricsService").Start(newCtx, "GetMetricsFlagByAppId") + appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(appId) span.End() if err != nil { - impl.Logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) + impl.Logger.Errorw("error, GetMetricsFlagByAppId", "err", err, "appId", appId) return envs, err } newCtx, span = otel.Tracer("chartRepository").Start(newCtx, "FindLatestChartForAppByAppId") @@ -1714,9 +1714,9 @@ func (impl AppListingServiceImpl) FetchMinDetailOtherEnvironment(appId int) ([]* return envs, err } appLevelInfraMetrics := true //default val, not being derived from DB. TODO: remove this from FE since this is derived from prometheus config at cluster level and this logic is already present at FE - appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + appLevelAppMetrics, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(appId) if err != nil { - impl.Logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) + impl.Logger.Errorw("error, GetMetricsFlagByAppId", "err", err, "appId", appId) return nil, err } diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index 9991ca32ee..d48612f705 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -453,7 +453,7 @@ func (impl BulkUpdateServiceImpl) BulkUpdateDeploymentTemplate(bulkUpdatePayload deploymentTemplateBulkUpdateResponse.Successful = append(deploymentTemplateBulkUpdateResponse.Successful, bulkUpdateSuccessResponse) //creating history entry for deployment template - appLevelAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(chart.AppId) + appLevelAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(chart.AppId) if err != nil { impl.logger.Errorw("error in getting app level metrics app level", "error", err, "appId", chart.AppId) return nil diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index ceb5956051..d3219e27c3 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -444,7 +444,7 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context ChartRefId: templateRequest.ChartRefId, UserId: templateRequest.UserId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err @@ -727,7 +727,7 @@ func (impl ChartServiceImpl) FindLatestChartForAppByAppId(appId int) (chartTempl impl.logger.Errorw("error in fetching chart ", "appId", appId, "err", err) return nil, err } - isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(appId) if err != nil { impl.logger.Errorw("error in fetching app-metrics", "appId", appId, "err", err) return nil, err @@ -742,7 +742,7 @@ func (impl ChartServiceImpl) GetByAppIdAndChartRefId(appId int, chartRefId int) impl.logger.Errorw("error in fetching chart ", "appId", appId, "err", err) return nil, err } - isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + isAppMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(appId) if err != nil { impl.logger.Errorw("error in fetching app-metrics", "appId", appId, "err", err) return nil, err @@ -841,7 +841,7 @@ func (impl ChartServiceImpl) UpdateAppOverride(ctx context.Context, templateRequ ChartRefId: templateRequest.ChartRefId, UserId: templateRequest.UserId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(ctx, appLevelMetricsUpdateReq) if err != nil { impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", appLevelMetricsUpdateReq) return nil, err diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index b57eb6dafe..2144b71cd5 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -14,10 +14,10 @@ import ( ) type DeployedAppMetricsService interface { - GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) + GetMetricsFlagByAppId(appId int) (bool, error) GetMetricsFlagByAppIdAndEnvId(appId, envId int) (bool, error) GetMetricsFlagForAPipelineByAppIdAndEnvId(appId, envId int) (bool, error) - CheckAndUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error + CreateOrUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error DeleteEnvLevelMetricsIfPresent(appId, envId int) error } @@ -40,7 +40,7 @@ func NewDeployedAppMetricsServiceImpl(logger *zap.SugaredLogger, } } -func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdEvenIfNotInDb(appId int) (bool, error) { +func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppId(appId int) (bool, error) { isAppMetricsEnabled := false appMetrics, err := impl.appLevelMetricsRepository.FindByAppId(appId) if err != nil && err != pg.ErrNoRows { @@ -56,12 +56,12 @@ func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdEvenIfNotInDb(ap func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagByAppIdAndEnvId(appId, envId int) (bool, error) { isAppMetricsEnabled := false envLevelAppMetrics, err := impl.envLevelMetricsRepository.FindByAppIdAndEnvId(appId, envId) - if err != nil && err != pg.ErrNoRows { + if err != nil { impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envId) return isAppMetricsEnabled, err } if envLevelAppMetrics != nil { - isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + isAppMetricsEnabled = envLevelAppMetrics.AppMetrics } return isAppMetricsEnabled, nil } @@ -74,20 +74,20 @@ func (impl *DeployedAppMetricsServiceImpl) GetMetricsFlagForAPipelineByAppIdAndE impl.logger.Errorw("error in getting env level app metrics", "err", err, "appId", appId, "envId", envId) return isAppMetricsEnabled, err } else if err == pg.ErrNoRows { - isAppLevelMetricsEnabled, err := impl.GetMetricsFlagByAppIdEvenIfNotInDb(appId) + isAppLevelMetricsEnabled, err := impl.GetMetricsFlagByAppId(appId) if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", appId) + impl.logger.Errorw("error, GetMetricsFlagByAppId", "err", err, "appId", appId) return false, err } isAppMetricsEnabled = isAppLevelMetricsEnabled - } else if envLevelAppMetrics != nil && envLevelAppMetrics.AppMetrics != nil { - isAppMetricsEnabled = *envLevelAppMetrics.AppMetrics + } else if envLevelAppMetrics != nil { + isAppMetricsEnabled = envLevelAppMetrics.AppMetrics } return isAppMetricsEnabled, nil } // CheckAndUpdateAppOrEnvLevelMetrics - this method checks whether chart being used supports metrics or not, is app level or env level and updates accordingly -func (impl *DeployedAppMetricsServiceImpl) CheckAndUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error { +func (impl *DeployedAppMetricsServiceImpl) CreateOrUpdateAppOrEnvLevelMetrics(ctx context.Context, req *bean.DeployedAppMetricsRequest) error { isAppMetricsSupported, err := impl.checkIsAppMetricsSupported(req.ChartRefId) if err != nil { return err @@ -189,7 +189,7 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *be envLevelAppMetrics = &repository.EnvLevelAppMetrics{ AppId: req.AppId, EnvId: req.EnvId, - AppMetrics: &req.EnableMetrics, + AppMetrics: req.EnableMetrics, AuditLog: sql.AuditLog{ CreatedOn: time.Now(), UpdatedOn: time.Now(), @@ -203,7 +203,7 @@ func (impl *DeployedAppMetricsServiceImpl) createOrUpdateEnvLevelMetrics(req *be return nil, err } } else { - envLevelAppMetrics.AppMetrics = &req.EnableMetrics + envLevelAppMetrics.AppMetrics = req.EnableMetrics envLevelAppMetrics.UpdatedOn = time.Now() envLevelAppMetrics.UpdatedBy = req.UserId err = impl.envLevelMetricsRepository.Update(envLevelAppMetrics) diff --git a/pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go b/pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go index bb81432024..9c985ab6e3 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go +++ b/pkg/deployment/manifest/deployedAppMetrics/repository/EnvLevelAppMetricsRepository.go @@ -28,7 +28,7 @@ type EnvLevelAppMetrics struct { Id int `sql:"id,pk"` AppId int `sql:"app_id,notnull"` EnvId int `sql:"env_id,notnull"` - AppMetrics *bool `sql:"app_metrics,notnull"` + AppMetrics bool `sql:"app_metrics,notnull"` //InfraMetrics *bool `sql:"infra_metrics,notnull"` not being used sql.AuditLog } diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index d7a3dfd307..794f7bfaac 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -1674,9 +1674,9 @@ func (impl *CdPipelineConfigServiceImpl) createCdPipeline(ctx context.Context, a } //getting global app metrics for cd pipeline create because env level metrics is not created yet appLevelAppMetricsEnabled := false - isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppIdEvenIfNotInDb(app.Id) + isAppLevelMetricsEnabled, err := impl.deployedAppMetricsService.GetMetricsFlagByAppId(app.Id) if err != nil { - impl.logger.Errorw("error, GetMetricsFlagByAppIdEvenIfNotInDb", "err", err, "appId", app.Id) + impl.logger.Errorw("error, GetMetricsFlagByAppId", "err", err, "appId", app.Id) return 0, err } appLevelAppMetricsEnabled = isAppLevelMetricsEnabled diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 686042bd65..210bef4093 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -324,7 +324,7 @@ func (impl PropertiesConfigServiceImpl) UpdateEnvironmentProperties(appId int, p ChartRefId: oldEnvOverride.Chart.ChartRefId, UserId: propertiesRequest.UserId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) if err != nil { impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) return nil, err @@ -434,7 +434,7 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit ChartRefId: chart.ChartRefId, UserId: userId, } - err = impl.deployedAppMetricsService.CheckAndUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) + err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) if err != nil { impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) return nil, isAppMetricsEnabled, err diff --git a/wire_gen.go b/wire_gen.go index 57c5566906..81d0d2ad50 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -45,7 +45,7 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/cluster" "github.com/devtron-labs/devtron/client/argocdServer/connection" - repository9 "github.com/devtron-labs/devtron/client/argocdServer/repository" + repository10 "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/client/dashboard" "github.com/devtron-labs/devtron/client/events" @@ -62,7 +62,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" repository5 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository13 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + repository14 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" "github.com/devtron-labs/devtron/internal/sql/repository/security" @@ -103,7 +103,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" - repository15 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" + repository9 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -111,7 +111,7 @@ import ( "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/genericNotes" - repository10 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" + repository11 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" jira2 "github.com/devtron-labs/devtron/pkg/jira" @@ -120,7 +120,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository14 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository15 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -129,10 +129,10 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/history" repository6 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - repository11 "github.com/devtron-labs/devtron/pkg/pipeline/repository" + repository12 "github.com/devtron-labs/devtron/pkg/pipeline/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" - repository12 "github.com/devtron-labs/devtron/pkg/plugin/repository" + repository13 "github.com/devtron-labs/devtron/pkg/plugin/repository" "github.com/devtron-labs/devtron/pkg/projectManagementService/jira" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" @@ -359,8 +359,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appLevelMetricsRepositoryImpl := repository15.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) - envLevelAppMetricsRepositoryImpl := repository15.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) + appLevelMetricsRepositoryImpl := repository9.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + envLevelAppMetricsRepositoryImpl := repository9.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, chartRefRepositoryImpl, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl) deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) chartWorkingDir := _wireChartWorkingDirValue @@ -375,7 +375,7 @@ func InitializeApp() (*App, error) { utilMergeUtil := util.MergeUtil{ Logger: sugaredLogger, } - repositoryServiceClientImpl := repository9.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) + repositoryServiceClientImpl := repository10.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, refChartDir, defaultChart, utilMergeUtil, repositoryServiceClientImpl, chartRefRepositoryImpl, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, httpClient, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) devtronSecretConfig, err := util3.GetDevtronSecretName() if err != nil { @@ -388,8 +388,8 @@ func InitializeApp() (*App, error) { } pipelineStatusTimelineRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineRepositoryImpl(db, sugaredLogger) appLabelRepositoryImpl := pipelineConfig.NewAppLabelRepositoryImpl(db) - genericNoteRepositoryImpl := repository10.NewGenericNoteRepositoryImpl(db) - genericNoteHistoryRepositoryImpl := repository10.NewGenericNoteHistoryRepositoryImpl(db) + genericNoteRepositoryImpl := repository11.NewGenericNoteRepositoryImpl(db) + genericNoteHistoryRepositoryImpl := repository11.NewGenericNoteHistoryRepositoryImpl(db) genericNoteHistoryServiceImpl := genericNotes.NewGenericNoteHistoryServiceImpl(genericNoteHistoryRepositoryImpl, sugaredLogger) genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) @@ -427,7 +427,7 @@ func InitializeApp() (*App, error) { } appStoreDeploymentServiceImpl := service.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImplExtended) - manifestPushConfigRepositoryImpl := repository11.NewManifestPushConfigRepository(sugaredLogger, db) + manifestPushConfigRepositoryImpl := repository12.NewManifestPushConfigRepository(sugaredLogger, db) gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, chartServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig) appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, ciArtifactRepositoryImpl, pipelineRepositoryImpl, dbMigrationConfigRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, tokenCache, acdAuthConfig, enforcerImpl, enforcerUtilImpl, userServiceImpl, appListingRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, imageScanDeployInfoRepositoryImpl, imageScanHistoryRepositoryImpl, argoK8sClientImpl, gitFactory, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, chartTemplateServiceImpl, refChartDir, chartRefRepositoryImpl, chartServiceImpl, helmAppClientImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, appCrudOperationServiceImpl, configMapHistoryRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, dockerRegistryIpsConfigServiceImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, gitOpsConfigRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, appStoreDeploymentServiceImpl, k8sCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, helmAppServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, argoClientWrapperServiceImpl, scopedVariableCMCSManagerImpl, acdConfig) validate, err := util.IntValidator() @@ -461,8 +461,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - pipelineStageRepositoryImpl := repository11.NewPipelineStageRepository(sugaredLogger, db) - globalPluginRepositoryImpl := repository12.NewGlobalPluginRepository(sugaredLogger, db) + pipelineStageRepositoryImpl := repository12.NewPipelineStageRepository(sugaredLogger, db) + globalPluginRepositoryImpl := repository13.NewGlobalPluginRepository(sugaredLogger, db) pipelineStageServiceImpl := pipeline.NewPipelineStageService(sugaredLogger, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, pipelineRepositoryImpl, scopedVariableManagerImpl) globalPluginServiceImpl := plugin.NewGlobalPluginService(sugaredLogger, globalPluginRepositoryImpl, pipelineStageRepositoryImpl) dockerRegistryConfigImpl := pipeline.NewDockerRegistryConfigImpl(sugaredLogger, helmAppServiceImpl, dockerArtifactStoreRepositoryImpl, dockerRegistryIpsConfigRepositoryImpl, ociRegistryConfigRepositoryImpl) @@ -500,7 +500,7 @@ func InitializeApp() (*App, error) { buildPipelineSwitchServiceImpl := pipeline.NewBuildPipelineSwitchServiceImpl(sugaredLogger, ciPipelineRepositoryImpl, ciCdPipelineOrchestratorImpl, pipelineRepositoryImpl, ciWorkflowRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineHistoryServiceImpl, ciTemplateOverrideRepositoryImpl, ciPipelineMaterialRepositoryImpl) ciPipelineConfigServiceImpl := pipeline.NewCiPipelineConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, dockerArtifactStoreRepositoryImpl, materialRepositoryImpl, appRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ecrConfig, appWorkflowRepositoryImpl, ciCdConfig, attributesServiceImpl, pipelineStageServiceImpl, ciPipelineMaterialRepositoryImpl, ciTemplateServiceImpl, ciTemplateOverrideRepositoryImpl, ciTemplateHistoryServiceImpl, enforcerUtilImpl, ciWorkflowRepositoryImpl, resourceGroupServiceImpl, customTagServiceImpl, ciPipelineHistoryServiceImpl, cdWorkflowRepositoryImpl, buildPipelineSwitchServiceImpl) ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) - imageTaggingRepositoryImpl := repository13.NewImageTaggingRepositoryImpl(db) + imageTaggingRepositoryImpl := repository14.NewImageTaggingRepositoryImpl(db) imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, chartRefRepositoryImpl, utilMergeUtil, environmentRepositoryImpl, ciCdPipelineOrchestratorImpl, applicationServiceClientImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) pipelineDeploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() @@ -551,7 +551,7 @@ func InitializeApp() (*App, error) { migrateDbRouterImpl := router.NewMigrateDbRouterImpl(migrateDbRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) - k8sResourceHistoryRepositoryImpl := repository14.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) From 5038a0b2ef48a02130876159553d1d2c524f62da Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 19:35:57 +0530 Subject: [PATCH 12/83] migrated some methods from chartService to chartRefService --- api/deployment/DeploymentConfigRestHandler.go | 2 +- .../app/DeploymentPipelineRestHandler.go | 4 +-- pkg/chart/ChartService.go | 33 ----------------- .../chartRef/ChartRefService.go | 35 +++++++++++++++++++ 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/api/deployment/DeploymentConfigRestHandler.go b/api/deployment/DeploymentConfigRestHandler.go index d9d819959e..8e27a52a5d 100644 --- a/api/deployment/DeploymentConfigRestHandler.go +++ b/api/deployment/DeploymentConfigRestHandler.go @@ -85,7 +85,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo return } - err = handler.chartService.ValidateUploadedFileFormat(fileHeader.Filename) + err = handler.chartRefService.ValidateCustomChartUploadedFileFormat(fileHeader.Filename) if err != nil { handler.Logger.Errorw("request err, Unsupported format", "err", err, "payload", file) common.WriteJsonResp(w, errors.New("Unsupported format file is uploaded, please upload file with .tgz extension"), nil, http.StatusBadRequest) diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 8889f2d5ea..5e9489f69a 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -877,7 +877,7 @@ func (handler PipelineConfigRestHandlerImpl) GetEnvConfigOverride(w http.Respons return } - schema, readme, err := handler.chartService.GetSchemaAndReadmeForTemplateByChartRefId(chartRefId) + schema, readme, err := handler.chartRefService.GetSchemaAndReadmeForTemplateByChartRefId(chartRefId) if err != nil { handler.Logger.Errorw("err in getting schema and readme, GetEnvConfigOverride", "err", err, "appId", appId, "chartRefId", chartRefId) } @@ -997,7 +997,7 @@ func (handler PipelineConfigRestHandlerImpl) GetDeploymentTemplate(w http.Respon return } - schema, readme, err := handler.chartService.GetSchemaAndReadmeForTemplateByChartRefId(chartRefId) + schema, readme, err := handler.chartRefService.GetSchemaAndReadmeForTemplateByChartRefId(chartRefId) if err != nil { handler.Logger.Errorw("err in getting schema and readme, GetDeploymentTemplate", "err", err, "appId", appId, "chartRefId", chartRefId) } diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 0212bc570a..dca2a43761 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -72,8 +72,6 @@ type ChartService interface { UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) DeploymentTemplateValidate(ctx context.Context, templatejson interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) - GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) (schema []byte, readme []byte, err error) - ValidateUploadedFileFormat(fileName string) error CheckIfChartRefUserUploadedByAppId(id int) (bool, error) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) @@ -151,30 +149,6 @@ func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartT return PatchWinterSoldierConfig(values, newChartType) } -func (impl ChartServiceImpl) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) { - refChart, _, err, _, _ := impl.chartRefService.GetRefChart(chartRefId) - if err != nil { - impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) - return nil, nil, err - } - var schemaByte []byte - var readmeByte []byte - err = impl.chartRefService.CheckChartExists(chartRefId) - if err != nil { - impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) - return nil, nil, err - } - schemaByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "schema.json"))) - if err != nil { - impl.logger.Errorw("error in reading schema.json file for refChart", "err", err, "chartRefId", chartRefId) - } - readmeByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "README.md"))) - if err != nil { - impl.logger.Errorw("error in reading readme file for refChart", "err", err, "chartRefId", chartRefId) - } - return schemaByte, readmeByte, nil -} - func (impl ChartServiceImpl) GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) { err := impl.chartRefService.CheckChartExists(chartRefId) if err != nil { @@ -1063,13 +1037,6 @@ func (impl ChartServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[stri } } -func (impl *ChartServiceImpl) ValidateUploadedFileFormat(fileName string) error { - if !strings.HasSuffix(fileName, ".tgz") { - return errors.New("unsupported format") - } - return nil -} - func (impl ChartServiceImpl) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) { chartInfo, err := impl.chartRepository.FindLatestChartForAppByAppId(id) if err != nil { diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go index 0bfd0bd278..01afd15aff 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -33,6 +33,9 @@ type ChartRefService interface { SaveCustomChart(req *bean.CustomChartRefDto) error FetchCustomChartsInfo() ([]*bean.ChartDto, error) + ValidateCustomChartUploadedFileFormat(fileName string) error + + GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) @@ -61,6 +64,13 @@ func NewChartRefServiceImpl(logger *zap.SugaredLogger, } } +func (impl *ChartRefServiceImpl) ValidateCustomChartUploadedFileFormat(fileName string) error { + if !strings.HasSuffix(fileName, ".tgz") { + return errors.New("unsupported format") + } + return nil +} + func (impl *ChartRefServiceImpl) GetDefault() (*bean.ChartRefDto, error) { chartRef, err := impl.chartRefRepository.GetDefault() if err != nil { @@ -98,6 +108,7 @@ func (impl *ChartRefServiceImpl) GetAllChartMetadata() (map[string]bean.ChartRef } return chartsMetadataMap, nil } + func (impl *ChartRefServiceImpl) ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) { oldChart, err := impl.FindById(oldChartRefId) if err != nil { @@ -199,6 +210,30 @@ func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, er return chartPath, template, nil, version, pipelineStrategyPath } +func (impl *ChartRefServiceImpl) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) { + refChart, _, err, _, _ := impl.GetRefChart(chartRefId) + if err != nil { + impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) + return nil, nil, err + } + var schemaByte []byte + var readmeByte []byte + err = impl.CheckChartExists(chartRefId) + if err != nil { + impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) + return nil, nil, err + } + schemaByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "schema.json"))) + if err != nil { + impl.logger.Errorw("error in reading schema.json file for refChart", "err", err, "chartRefId", chartRefId) + } + readmeByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "README.md"))) + if err != nil { + impl.logger.Errorw("error in reading readme file for refChart", "err", err, "chartRefId", chartRefId) + } + return schemaByte, readmeByte, nil +} + func (impl *ChartRefServiceImpl) ChartRefAutocomplete() ([]*bean.ChartRefAutocompleteDto, error) { var chartRefs []*bean.ChartRefAutocompleteDto results, err := impl.chartRefRepository.GetAll() From c38d5288e869569407ca09aa354f738792c99026 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Mon, 15 Jan 2024 20:09:41 +0530 Subject: [PATCH 13/83] added dt validation service interface --- .../DeploymentTemplateValidationService.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go diff --git a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go new file mode 100644 index 0000000000..6c851bc518 --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go @@ -0,0 +1,16 @@ +package deploymentTemplate + +import "go.uber.org/zap" + +type DeploymentTemplateValidationService interface { +} + +type DeploymentTemplateValidationServiceImpl struct { + logger *zap.SugaredLogger +} + +func NewDeploymentTemplateValidationServiceImpl(logger *zap.SugaredLogger) *DeploymentTemplateValidationServiceImpl { + return &DeploymentTemplateValidationServiceImpl{ + logger: logger, + } +} From f0e449e6cfba75c77028b077d1ef33373dbe5d87 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 17:41:25 +0530 Subject: [PATCH 14/83] minor refactoring --- .../app/DeploymentPipelineRestHandler.go | 8 +- pkg/chart/ChartService.go | 98 +---------------- .../chartRef/ChartRefService.go | 100 +++++++++++++++++- .../DeployementTemplateService.go | 2 +- wire_gen.go | 8 +- 5 files changed, 109 insertions(+), 107 deletions(-) diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 5e9489f69a..22eec8e413 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -1010,7 +1010,7 @@ func (handler PipelineConfigRestHandlerImpl) GetDeploymentTemplate(w http.Respon } if pg.ErrNoRows == err { - appOverride, _, err := handler.chartService.GetAppOverrideForDefaultTemplate(chartRefId) + appOverride, _, err := handler.chartRefService.GetAppOverrideForDefaultTemplate(chartRefId) if err != nil { handler.Logger.Errorw("service err, GetDeploymentTemplate", "err", err, "appId", appId, "chartRefId", chartRefId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -1085,7 +1085,7 @@ func (handler *PipelineConfigRestHandlerImpl) GetDefaultDeploymentTemplate(w htt common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "unauthorized user", http.StatusForbidden) return } - defaultTemplate, _, err := handler.chartService.GetAppOverrideForDefaultTemplate(chartRefId) + defaultTemplate, _, err := handler.chartRefService.GetAppOverrideForDefaultTemplate(chartRefId) if err != nil { handler.Logger.Errorw("error in getting default deployment template, GetDefaultDeploymentTemplate", "err", err, "appId", appId, "chartRefId", chartRefId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -1363,7 +1363,7 @@ func (handler PipelineConfigRestHandlerImpl) GetAppOverrideForDefaultTemplate(w } //RBAC - appOverride, _, err := handler.chartService.GetAppOverrideForDefaultTemplate(chartRefId) + appOverride, _, err := handler.chartRefService.GetAppOverrideForDefaultTemplate(chartRefId) if err != nil { handler.Logger.Errorw("service err, UpdateCiTemplate", "err", err, "appId", appId, "chartRefId", chartRefId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -2311,7 +2311,7 @@ func (handler PipelineConfigRestHandlerImpl) UpgradeForAllApps(w http.ResponseWr return } - newAppOverride, _, err := handler.chartService.GetAppOverrideForDefaultTemplate(chartUpgradeRequest.ChartRefId) + newAppOverride, _, err := handler.chartRefService.GetAppOverrideForDefaultTemplate(chartUpgradeRequest.ChartRefId) if err != nil { handler.Logger.Errorw("service err, UpgradeForAllApps", "err", err, "payload", chartUpgradeRequest) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index dca2a43761..3e32659efb 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -39,8 +39,6 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history" - "io/ioutil" - "os" "path/filepath" "strconv" "strings" @@ -65,13 +63,11 @@ type ChartService interface { CreateChartFromEnvOverride(templateRequest TemplateRequest, ctx context.Context) (chart *TemplateRequest, err error) FindLatestChartForAppByAppId(appId int) (chartTemplate *TemplateRequest, err error) GetByAppIdAndChartRefId(appId int, chartRefId int) (chartTemplate *TemplateRequest, err error) - GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) UpdateAppOverride(ctx context.Context, templateRequest *TemplateRequest) (*TemplateRequest, error) IsReadyToTrigger(appId int, envId int, pipelineId int) (IsReady, error) FindPreviousChartByAppId(appId int) (chartTemplate *TemplateRequest, err error) UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) DeploymentTemplateValidate(ctx context.Context, templatejson interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) - JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) @@ -149,60 +145,6 @@ func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartT return PatchWinterSoldierConfig(values, newChartType) } -func (impl ChartServiceImpl) GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) { - err := impl.chartRefService.CheckChartExists(chartRefId) - if err != nil { - impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") - return nil, "", err - } - - refChart, _, err, _, _ := impl.chartRefService.GetRefChart(chartRefId) - if err != nil { - return nil, "", err - } - var appOverrideByte, envOverrideByte []byte - appOverrideByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "app-values.yaml"))) - if err != nil { - impl.logger.Infow("App values yaml file is missing") - } else { - appOverrideByte, err = yaml.YAMLToJSON(appOverrideByte) - if err != nil { - return nil, "", err - } - } - - envOverrideByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "env-values.yaml"))) - if err != nil { - impl.logger.Infow("Env values yaml file is missing") - } else { - envOverrideByte, err = yaml.YAMLToJSON(envOverrideByte) - if err != nil { - return nil, "", err - } - } - - messages := make(map[string]interface{}) - var merged []byte - if appOverrideByte == nil && envOverrideByte == nil { - return messages, "", nil - } else if appOverrideByte == nil || envOverrideByte == nil { - if appOverrideByte == nil { - merged = envOverrideByte - } else { - merged = appOverrideByte - } - } else { - merged, err = impl.mergeUtil.JsonPatch(appOverrideByte, []byte(envOverrideByte)) - if err != nil { - return nil, "", err - } - } - - appOverride := json.RawMessage(merged) - messages["defaultAppOverride"] = appOverride - return messages, string(merged), nil -} - type AppMetricsEnabled struct { AppMetrics bool `json:"app-metrics"` } @@ -924,7 +866,7 @@ const memory = "memory" func (impl ChartServiceImpl) DeploymentTemplateValidate(ctx context.Context, template interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) { _, span := otel.Tracer("orchestrator").Start(ctx, "JsonSchemaExtractFromFile") - schemajson, version, err := impl.JsonSchemaExtractFromFile(chartRefId) + schemajson, version, err := impl.chartRefService.JsonSchemaExtractFromFile(chartRefId) span.End() if err != nil { impl.logger.Errorw("Json Schema not found err, FindJsonSchema", "err", err) @@ -999,44 +941,6 @@ func (impl ChartServiceImpl) DeploymentTemplateValidate(ctx context.Context, tem } } -func (impl ChartServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) { - err := impl.chartRefService.CheckChartExists(chartRefId) - if err != nil { - impl.logger.Errorw("refChartDir Not Found", "err", err) - return nil, "", err - } - - refChartDir, _, err, version, _ := impl.chartRefService.GetRefChart(chartRefId) - if err != nil { - impl.logger.Errorw("refChartDir Not Found err, JsonSchemaExtractFromFile", err) - return nil, "", err - } - fileStatus := filepath.Join(refChartDir, "schema.json") - if _, err := os.Stat(fileStatus); os.IsNotExist(err) { - impl.logger.Errorw("Schema File Not Found err, JsonSchemaExtractFromFile", err) - return nil, "", err - } else { - jsonFile, err := os.Open(fileStatus) - if err != nil { - impl.logger.Errorw("jsonfile open err, JsonSchemaExtractFromFile", "err", err) - return nil, "", err - } - byteValueJsonFile, err := ioutil.ReadAll(jsonFile) - if err != nil { - impl.logger.Errorw("byteValueJsonFile read err, JsonSchemaExtractFromFile", "err", err) - return nil, "", err - } - - var schemajson map[string]interface{} - err = json.Unmarshal([]byte(byteValueJsonFile), &schemajson) - if err != nil { - impl.logger.Errorw("Unmarshal err in byteValueJsonFile, DeploymentTemplateValidate", "err", err) - return nil, "", err - } - return schemajson, version, nil - } -} - func (impl ChartServiceImpl) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) { chartInfo, err := impl.chartRepository.FindLatestChartForAppByAppId(id) if err != nil { diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go index 01afd15aff..2b10d904b6 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -2,6 +2,7 @@ package chartRef import ( "bytes" + "encoding/json" "errors" "fmt" "github.com/devtron-labs/devtron/internal/constants" @@ -35,6 +36,9 @@ type ChartRefService interface { FetchCustomChartsInfo() ([]*bean.ChartDto, error) ValidateCustomChartUploadedFileFormat(fileName string) error + GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) + + JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) @@ -49,11 +53,13 @@ type ChartRefServiceImpl struct { logger *zap.SugaredLogger chartRefRepository chartRepoRepository.ChartRefRepository chartTemplateService util.ChartTemplateService + mergeUtil util.MergeUtil } func NewChartRefServiceImpl(logger *zap.SugaredLogger, chartRefRepository chartRepoRepository.ChartRefRepository, - chartTemplateService util.ChartTemplateService) *ChartRefServiceImpl { + chartTemplateService util.ChartTemplateService, + mergeUtil util.MergeUtil) *ChartRefServiceImpl { // cache devtron reference charts list devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) setReservedChartList(devtronChartList) @@ -61,6 +67,7 @@ func NewChartRefServiceImpl(logger *zap.SugaredLogger, logger: logger, chartRefRepository: chartRefRepository, chartTemplateService: chartTemplateService, + mergeUtil: mergeUtil, } } @@ -328,6 +335,97 @@ func (impl *ChartRefServiceImpl) CheckChartExists(chartRefId int) error { } return nil } +func (impl *ChartRefServiceImpl) GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) { + err := impl.CheckChartExists(chartRefId) + if err != nil { + impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") + return nil, "", err + } + + refChart, _, err, _, _ := impl.GetRefChart(chartRefId) + if err != nil { + return nil, "", err + } + var appOverrideByte, envOverrideByte []byte + appOverrideByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "app-values.yaml"))) + if err != nil { + impl.logger.Infow("App values yaml file is missing") + } else { + appOverrideByte, err = yaml.YAMLToJSON(appOverrideByte) + if err != nil { + return nil, "", err + } + } + + envOverrideByte, err = ioutil.ReadFile(filepath.Clean(filepath.Join(refChart, "env-values.yaml"))) + if err != nil { + impl.logger.Infow("Env values yaml file is missing") + } else { + envOverrideByte, err = yaml.YAMLToJSON(envOverrideByte) + if err != nil { + return nil, "", err + } + } + + messages := make(map[string]interface{}) + var merged []byte + if appOverrideByte == nil && envOverrideByte == nil { + return messages, "", nil + } else if appOverrideByte == nil || envOverrideByte == nil { + if appOverrideByte == nil { + merged = envOverrideByte + } else { + merged = appOverrideByte + } + } else { + merged, err = impl.mergeUtil.JsonPatch(appOverrideByte, []byte(envOverrideByte)) + if err != nil { + return nil, "", err + } + } + + appOverride := json.RawMessage(merged) + messages["defaultAppOverride"] = appOverride + return messages, string(merged), nil +} + +func (impl *ChartRefServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) { + err := impl.CheckChartExists(chartRefId) + if err != nil { + impl.logger.Errorw("refChartDir Not Found", "err", err) + return nil, "", err + } + + refChartDir, _, err, version, _ := impl.GetRefChart(chartRefId) + if err != nil { + impl.logger.Errorw("refChartDir Not Found err, JsonSchemaExtractFromFile", err) + return nil, "", err + } + fileStatus := filepath.Join(refChartDir, "schema.json") + if _, err := os.Stat(fileStatus); os.IsNotExist(err) { + impl.logger.Errorw("Schema File Not Found err, JsonSchemaExtractFromFile", err) + return nil, "", err + } else { + jsonFile, err := os.Open(fileStatus) + if err != nil { + impl.logger.Errorw("jsonfile open err, JsonSchemaExtractFromFile", "err", err) + return nil, "", err + } + byteValueJsonFile, err := ioutil.ReadAll(jsonFile) + if err != nil { + impl.logger.Errorw("byteValueJsonFile read err, JsonSchemaExtractFromFile", "err", err) + return nil, "", err + } + + var schemajson map[string]interface{} + err = json.Unmarshal([]byte(byteValueJsonFile), &schemajson) + if err != nil { + impl.logger.Errorw("Unmarshal err in byteValueJsonFile, DeploymentTemplateValidate", "err", err) + return nil, "", err + } + return schemajson, version, nil + } +} func (impl *ChartRefServiceImpl) ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*bean.ChartDataInfo, error) { binaryDataReader := bytes.NewReader(chartData) diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index 1cb3023bf7..b35924856a 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -200,7 +200,7 @@ func (impl DeploymentTemplateServiceImpl) GetDeploymentTemplate(ctx context.Cont } else { switch request.Type { case repository.DefaultVersions: - _, values, err = impl.chartService.GetAppOverrideForDefaultTemplate(request.ChartRefId) + _, values, err = impl.chartRefService.GetAppOverrideForDefaultTemplate(request.ChartRefId) resolvedValue = values case repository.PublishedOnEnvironments: values, resolvedValue, variableSnapshot, err = impl.fetchResolvedTemplateForPublishedEnvs(ctx, request) diff --git a/wire_gen.go b/wire_gen.go index f32319b90d..5e774bbe7a 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -367,7 +367,10 @@ func InitializeApp() (*App, error) { return nil, err } chartRefRepositoryImpl := chartRepoRepository.NewChartRefRepositoryImpl(db) - chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl) + utilMergeUtil := util.MergeUtil{ + Logger: sugaredLogger, + } + chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl, utilMergeUtil) appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl) validate, err := util.IntValidator() if err != nil { @@ -462,9 +465,6 @@ func InitializeApp() (*App, error) { ciBuildConfigServiceImpl := pipeline.NewCiBuildConfigServiceImpl(sugaredLogger, ciBuildConfigRepositoryImpl) ciTemplateServiceImpl := pipeline.NewCiTemplateServiceImpl(sugaredLogger, ciBuildConfigServiceImpl, ciTemplateRepositoryImpl, ciTemplateOverrideRepositoryImpl) chartRepoRepositoryImpl := chartRepoRepository.NewChartRepoRepositoryImpl(db) - utilMergeUtil := util.MergeUtil{ - Logger: sugaredLogger, - } configMapServiceImpl := pipeline.NewConfigMapServiceImpl(chartRepositoryImpl, sugaredLogger, chartRepoRepositoryImpl, utilMergeUtil, pipelineConfigRepositoryImpl, configMapRepositoryImpl, envConfigOverrideRepositoryImpl, commonServiceImpl, appRepositoryImpl, configMapHistoryServiceImpl, environmentRepositoryImpl, scopedVariableCMCSManagerImpl) ciCdPipelineOrchestratorImpl := pipeline.NewCiCdPipelineOrchestrator(appRepositoryImpl, sugaredLogger, materialRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciCdConfig, appWorkflowRepositoryImpl, environmentRepositoryImpl, attributesServiceImpl, appListingRepositoryImpl, appCrudOperationServiceImpl, userAuthServiceImpl, prePostCdScriptHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, ciTemplateOverrideRepositoryImpl, gitMaterialHistoryServiceImpl, ciPipelineHistoryServiceImpl, ciTemplateServiceImpl, dockerArtifactStoreRepositoryImpl, ciArtifactRepositoryImpl, configMapServiceImpl, customTagServiceImpl, genericNoteServiceImpl) ecrConfig, err := pipeline.GetEcrConfig() From c151a32daa30fd71757f521c83e53eb79909b1a0 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 18:30:39 +0530 Subject: [PATCH 15/83] moved validation method - 1 --- .../app/DeploymentPipelineRestHandler.go | 10 +- .../app/PipelineConfigRestHandler.go | 132 +++++++++--------- pkg/chart/ChartService.go | 87 ------------ .../DeploymentTemplateValidationService.go | 97 ++++++++++++- .../manifest/wire_deployment_manifest.go | 2 + wire_gen.go | 4 +- 6 files changed, 171 insertions(+), 161 deletions(-) diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 22eec8e413..61776a94e8 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -119,7 +119,7 @@ func (handler PipelineConfigRestHandlerImpl) ConfigureDeploymentTemplateForApp(w scope := resourceQualifiers.Scope{ AppId: templateRequest.AppId, } - validate, err2 := handler.chartService.DeploymentTemplateValidate(r.Context(), templateRequest.ValuesOverride, chartRefId, scope) + validate, err2 := handler.deploymentTemplateValidationService.DeploymentTemplateValidate(r.Context(), templateRequest.ValuesOverride, chartRefId, scope) if !validate { common.WriteJsonResp(w, err2, nil, http.StatusBadRequest) return @@ -593,7 +593,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite EnvId: request.EnvId, ClusterId: envConfigProperties.ClusterId, } - validate, err2 := handler.chartService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, envConfigProperties.ChartRefId, scope) + validate, err2 := handler.deploymentTemplateValidationService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, envConfigProperties.ChartRefId, scope) if !validate { handler.Logger.Errorw("validation err, UpdateAppOverride", "err", err2, "payload", request) common.WriteJsonResp(w, err2, "validation err, UpdateAppOverrid", http.StatusBadRequest) @@ -714,7 +714,7 @@ func (handler PipelineConfigRestHandlerImpl) EnvConfigOverrideCreate(w http.Resp EnvId: environmentId, ClusterId: envConfigProperties.ClusterId, } - validate, err2 := handler.chartService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, chartRefId, scope) + validate, err2 := handler.deploymentTemplateValidationService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, chartRefId, scope) if !validate { handler.Logger.Errorw("validation err, UpdateAppOverride", "err", err2, "payload", envConfigProperties) common.WriteJsonResp(w, err2, nil, http.StatusBadRequest) @@ -823,7 +823,7 @@ func (handler PipelineConfigRestHandlerImpl) EnvConfigOverrideUpdate(w http.Resp EnvId: envId, ClusterId: envConfigProperties.ClusterId, } - validate, err2 := handler.chartService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, chartRefId, scope) + validate, err2 := handler.deploymentTemplateValidationService.DeploymentTemplateValidate(r.Context(), envConfigProperties.EnvOverrideValues, chartRefId, scope) if !validate { handler.Logger.Errorw("validation err, UpdateAppOverride", "err", err2, "payload", envConfigProperties) common.WriteJsonResp(w, err2, nil, http.StatusBadRequest) @@ -1418,7 +1418,7 @@ func (handler PipelineConfigRestHandlerImpl) UpdateAppOverride(w http.ResponseWr AppId: templateRequest.AppId, } _, span = otel.Tracer("orchestrator").Start(ctx, "chartService.DeploymentTemplateValidate") - validate, err2 := handler.chartService.DeploymentTemplateValidate(ctx, templateRequest.ValuesOverride, chartRefId, scope) + validate, err2 := handler.deploymentTemplateValidationService.DeploymentTemplateValidate(ctx, templateRequest.ValuesOverride, chartRefId, scope) span.End() if !validate { handler.Logger.Errorw("validation err, UpdateAppOverride", "err", err2, "payload", templateRequest) diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/PipelineConfigRestHandler.go index d58c9464d5..6a1aefe620 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/PipelineConfigRestHandler.go @@ -23,6 +23,7 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "io" "net/http" @@ -102,41 +103,43 @@ type PipelineConfigRestHandler interface { } type PipelineConfigRestHandlerImpl struct { - pipelineBuilder pipeline.PipelineBuilder - ciPipelineRepository pipelineConfig.CiPipelineRepository - ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository - ciHandler pipeline.CiHandler - Logger *zap.SugaredLogger - chartService chart.ChartService - propertiesConfigService pipeline.PropertiesConfigService - dbMigrationService pipeline.DbMigrationService - userAuthService user.UserService - validator *validator.Validate - teamService team.TeamService - enforcer casbin.Enforcer - gitSensorClient gitSensor.Client - pipelineRepository pipelineConfig.PipelineRepository - appWorkflowService appWorkflow.AppWorkflowService - enforcerUtil rbac.EnforcerUtil - envService request.EnvironmentService - gitRegistryConfig pipeline.GitRegistryConfig - dockerRegistryConfig pipeline.DockerRegistryConfig - cdHandler pipeline.CdHandler - appCloneService appClone.AppCloneService - materialRepository pipelineConfig.MaterialRepository - policyService security2.PolicyService - scanResultRepository security.ImageScanResultRepository - gitProviderRepo repository.GitProviderRepository - argoUserService argo.ArgoUserService - imageTaggingService pipeline.ImageTaggingService - deploymentTemplateService generateManifest.DeploymentTemplateService - pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig - ciArtifactRepository repository.CiArtifactRepository - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService - chartRefService chartRef.ChartRefService + pipelineBuilder pipeline.PipelineBuilder + ciPipelineRepository pipelineConfig.CiPipelineRepository + ciPipelineMaterialRepository pipelineConfig.CiPipelineMaterialRepository + ciHandler pipeline.CiHandler + Logger *zap.SugaredLogger + deploymentTemplateValidationService deploymentTemplate.DeploymentTemplateValidationService + chartService chart.ChartService + propertiesConfigService pipeline.PropertiesConfigService + dbMigrationService pipeline.DbMigrationService + userAuthService user.UserService + validator *validator.Validate + teamService team.TeamService + enforcer casbin.Enforcer + gitSensorClient gitSensor.Client + pipelineRepository pipelineConfig.PipelineRepository + appWorkflowService appWorkflow.AppWorkflowService + enforcerUtil rbac.EnforcerUtil + envService request.EnvironmentService + gitRegistryConfig pipeline.GitRegistryConfig + dockerRegistryConfig pipeline.DockerRegistryConfig + cdHandler pipeline.CdHandler + appCloneService appClone.AppCloneService + materialRepository pipelineConfig.MaterialRepository + policyService security2.PolicyService + scanResultRepository security.ImageScanResultRepository + gitProviderRepo repository.GitProviderRepository + argoUserService argo.ArgoUserService + imageTaggingService pipeline.ImageTaggingService + deploymentTemplateService generateManifest.DeploymentTemplateService + pipelineRestHandlerEnvConfig *PipelineRestHandlerEnvConfig + ciArtifactRepository repository.CiArtifactRepository + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService } func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger *zap.SugaredLogger, + deploymentTemplateValidationService deploymentTemplate.DeploymentTemplateValidationService, chartService chart.ChartService, propertiesConfigService pipeline.PropertiesConfigService, dbMigrationService pipeline.DbMigrationService, @@ -166,38 +169,39 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger Logger.Errorw("error in parsing PipelineRestHandlerEnvConfig", "err", err) } return &PipelineConfigRestHandlerImpl{ - pipelineBuilder: pipelineBuilder, - Logger: Logger, - chartService: chartService, - propertiesConfigService: propertiesConfigService, - dbMigrationService: dbMigrationService, - userAuthService: userAuthService, - validator: validator, - teamService: teamService, - enforcer: enforcer, - ciHandler: ciHandler, - gitSensorClient: gitSensorClient, - ciPipelineRepository: ciPipelineRepository, - pipelineRepository: pipelineRepository, - enforcerUtil: enforcerUtil, - envService: envService, - gitRegistryConfig: gitRegistryConfig, - dockerRegistryConfig: dockerRegistryConfig, - cdHandler: cdHandler, - appCloneService: appCloneService, - appWorkflowService: appWorkflowService, - materialRepository: materialRepository, - policyService: policyService, - scanResultRepository: scanResultRepository, - gitProviderRepo: gitProviderRepo, - argoUserService: argoUserService, - ciPipelineMaterialRepository: ciPipelineMaterialRepository, - imageTaggingService: imageTaggingService, - deploymentTemplateService: deploymentTemplateService, - pipelineRestHandlerEnvConfig: envConfig, - ciArtifactRepository: ciArtifactRepository, - deployedAppMetricsService: deployedAppMetricsService, - chartRefService: chartRefService, + pipelineBuilder: pipelineBuilder, + Logger: Logger, + deploymentTemplateValidationService: deploymentTemplateValidationService, + chartService: chartService, + propertiesConfigService: propertiesConfigService, + dbMigrationService: dbMigrationService, + userAuthService: userAuthService, + validator: validator, + teamService: teamService, + enforcer: enforcer, + ciHandler: ciHandler, + gitSensorClient: gitSensorClient, + ciPipelineRepository: ciPipelineRepository, + pipelineRepository: pipelineRepository, + enforcerUtil: enforcerUtil, + envService: envService, + gitRegistryConfig: gitRegistryConfig, + dockerRegistryConfig: dockerRegistryConfig, + cdHandler: cdHandler, + appCloneService: appCloneService, + appWorkflowService: appWorkflowService, + materialRepository: materialRepository, + policyService: policyService, + scanResultRepository: scanResultRepository, + gitProviderRepo: gitProviderRepo, + argoUserService: argoUserService, + ciPipelineMaterialRepository: ciPipelineMaterialRepository, + imageTaggingService: imageTaggingService, + deploymentTemplateService: deploymentTemplateService, + pipelineRestHandlerEnvConfig: envConfig, + ciArtifactRepository: ciArtifactRepository, + deployedAppMetricsService: deployedAppMetricsService, + chartRefService: chartRefService, } } diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 3e32659efb..f1dcf6c1dd 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -26,9 +26,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" bean2 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" - "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" - "github.com/devtron-labs/devtron/pkg/variables/parsers" repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" "go.opentelemetry.io/otel" @@ -49,10 +47,8 @@ import ( "github.com/devtron-labs/devtron/internal/util" repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" - util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "github.com/juju/errors" - "github.com/xeipuuv/gojsonschema" "go.uber.org/zap" "k8s.io/helm/pkg/proto/hapi/chart" "sigs.k8s.io/yaml" @@ -67,7 +63,6 @@ type ChartService interface { IsReadyToTrigger(appId int, envId int, pipelineId int) (IsReady, error) FindPreviousChartByAppId(appId int) (chartTemplate *TemplateRequest, err error) UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) - DeploymentTemplateValidate(ctx context.Context, templatejson interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) @@ -859,88 +854,6 @@ func (impl ChartServiceImpl) UpgradeForApp(appId int, chartRefId int, newAppOver return true, nil } -const memoryPattern = `"1000Mi" or "1Gi"` -const cpuPattern = `"50m" or "0.05"` -const cpu = "cpu" -const memory = "memory" - -func (impl ChartServiceImpl) DeploymentTemplateValidate(ctx context.Context, template interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) { - _, span := otel.Tracer("orchestrator").Start(ctx, "JsonSchemaExtractFromFile") - schemajson, version, err := impl.chartRefService.JsonSchemaExtractFromFile(chartRefId) - span.End() - if err != nil { - impl.logger.Errorw("Json Schema not found err, FindJsonSchema", "err", err) - return true, nil - } - //if err != nil && chartRefId >= 9 { - // impl.logger.Errorw("Json Schema not found err, FindJsonSchema", "err", err) - // return false, err - //} else if err != nil { - // impl.logger.Errorw("Json Schema not found err, FindJsonSchema", "err", err) - // return true, nil - //} - - templateBytes := template.(json.RawMessage) - templatejsonstring, _, err := impl.scopedVariableManager.ExtractVariablesAndResolveTemplate(scope, string(templateBytes), parsers.JsonVariableTemplate, true, false) - if err != nil { - return false, err - } - var templatejson interface{} - err = json.Unmarshal([]byte(templatejsonstring), &templatejson) - if err != nil { - fmt.Println("Error:", err) - return false, err - } - - schemaLoader := gojsonschema.NewGoLoader(schemajson) - documentLoader := gojsonschema.NewGoLoader(templatejson) - marshalTemplatejson, err := json.Marshal(templatejson) - if err != nil { - impl.logger.Errorw("json template marshal err, DeploymentTemplateValidate", "err", err) - return false, err - } - _, span = otel.Tracer("orchestrator").Start(ctx, "gojsonschema.Validate") - result, err := gojsonschema.Validate(schemaLoader, documentLoader) - span.End() - if err != nil { - impl.logger.Errorw("result validate err, DeploymentTemplateValidate", "err", err) - return false, err - } - if result.Valid() { - var dat map[string]interface{} - if err := json.Unmarshal(marshalTemplatejson, &dat); err != nil { - impl.logger.Errorw("json template unmarshal err, DeploymentTemplateValidate", "err", err) - return false, err - } - - _, err := util2.CompareLimitsRequests(dat, version) - if err != nil { - impl.logger.Errorw("LimitRequestCompare err, DeploymentTemplateValidate", "err", err) - return false, err - } - _, err = util2.AutoScale(dat) - if err != nil { - impl.logger.Errorw("LimitRequestCompare err, DeploymentTemplateValidate", "err", err) - return false, err - } - - return true, nil - } else { - var stringerror string - for _, err := range result.Errors() { - impl.logger.Errorw("result err, DeploymentTemplateValidate", "err", err.Details()) - if err.Details()["format"] == cpu { - stringerror = stringerror + err.Field() + ": Format should be like " + cpuPattern + "\n" - } else if err.Details()["format"] == memory { - stringerror = stringerror + err.Field() + ": Format should be like " + memoryPattern + "\n" - } else { - stringerror = stringerror + err.String() + "\n" - } - } - return false, errors.New(stringerror) - } -} - func (impl ChartServiceImpl) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) { chartInfo, err := impl.chartRepository.FindLatestChartForAppByAppId(id) if err != nil { diff --git a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go index 6c851bc518..25023f1671 100644 --- a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go +++ b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go @@ -1,16 +1,105 @@ package deploymentTemplate -import "go.uber.org/zap" +import ( + "context" + "encoding/json" + "errors" + "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/bean" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + "github.com/devtron-labs/devtron/pkg/resourceQualifiers" + "github.com/devtron-labs/devtron/pkg/variables" + "github.com/devtron-labs/devtron/pkg/variables/parsers" + util2 "github.com/devtron-labs/devtron/util" + "github.com/xeipuuv/gojsonschema" + "go.opentelemetry.io/otel" + "go.uber.org/zap" +) type DeploymentTemplateValidationService interface { + DeploymentTemplateValidate(ctx context.Context, template interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) } type DeploymentTemplateValidationServiceImpl struct { - logger *zap.SugaredLogger + logger *zap.SugaredLogger + chartRefService chartRef.ChartRefService + scopedVariableManager variables.ScopedVariableManager } -func NewDeploymentTemplateValidationServiceImpl(logger *zap.SugaredLogger) *DeploymentTemplateValidationServiceImpl { +func NewDeploymentTemplateValidationServiceImpl(logger *zap.SugaredLogger, + chartRefService chartRef.ChartRefService, + scopedVariableManager variables.ScopedVariableManager) *DeploymentTemplateValidationServiceImpl { return &DeploymentTemplateValidationServiceImpl{ - logger: logger, + logger: logger, + chartRefService: chartRefService, + scopedVariableManager: scopedVariableManager, + } +} + +func (impl *DeploymentTemplateValidationServiceImpl) DeploymentTemplateValidate(ctx context.Context, template interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) { + _, span := otel.Tracer("orchestrator").Start(ctx, "JsonSchemaExtractFromFile") + schemajson, version, err := impl.chartRefService.JsonSchemaExtractFromFile(chartRefId) + span.End() + if err != nil { + impl.logger.Errorw("Json Schema not found err, FindJsonSchema", "err", err) + return true, nil + } + + templateBytes := template.(json.RawMessage) + templatejsonstring, _, err := impl.scopedVariableManager.ExtractVariablesAndResolveTemplate(scope, string(templateBytes), parsers.JsonVariableTemplate, true, false) + if err != nil { + return false, err + } + var templatejson interface{} + err = json.Unmarshal([]byte(templatejsonstring), &templatejson) + if err != nil { + fmt.Println("Error:", err) + return false, err + } + + schemaLoader := gojsonschema.NewGoLoader(schemajson) + documentLoader := gojsonschema.NewGoLoader(templatejson) + marshalTemplatejson, err := json.Marshal(templatejson) + if err != nil { + impl.logger.Errorw("json template marshal err, DeploymentTemplateValidate", "err", err) + return false, err + } + _, span = otel.Tracer("orchestrator").Start(ctx, "gojsonschema.Validate") + result, err := gojsonschema.Validate(schemaLoader, documentLoader) + span.End() + if err != nil { + impl.logger.Errorw("result validate err, DeploymentTemplateValidate", "err", err) + return false, err + } + if result.Valid() { + var dat map[string]interface{} + if err := json.Unmarshal(marshalTemplatejson, &dat); err != nil { + impl.logger.Errorw("json template unmarshal err, DeploymentTemplateValidate", "err", err) + return false, err + } + _, err := util2.CompareLimitsRequests(dat, version) + if err != nil { + impl.logger.Errorw("LimitRequestCompare err, DeploymentTemplateValidate", "err", err) + return false, err + } + _, err = util2.AutoScale(dat) + if err != nil { + impl.logger.Errorw("LimitRequestCompare err, DeploymentTemplateValidate", "err", err) + return false, err + } + return true, nil + } else { + var stringerror string + for _, err := range result.Errors() { + impl.logger.Errorw("result err, DeploymentTemplateValidate", "err", err.Details()) + if err.Details()["format"] == bean.Cpu { + stringerror = stringerror + err.Field() + ": Format should be like " + bean.CpuPattern + "\n" + } else if err.Details()["format"] == bean.Memory { + stringerror = stringerror + err.Field() + ": Format should be like " + bean.MemoryPattern + "\n" + } else { + stringerror = stringerror + err.String() + "\n" + } + } + return false, errors.New(stringerror) } } diff --git a/pkg/deployment/manifest/wire_deployment_manifest.go b/pkg/deployment/manifest/wire_deployment_manifest.go index fe6d1a6e61..d1d9613d40 100644 --- a/pkg/deployment/manifest/wire_deployment_manifest.go +++ b/pkg/deployment/manifest/wire_deployment_manifest.go @@ -12,6 +12,8 @@ var DeploymentManifestWireSet = wire.NewSet( wire.Bind(new(deployedAppMetrics.DeployedAppMetricsService), new(*deployedAppMetrics.DeployedAppMetricsServiceImpl)), deploymentTemplate.NewDeploymentTemplateServiceImpl, wire.Bind(new(deploymentTemplate.DeploymentTemplateService), new(*deploymentTemplate.DeploymentTemplateServiceImpl)), + deploymentTemplate.NewDeploymentTemplateValidationServiceImpl, + wire.Bind(new(deploymentTemplate.DeploymentTemplateValidationService), new(*deploymentTemplate.DeploymentTemplateValidationServiceImpl)), chartRef.NewChartRefServiceImpl, wire.Bind(new(chartRef.ChartRefService), new(*chartRef.ChartRefServiceImpl)), ) diff --git a/wire_gen.go b/wire_gen.go index 5e774bbe7a..712f28e051 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -102,6 +102,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" @@ -494,6 +495,7 @@ func InitializeApp() (*App, error) { appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, chartTemplateServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl) devtronAppConfigServiceImpl := pipeline.NewDevtronAppConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, appRepositoryImpl, pipelineRepositoryImpl, resourceGroupServiceImpl, enforcerUtilImpl, ciMaterialConfigServiceImpl) pipelineBuilderImpl := pipeline.NewPipelineBuilderImpl(sugaredLogger, materialRepositoryImpl, chartRepositoryImpl, ciPipelineConfigServiceImpl, ciMaterialConfigServiceImpl, appArtifactManagerImpl, devtronAppCMCSServiceImpl, devtronAppStrategyServiceImpl, appDeploymentTypeChangeManagerImpl, cdPipelineConfigServiceImpl, devtronAppConfigServiceImpl) + deploymentTemplateValidationServiceImpl := deploymentTemplate.NewDeploymentTemplateValidationServiceImpl(sugaredLogger, chartRefServiceImpl, scopedVariableManagerImpl) chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) dbMigrationServiceImpl := pipeline.NewDbMogrationService(sugaredLogger, dbMigrationConfigRepositoryImpl) ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) @@ -516,7 +518,7 @@ func InitializeApp() (*App, error) { imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciCdConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl) - pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) + pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, deploymentTemplateValidationServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, dbMigrationServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) appWorkflowRestHandlerImpl := restHandler.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) webhookEventDataRepositoryImpl := repository.NewWebhookEventDataRepositoryImpl(db) webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) From 20562f21809e7574399fc8a83303e8dd3800c3a1 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 18:44:48 +0530 Subject: [PATCH 16/83] wip --- api/restHandler/CoreAppRestHandler.go | 4 +--- .../app/DeploymentPipelineRestHandler.go | 2 +- pkg/chart/ChartService.go | 21 ------------------ .../DeploymentTemplateValidationService.go | 22 +++++++++++++++++++ .../deploymentTemplate/adapter/adapter.go | 1 + .../manifest/deploymentTemplate/bean/bean.go | 11 ++++++++++ 6 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 pkg/deployment/manifest/deploymentTemplate/adapter/adapter.go create mode 100644 pkg/deployment/manifest/deploymentTemplate/bean/bean.go diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 5a0ccf43f4..3264af0409 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -93,7 +93,6 @@ type CoreAppRestHandlerImpl struct { appWorkflowRepository appWorkflow2.AppWorkflowRepository environmentRepository repository2.EnvironmentRepository configMapRepository chartConfig.ConfigMapRepository - envConfigRepo chartConfig.EnvConfigOverrideRepository chartRepo chartRepoRepository.ChartRepository teamService team.TeamService argoUserService argo.ArgoUserService @@ -107,7 +106,7 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U propertiesConfigService pipeline.PropertiesConfigService, appWorkflowService appWorkflow.AppWorkflowService, materialRepository pipelineConfig.MaterialRepository, gitProviderRepo repository.GitProviderRepository, appWorkflowRepository appWorkflow2.AppWorkflowRepository, environmentRepository repository2.EnvironmentRepository, configMapRepository chartConfig.ConfigMapRepository, - envConfigRepo chartConfig.EnvConfigOverrideRepository, chartRepo chartRepoRepository.ChartRepository, teamService team.TeamService, + chartRepo chartRepoRepository.ChartRepository, teamService team.TeamService, argoUserService argo.ArgoUserService, pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository) *CoreAppRestHandlerImpl { handler := &CoreAppRestHandlerImpl{ logger: logger, @@ -128,7 +127,6 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U appWorkflowRepository: appWorkflowRepository, environmentRepository: environmentRepository, configMapRepository: configMapRepository, - envConfigRepo: envConfigRepo, chartRepo: chartRepo, teamService: teamService, argoUserService: argoUserService, diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/DeploymentPipelineRestHandler.go index 61776a94e8..c887889a61 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/DeploymentPipelineRestHandler.go @@ -555,7 +555,7 @@ func (handler PipelineConfigRestHandlerImpl) ChangeChartRef(w http.ResponseWrite } if newChartType == bean4.RolloutChartType { - enabled, err := handler.chartService.FlaggerCanaryEnabled(envConfigProperties.EnvOverrideValues) + enabled, err := handler.deploymentTemplateValidationService.FlaggerCanaryEnabled(envConfigProperties.EnvOverrideValues) if err != nil || enabled { handler.Logger.Errorw("rollout charts do not support flaggerCanary, ChangeChartRef", "err", err, "payload", request) common.WriteJsonResp(w, err, "rollout charts do not support flaggerCanary, ChangeChartRef", http.StatusBadRequest) diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index f1dcf6c1dd..d6acd1c587 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -65,7 +65,6 @@ type ChartService interface { UpgradeForApp(appId int, chartRefId int, newAppOverride map[string]interface{}, userId int32, ctx context.Context) (bool, error) CheckIfChartRefUserUploadedByAppId(id int) (bool, error) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) - FlaggerCanaryEnabled(values json.RawMessage) (bool, error) ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*bean2.ChartRefAutocompleteResponse, error) } @@ -116,26 +115,6 @@ func NewChartServiceImpl(chartRepository chartRepoRepository.ChartRepository, } } -func (impl ChartServiceImpl) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) { - var jsonMap map[string]json.RawMessage - if err := json.Unmarshal([]byte(values), &jsonMap); err != nil { - return false, err - } - - flaggerCanary, found := jsonMap["flaggerCanary"] - if !found { - return false, nil - } - var flaggerCanaryUnmarshalled map[string]json.RawMessage - if err := json.Unmarshal([]byte(flaggerCanary), &flaggerCanaryUnmarshalled); err != nil { - return false, err - } - enabled, found := flaggerCanaryUnmarshalled["enabled"] - if !found { - return true, fmt.Errorf("flagger canary enabled field must be set and be equal to false") - } - return string(enabled) == "true", nil -} func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) { return PatchWinterSoldierConfig(values, newChartType) } diff --git a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go index 25023f1671..8c0bf25b06 100644 --- a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go +++ b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateValidationService.go @@ -18,6 +18,7 @@ import ( type DeploymentTemplateValidationService interface { DeploymentTemplateValidate(ctx context.Context, template interface{}, chartRefId int, scope resourceQualifiers.Scope) (bool, error) + FlaggerCanaryEnabled(values json.RawMessage) (bool, error) } type DeploymentTemplateValidationServiceImpl struct { @@ -103,3 +104,24 @@ func (impl *DeploymentTemplateValidationServiceImpl) DeploymentTemplateValidate( return false, errors.New(stringerror) } } + +func (impl *DeploymentTemplateValidationServiceImpl) FlaggerCanaryEnabled(values json.RawMessage) (bool, error) { + var jsonMap map[string]json.RawMessage + if err := json.Unmarshal(values, &jsonMap); err != nil { + return false, err + } + + flaggerCanary, found := jsonMap[bean.FlaggerCanary] + if !found { + return false, nil + } + var flaggerCanaryUnmarshalled map[string]json.RawMessage + if err := json.Unmarshal(flaggerCanary, &flaggerCanaryUnmarshalled); err != nil { + return false, err + } + enabled, found := flaggerCanaryUnmarshalled[bean.EnabledFlag] + if !found { + return true, fmt.Errorf("flagger canary enabled field must be set and be equal to false") + } + return string(enabled) == bean.TrueFlag, nil +} diff --git a/pkg/deployment/manifest/deploymentTemplate/adapter/adapter.go b/pkg/deployment/manifest/deploymentTemplate/adapter/adapter.go new file mode 100644 index 0000000000..b8e8da3083 --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/adapter/adapter.go @@ -0,0 +1 @@ +package adapter diff --git a/pkg/deployment/manifest/deploymentTemplate/bean/bean.go b/pkg/deployment/manifest/deploymentTemplate/bean/bean.go new file mode 100644 index 0000000000..78671118fc --- /dev/null +++ b/pkg/deployment/manifest/deploymentTemplate/bean/bean.go @@ -0,0 +1,11 @@ +package bean + +const ( + MemoryPattern = `"1000Mi" or "1Gi"` + CpuPattern = `"50m" or "0.05"` + Cpu = "cpu" + Memory = "memory" + FlaggerCanary = "flaggerCanary" + EnabledFlag = "enabled" + TrueFlag = "true" +) From 75b99abca19ad0a3ad3361ce80e9334213ad6df7 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 18:45:43 +0530 Subject: [PATCH 17/83] removed redundant appMetrics req obj --- pkg/chart/bean.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/chart/bean.go b/pkg/chart/bean.go index c3dce0a3b1..eb9599d922 100644 --- a/pkg/chart/bean.go +++ b/pkg/chart/bean.go @@ -35,13 +35,6 @@ type TemplateRequest struct { UserId int32 `json:"-"` } -type AppMetricEnableDisableRequest struct { - AppId int `json:"appId,omitempty"` - EnvironmentId int `json:"environmentId,omitempty"` - IsAppMetricsEnabled bool `json:"isAppMetricsEnabled"` - UserId int32 `json:"-"` -} - type ChartUpgradeRequest struct { ChartRefId int `json:"chartRefId" validate:"number"` All bool `json:"all"` From 11f76ff7d45cf2cbfa93a67368988311346802e3 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 19:03:26 +0530 Subject: [PATCH 18/83] moved app metrics bindings to wireset --- Wire.go | 6 ------ pkg/deployment/manifest/wire_deployment_manifest.go | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Wire.go b/Wire.go index 79e4c8a53a..0dc8fefc60 100644 --- a/Wire.go +++ b/Wire.go @@ -97,7 +97,6 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/manifest" - repository11 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -552,11 +551,6 @@ func InitializeApp() (*App, error) { restHandler.NewExternalCiRestHandlerImpl, wire.Bind(new(restHandler.ExternalCiRestHandler), new(*restHandler.ExternalCiRestHandlerImpl)), - repository11.NewAppLevelMetricsRepositoryImpl, - wire.Bind(new(repository11.AppLevelMetricsRepository), new(*repository11.AppLevelMetricsRepositoryImpl)), - - repository11.NewEnvLevelAppMetricsRepositoryImpl, - wire.Bind(new(repository11.EnvLevelAppMetricsRepository), new(*repository11.EnvLevelAppMetricsRepositoryImpl)), grafana.GetGrafanaClientConfig, grafana.NewGrafanaClientImpl, diff --git a/pkg/deployment/manifest/wire_deployment_manifest.go b/pkg/deployment/manifest/wire_deployment_manifest.go index fe6d1a6e61..497771f975 100644 --- a/pkg/deployment/manifest/wire_deployment_manifest.go +++ b/pkg/deployment/manifest/wire_deployment_manifest.go @@ -2,12 +2,18 @@ package manifest import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/google/wire" ) var DeploymentManifestWireSet = wire.NewSet( + repository.NewAppLevelMetricsRepositoryImpl, + wire.Bind(new(repository.AppLevelMetricsRepository), new(*repository.AppLevelMetricsRepositoryImpl)), + repository.NewEnvLevelAppMetricsRepositoryImpl, + wire.Bind(new(repository.EnvLevelAppMetricsRepository), new(*repository.EnvLevelAppMetricsRepositoryImpl)), + deployedAppMetrics.NewDeployedAppMetricsServiceImpl, wire.Bind(new(deployedAppMetrics.DeployedAppMetricsService), new(*deployedAppMetrics.DeployedAppMetricsServiceImpl)), deploymentTemplate.NewDeploymentTemplateServiceImpl, From b59cb1cf8daa7dfb0b042798b6bfb1003c5eab09 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 19:15:48 +0530 Subject: [PATCH 19/83] removed multiple dead code --- api/restHandler/BatchOperationRestHandler.go | 12 ------- api/restHandler/CoreAppRestHandler.go | 14 -------- .../app/PipelineConfigRestHandler.go | 29 ----------------- api/restHandler/common/apiError.go | 32 ------------------- .../sql/repository/AppListingRepository.go | 25 --------------- pkg/chart/ChartService.go | 25 --------------- pkg/pipeline/PropertiesConfig.go | 13 -------- 7 files changed, 150 deletions(-) diff --git a/api/restHandler/BatchOperationRestHandler.go b/api/restHandler/BatchOperationRestHandler.go index d89bafbd55..1c1178568a 100644 --- a/api/restHandler/BatchOperationRestHandler.go +++ b/api/restHandler/BatchOperationRestHandler.go @@ -145,15 +145,3 @@ func validatePipeline(pipeline *v1.Pipeline, props v1.InheritedProps) error { } return nil } - -func executePipeline(pipeline *v1.Pipeline, props v1.InheritedProps) error { - if pipeline.Build == nil && pipeline.Deployment == nil { - return nil - } else if pipeline.Build != nil { - pipeline.Build.UpdateMissingProps(props) - return validation.ValidateBuild(pipeline.Build) - } else if pipeline.Deployment != nil { - //return batch.ExecuteDeployment(pipeline.Deployment, props) - } - return nil -} diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 3264af0409..b8098c2f3d 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -2086,20 +2086,6 @@ func convertCdDeploymentStrategies(deploymentStrategies []*appBean.DeploymentStr return convertedStrategies, nil } -func ExtractErrorType(err error) int { - switch err.(type) { - case *util2.InternalServerError: - return http.StatusInternalServerError - case *util2.ForbiddenError: - return http.StatusForbidden - case *util2.BadRequestError: - return http.StatusBadRequest - default: - //TODO : ask and update response for this case - return 0 - } -} - func (handler CoreAppRestHandlerImpl) validateCdPipelines(cdPipelines []*appBean.CdPipelineDetails, appName, token string) (error, int) { for _, cdPipeline := range cdPipelines { envName := cdPipeline.EnvironmentName diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/PipelineConfigRestHandler.go index 6a1aefe620..5de61b9131 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/PipelineConfigRestHandler.go @@ -44,7 +44,6 @@ import ( "github.com/go-pg/pg" "go.opentelemetry.io/otel" - bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/security" @@ -59,10 +58,7 @@ import ( util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" "github.com/gorilla/mux" - "github.com/grpc-ecosystem/grpc-gateway/runtime" "go.uber.org/zap" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" "gopkg.in/go-playground/validator.v9" ) @@ -573,31 +569,6 @@ func (handler *PipelineConfigRestHandlerImpl) sendData(event []byte, w http.Resp } } -func (handler *PipelineConfigRestHandlerImpl) handleForwardResponseStreamError(wroteHeader bool, w http.ResponseWriter, err error) { - code := "000" - if !wroteHeader { - s, ok := status.FromError(err) - if !ok { - s = status.New(codes.Unknown, err.Error()) - } - w.WriteHeader(runtime.HTTPStatusFromCode(s.Code())) - code = fmt.Sprint(s.Code()) - } - response := bean2.Response{} - apiErr := bean2.ApiError{} - apiErr.Code = code // 000=unknown - apiErr.InternalMessage = err.Error() - response.Errors = []bean2.ApiError{apiErr} - buf, err2 := json.Marshal(response) - if err2 != nil { - handler.Logger.Errorw("marshal err, handleForwardResponseStreamError", "err", err2, "response", response) - } - if _, err3 := w.Write(buf); err3 != nil { - handler.Logger.Errorw("Failed to notify error to client, handleForwardResponseStreamError", "err", err3, "response", response) - return - } -} - func (handler PipelineConfigRestHandlerImpl) FetchAppWorkflowStatusForTriggerView(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { diff --git a/api/restHandler/common/apiError.go b/api/restHandler/common/apiError.go index 8d4c29689d..b95074876b 100644 --- a/api/restHandler/common/apiError.go +++ b/api/restHandler/common/apiError.go @@ -126,29 +126,6 @@ func WriteJsonResp(w http.ResponseWriter, err error, respBody interface{}, statu } -// use this method when we have specific api error to be conveyed to api User -func writeJsonRespStructured(w http.ResponseWriter, err error, respBody interface{}, status int, apiErrors []*util.ApiError) { - response := Response{} - response.Code = status - response.Status = http.StatusText(status) - if err == nil { - response.Result = respBody - } else { - response.Errors = apiErrors - } - b, err := json.Marshal(response) - if err != nil { - util.GetLogger().Error("error in marshaling err object", err) - status = 500 - } - w.Header().Set(CONTENT_TYPE, APPLICATION_JSON) - w.WriteHeader(status) - _, err = w.Write(b) - if err != nil { - util.GetLogger().Error(err) - } -} - // global response body used across api type Response struct { Code int `json:"code,omitempty"` @@ -156,12 +133,3 @@ type Response struct { Result interface{} `json:"result,omitempty"` Errors []*util.ApiError `json:"errors,omitempty"` } - -func contains(s []*string, e *string) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index c5e2583b53..150ecfd37a 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -181,18 +181,6 @@ func (impl AppListingRepositoryImpl) FetchJobsLastSucceededOn(CiPipelineIDs []in return lastSucceededTimeArray, nil } -func getRequiredAppIdsInSequence(appIds []int) []int { - resIDs := make([]int, 0) - appIdsSet := make(map[int]bool) - for _, appId := range appIds { - if _, ok := appIdsSet[appId]; !ok { - resIDs = append(resIDs, appId) - appIdsSet[appId] = true - } - } - return resIDs -} - func (impl AppListingRepositoryImpl) FetchAppsByEnvironment(appListingFilter helper.AppListingFilter) ([]*bean.AppEnvironmentContainer, error) { impl.Logger.Debug("reached at FetchAppsByEnvironment:") var appEnvArr []*bean.AppEnvironmentContainer @@ -492,19 +480,6 @@ func (impl AppListingRepositoryImpl) FetchAppDetail(ctx context.Context, appId i return appDetailContainer, nil } -func (impl AppListingRepositoryImpl) fetchLinkOutsByAppIdAndEnvId(appId int, envId int) ([]string, error) { - impl.Logger.Debug("reached at AppListingRepository:") - - var linkOuts []string - query := "SELECT ael.link from app_env_linkouts ael where ael.app_id=? and ael.environment_id=?" - impl.Logger.Debugw("lingOut query:", query) - _, err := impl.dbConnection.Query(&linkOuts, query, appId, envId) - if err != nil { - impl.Logger.Errorw("err", err) - } - return linkOuts, err -} - func (impl AppListingRepositoryImpl) PrometheusApiByEnvId(id int) (*string, error) { impl.Logger.Debug("reached at PrometheusApiByEnvId:") var prometheusEndpoint string diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 1853c45bb0..9939447811 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -119,10 +119,6 @@ func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartT return PatchWinterSoldierConfig(values, newChartType) } -type AppMetricsEnabled struct { - AppMetrics bool `json:"app-metrics"` -} - func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context.Context) (*TemplateRequest, error) { err := impl.chartRefService.CheckChartExists(templateRequest.ChartRefId) if err != nil { @@ -433,27 +429,6 @@ func (impl ChartServiceImpl) getChartMetaData(templateRequest TemplateRequest) ( return metadata, err } -func (impl ChartServiceImpl) getRefChartVersion(templateRequest TemplateRequest) (string, error) { - var version string - if templateRequest.ChartRefId > 0 { - chartRefDto, err := impl.chartRefService.FindById(templateRequest.ChartRefId) - if err != nil { - chartRefDto, err = impl.chartRefService.GetDefault() - if err != nil { - return "", err - } - } - version = chartRefDto.Version - } else { - chartRefDto, err := impl.chartRefService.GetDefault() - if err != nil { - return "", err - } - version = chartRefDto.Location - } - return version, nil -} - func (impl ChartServiceImpl) getChartRepo(templateRequest TemplateRequest) (*chartRepoRepository.ChartRepo, error) { if templateRequest.ChartRepositoryId == 0 { chartRepo, err := impl.repoRepository.GetDefault() diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 3f997d2a6a..56cce5f16e 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -28,7 +28,6 @@ import ( repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" "time" - chartService "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -331,18 +330,6 @@ func (impl PropertiesConfigServiceImpl) UpdateEnvironmentProperties(appId int, p return propertiesRequest, err } -func (impl PropertiesConfigServiceImpl) buildAppMetricsJson() ([]byte, error) { - appMetricsEnabled := chartService.AppMetricsEnabled{ - AppMetrics: true, - } - appMetricsJson, err := json.Marshal(appMetricsEnabled) - if err != nil { - impl.logger.Error(err) - return nil, err - } - return appMetricsJson, nil -} - func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, bool, error) { env, err := impl.environmentRepository.FindById(environmentId) if err != nil { From d113b35b51d021aa2d461d8cbbd22318cc15cd0d Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 16 Jan 2024 19:34:48 +0530 Subject: [PATCH 20/83] remove redundant dependency --- pkg/gitops/GitOpsConfigService.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index fe2e70ec0f..ed3c6bd27b 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -33,7 +33,6 @@ import ( cluster3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer" cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" @@ -95,8 +94,6 @@ type GitOpsConfigServiceImpl struct { K8sUtil *util4.K8sUtil aCDAuthConfig *util3.ACDAuthConfig clusterService cluster.ClusterService - envService cluster.EnvironmentService - versionService argocdServer.VersionService gitFactory *util.GitFactory chartTemplateService util.ChartTemplateService argoUserService argo.ArgoUserService @@ -106,7 +103,7 @@ type GitOpsConfigServiceImpl struct { func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, globalEnvVariables *util2.GlobalEnvVariables, gitOpsRepository repository.GitOpsConfigRepository, K8sUtil *util4.K8sUtil, aCDAuthConfig *util3.ACDAuthConfig, - clusterService cluster.ClusterService, envService cluster.EnvironmentService, versionService argocdServer.VersionService, + clusterService cluster.ClusterService, gitFactory *util.GitFactory, chartTemplateService util.ChartTemplateService, argoUserService argo.ArgoUserService, clusterServiceCD cluster2.ServiceClient) *GitOpsConfigServiceImpl { return &GitOpsConfigServiceImpl{ randSource: rand.NewSource(time.Now().UnixNano()), @@ -116,8 +113,6 @@ func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, K8sUtil: K8sUtil, aCDAuthConfig: aCDAuthConfig, clusterService: clusterService, - envService: envService, - versionService: versionService, gitFactory: gitFactory, chartTemplateService: chartTemplateService, argoUserService: argoUserService, From ae90f366e81ecb8e3e76e7c5085c1c2dab539efe Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Wed, 17 Jan 2024 14:06:51 +0530 Subject: [PATCH 21/83] moved ChartGroup router and rest handler to respective folder --- Wire.go | 9 +++++---- .../chartGroup}/ChartGroupRestHandler.go | 2 +- .../chartGroup}/ChartGroupRouter.go | 11 +++++------ api/router/router.go | 7 ++++--- wire_gen.go | 5 +++-- 5 files changed, 18 insertions(+), 16 deletions(-) rename api/{restHandler => appStore/chartGroup}/ChartGroupRestHandler.go (99%) rename api/{router => appStore/chartGroup}/ChartGroupRouter.go (83%) diff --git a/Wire.go b/Wire.go index caeb9157b9..459471edd8 100644 --- a/Wire.go +++ b/Wire.go @@ -26,6 +26,7 @@ import ( util4 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/apiToken" appStoreRestHandler "github.com/devtron-labs/devtron/api/appStore" + chartGroup2 "github.com/devtron-labs/devtron/api/appStore/chartGroup" chartProvider "github.com/devtron-labs/devtron/api/appStore/chartProvider" appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover" @@ -591,10 +592,10 @@ func InitializeApp() (*App, error) { wire.Bind(new(repository4.ChartGroupEntriesRepository), new(*repository4.ChartGroupEntriesRepositoryImpl)), chartGroup.NewChartGroupServiceImpl, wire.Bind(new(chartGroup.ChartGroupService), new(*chartGroup.ChartGroupServiceImpl)), - restHandler.NewChartGroupRestHandlerImpl, - wire.Bind(new(restHandler.ChartGroupRestHandler), new(*restHandler.ChartGroupRestHandlerImpl)), - router.NewChartGroupRouterImpl, - wire.Bind(new(router.ChartGroupRouter), new(*router.ChartGroupRouterImpl)), + chartGroup2.NewChartGroupRestHandlerImpl, + wire.Bind(new(chartGroup2.ChartGroupRestHandler), new(*chartGroup2.ChartGroupRestHandlerImpl)), + chartGroup2.NewChartGroupRouterImpl, + wire.Bind(new(chartGroup2.ChartGroupRouter), new(*chartGroup2.ChartGroupRouterImpl)), repository4.NewChartGroupDeploymentRepositoryImpl, wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)), diff --git a/api/restHandler/ChartGroupRestHandler.go b/api/appStore/chartGroup/ChartGroupRestHandler.go similarity index 99% rename from api/restHandler/ChartGroupRestHandler.go rename to api/appStore/chartGroup/ChartGroupRestHandler.go index 0e496bea65..5fee0dab7e 100644 --- a/api/restHandler/ChartGroupRestHandler.go +++ b/api/appStore/chartGroup/ChartGroupRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package chartGroup import ( "encoding/json" diff --git a/api/router/ChartGroupRouter.go b/api/appStore/chartGroup/ChartGroupRouter.go similarity index 83% rename from api/router/ChartGroupRouter.go rename to api/appStore/chartGroup/ChartGroupRouter.go index df28fd471e..48354ce457 100644 --- a/api/router/ChartGroupRouter.go +++ b/api/appStore/chartGroup/ChartGroupRouter.go @@ -15,26 +15,25 @@ * */ -package router +package chartGroup import ( - "github.com/devtron-labs/devtron/api/restHandler" "github.com/gorilla/mux" ) type ChartGroupRouterImpl struct { - ChartGroupRestHandler restHandler.ChartGroupRestHandler + ChartGroupRestHandler ChartGroupRestHandler } type ChartGroupRouter interface { - initChartGroupRouter(helmRouter *mux.Router) + InitChartGroupRouter(helmRouter *mux.Router) } -func NewChartGroupRouterImpl(ChartGroupRestHandler restHandler.ChartGroupRestHandler) *ChartGroupRouterImpl { +func NewChartGroupRouterImpl(ChartGroupRestHandler ChartGroupRestHandler) *ChartGroupRouterImpl { return &ChartGroupRouterImpl{ChartGroupRestHandler: ChartGroupRestHandler} } -func (impl *ChartGroupRouterImpl) initChartGroupRouter(chartGroupRouter *mux.Router) { +func (impl *ChartGroupRouterImpl) InitChartGroupRouter(chartGroupRouter *mux.Router) { chartGroupRouter.Path("/"). HandlerFunc(impl.ChartGroupRestHandler.CreateChartGroup).Methods("POST") chartGroupRouter.Path("/"). diff --git a/api/router/router.go b/api/router/router.go index 558940e3f4..4742d9c060 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -22,6 +22,7 @@ import ( pubsub2 "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/api/apiToken" "github.com/devtron-labs/devtron/api/appStore" + "github.com/devtron-labs/devtron/api/appStore/chartGroup" appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" "github.com/devtron-labs/devtron/api/auth/sso" "github.com/devtron-labs/devtron/api/auth/user" @@ -81,7 +82,7 @@ type MuxRouter struct { ChartRepositoryRouter chartRepo.ChartRepositoryRouter ReleaseMetricsRouter ReleaseMetricsRouter deploymentGroupRouter DeploymentGroupRouter - chartGroupRouter ChartGroupRouter + chartGroupRouter chartGroup.ChartGroupRouter batchOperationRouter BatchOperationRouter imageScanRouter ImageScanRouter policyRouter PolicyRouter @@ -136,7 +137,7 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P ciEventHandler pubsub.CiEventHandler, pubsubClient *pubsub2.PubSubClientServiceImpl, UserRouter user.UserRouter, ChartRefRouter ChartRefRouter, ConfigMapRouter ConfigMapRouter, AppStoreRouter appStore.AppStoreRouter, chartRepositoryRouter chartRepo.ChartRepositoryRouter, ReleaseMetricsRouter ReleaseMetricsRouter, deploymentGroupRouter DeploymentGroupRouter, batchOperationRouter BatchOperationRouter, - chartGroupRouter ChartGroupRouter, imageScanRouter ImageScanRouter, + chartGroupRouter chartGroup.ChartGroupRouter, imageScanRouter ImageScanRouter, policyRouter PolicyRouter, gitOpsConfigRouter GitOpsConfigRouter, dashboardRouter dashboard.DashboardRouter, attributesRouter AttributesRouter, userAttributesRouter UserAttributesRouter, commonRouter CommonRouter, grafanaRouter GrafanaRouter, ssoLoginRouter sso.SsoLoginRouter, telemetryRouter TelemetryRouter, telemetryWatcher telemetry.TelemetryEventClient, bulkUpdateRouter BulkUpdateRouter, webhookListenerRouter WebhookListenerRouter, appRouter AppRouter, coreAppRouter CoreAppRouter, helmAppRouter client.HelmAppRouter, k8sApplicationRouter application.K8sApplicationRouter, @@ -322,7 +323,7 @@ func (r MuxRouter) Init() { r.batchOperationRouter.initBatchOperationRouter(rootRouter) chartGroupRouter := r.Router.PathPrefix("/orchestrator/chart-group").Subrouter() - r.chartGroupRouter.initChartGroupRouter(chartGroupRouter) + r.chartGroupRouter.InitChartGroupRouter(chartGroupRouter) imageScanRouter := r.Router.PathPrefix("/orchestrator/security/scan").Subrouter() r.imageScanRouter.InitImageScanRouter(imageScanRouter) diff --git a/wire_gen.go b/wire_gen.go index a0bd21ec8a..30d30896c5 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -14,6 +14,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" apiToken2 "github.com/devtron-labs/devtron/api/apiToken" "github.com/devtron-labs/devtron/api/appStore" + chartGroup2 "github.com/devtron-labs/devtron/api/appStore/chartGroup" chartProvider2 "github.com/devtron-labs/devtron/api/appStore/chartProvider" "github.com/devtron-labs/devtron/api/appStore/deployment" "github.com/devtron-labs/devtron/api/appStore/discover" @@ -671,8 +672,8 @@ func InitializeApp() (*App, error) { chartGroupEntriesRepositoryImpl := repository11.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository11.NewChartGroupReposotoryImpl(db, sugaredLogger) chartGroupServiceImpl := chartGroup.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) - chartGroupRestHandlerImpl := restHandler.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) - chartGroupRouterImpl := router.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) + chartGroupRestHandlerImpl := chartGroup2.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) + chartGroupRouterImpl := chartGroup2.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) scanToolExecutionHistoryMappingRepositoryImpl := security.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) imageScanServiceImpl := security2.NewImageScanServiceImpl(sugaredLogger, imageScanHistoryRepositoryImpl, imageScanResultRepositoryImpl, imageScanObjectMetaRepositoryImpl, cveStoreRepositoryImpl, imageScanDeployInfoRepositoryImpl, userServiceImpl, teamRepositoryImpl, appRepositoryImpl, environmentServiceImpl, ciArtifactRepositoryImpl, policyServiceImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, scanToolMetadataRepositoryImpl, scanToolExecutionHistoryMappingRepositoryImpl) imageScanRestHandlerImpl := restHandler.NewImageScanRestHandlerImpl(sugaredLogger, imageScanServiceImpl, userServiceImpl, enforcerImpl, enforcerUtilImpl, environmentServiceImpl) From f802e6104ed41067d33553c79b39905436d4dc1b Mon Sep 17 00:00:00 2001 From: nishant Date: Wed, 17 Jan 2024 14:06:53 +0530 Subject: [PATCH 22/83] stage 1 --- .../common/AppStoreDeploymentCommonService.go | 244 ++---------------- .../common/AppStoreDeploymentGitService.go | 204 +++++++++++++++ 2 files changed, 230 insertions(+), 218 deletions(-) create mode 100644 pkg/appStore/deployment/common/AppStoreDeploymentGitService.go diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 44ca59836e..48a2760256 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -29,33 +29,39 @@ import ( util2 "github.com/devtron-labs/devtron/pkg/appStore/util" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" - "github.com/google/go-github/github" - "github.com/microsoft/azure-devops-go-api/azuredevops" - dirCopy "github.com/otiai10/copy" - "github.com/xanzy/go-gitlab" "go.uber.org/zap" "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/proto/hapi/chart" - "net/http" "os" "path" "path/filepath" - "regexp" "sigs.k8s.io/yaml" ) type AppStoreDeploymentCommonService interface { + //MOve to DB service GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) + //move to db service GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) + //move to gitops service ParseGitRepoErrorResponse(err error) (bool, error) + //keep here only GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) + // common for all gitops? CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) + //move to git service CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, bool, string, error) + //move to gitservice CommitConfigToGit(chartConfig *util.ChartConfig) (gitHash string, err error) + //keep here only GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) + //keep here only GetValuesString(chartName, valuesOverrideYaml string) (string, error) + //keep here only GetRequirementsString(appStoreVersionId int) (string, error) + //rethink GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *AppStoreManifestResponse, err error) + //gitops service GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) } @@ -208,34 +214,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) convert(chart *repository.Instal } } -func (impl AppStoreDeploymentCommonServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { - //update values yaml in chart - noTargetFound := false - if err != nil { - if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) - noTargetFound = true - } - if err.Error() == util.BITBUCKET_REPO_NOT_FOUND_ERROR { - impl.logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) - noTargetFound = true - } - } - return noTargetFound, err -} - func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, valuesOverrideYaml string) (string, error) { ValuesOverrideByte, err := yaml.YAMLToJSON([]byte(valuesOverrideYaml)) @@ -347,27 +325,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetValuesAndRequirementGitConfig return valuesConfig, RequirementConfig, nil } -// CreateChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml -func (impl AppStoreDeploymentCommonServiceImpl) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { - - ChartCreateResponse := &util.ChartCreateResponse{} - template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(string(impl.refChartDir), template) - valid, err := chartutil.IsChartDir(chartPath) - if err != nil || !valid { - impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) - return ChartCreateResponse, err - } - chartCreateRequest := ParseChartCreateRequest(installAppVersionRequest, chartPath) - chartCreateResponse, err := impl.chartTemplateService.BuildChartProxyForHelmApps(chartCreateRequest) - if err != nil { - impl.logger.Errorw("Error in building chart proxy", "err", err) - return chartCreateResponse, err - } - return chartCreateResponse, nil - -} - func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *AppStoreManifestResponse, err error) { manifestResponse = &AppStoreManifestResponse{} @@ -390,17 +347,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifest(installAppVersi return manifestResponse, nil } -//func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifestAndPerformGitOps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartGitAttribute, error) { -// -// manifestResponse, err := impl.GenerateManifest(installAppVersionRequest) -// if err != nil { -// impl.logger.Errorw("Error in generating manifest for gitops step", "err", err) -// return nil, err -// } -// impl. -// -//} - // CreateGitOpsRepo creates a gitOps repo with readme func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { @@ -438,72 +384,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi return repoUrl, isNew, err } -// PushChartToGitopsRepo pushes built chart to gitOps repo -func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, string, error) { - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") - chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(PushChartToGitRequest.RepoURL, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) - return nil, "", err - } - } else { - err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) - if err != nil { - return nil, "", err - } - } - acdAppName := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, PushChartToGitRequest.EnvName) - dir := filepath.Join(clonedDir, acdAppName) - err := os.MkdirAll(dir, os.ModePerm) - if err != nil { - impl.logger.Errorw("error in making dir", "err", err) - return nil, "", err - } - err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, "", err - } - err = impl.AddConfigFileToChart(requirementsConfig, dir, clonedDir) - if err != nil { - impl.logger.Errorw("error in adding requirements.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) - return nil, "", err - } - err = impl.AddConfigFileToChart(valuesConfig, dir, clonedDir) - if err != nil { - impl.logger.Errorw("error in adding values.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) - return nil, "", err - } - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) - commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) - return nil, "", err - } - err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, "", err - } - commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - return nil, "", err - } - } - impl.logger.Debugw("template committed", "url", PushChartToGitRequest.RepoURL, "commit", commit) - defer impl.chartTemplateService.CleanDir(clonedDir) - return &util.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err -} - // AddConfigFileToChart will override requirements.yaml file in chart func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *util.ChartConfig, dir string, clonedDir string) error { filePath := filepath.Join(clonedDir, config.FileName) @@ -527,95 +407,23 @@ func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *uti return nil } -// CreateGitOpsRepoAndPushChart is a wrapper for creating gitops repo and pushing chart to created repo -func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, bool, string, error) { - repoURL, isNew, err := impl.CreateGitOpsRepo(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) - return nil, false, "", err - } - pushChartToGitRequest := ParseChartGitPushRequest(installAppVersionRequest, repoURL, builtChartPath) - chartGitAttribute, commitHash, err := impl.PushChartToGitopsRepo(pushChartToGitRequest, requirementsConfig, valuesConfig) - if err != nil { - impl.logger.Errorw("error in pushing chart to git", "err", err) - return nil, false, "", err - } - return chartGitAttribute, isNew, commitHash, err -} +// CreateChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml +func (impl AppStoreDeploymentCommonServiceImpl) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { -// CommitConfigToGit is used for committing values.yaml and requirements.yaml file config -func (impl AppStoreDeploymentCommonServiceImpl) CommitConfigToGit(chartConfig *util.ChartConfig) (string, error) { - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return "", err - } - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} - gitHash, _, err := impl.gitFactory.Client.CommitValues(chartConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return "", err + ChartCreateResponse := &util.ChartCreateResponse{} + template := appStoreBean.CHART_PROXY_TEMPLATE + chartPath := path.Join(string(impl.refChartDir), template) + valid, err := chartutil.IsChartDir(chartPath) + if err != nil || !valid { + impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) + return ChartCreateResponse, err } - return gitHash, nil -} - -func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { - appStoreGitOpsResponse := &AppStoreGitOpsResponse{} - chartGitAttribute, isNew, githash, err := impl.CreateGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) + chartCreateRequest := ParseChartCreateRequest(installAppVersionRequest, chartPath) + chartCreateResponse, err := impl.chartTemplateService.BuildChartProxyForHelmApps(chartCreateRequest) if err != nil { - impl.logger.Errorw("Error in pushing chart to git", "err", err) - return appStoreGitOpsResponse, err - } - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(installAppVersionRequest.AppName, "-") - clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName - - // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. - // step-2 commit dependencies and values in git - if !isNew { - _, err = impl.CommitConfigToGit(manifestResponse.RequirementsConfig) - if err != nil { - impl.logger.Errorw("error in committing dependency config to git", "err", err) - return appStoreGitOpsResponse, err - } - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return appStoreGitOpsResponse, err - } - - githash, err = impl.CommitConfigToGit(manifestResponse.ValuesConfig) - if err != nil { - impl.logger.Errorw("error in committing values config to git", "err", err) - return appStoreGitOpsResponse, err - } - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return appStoreGitOpsResponse, err - } + impl.logger.Errorw("Error in building chart proxy", "err", err) + return chartCreateResponse, err } - appStoreGitOpsResponse.ChartGitAttribute = chartGitAttribute - appStoreGitOpsResponse.GitHash = githash - return appStoreGitOpsResponse, nil -} + return chartCreateResponse, nil -func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { - appStoreGitOpsResponse := &AppStoreGitOpsResponse{} - manifest, err := impl.GenerateManifest(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in performing manifest and git operations", "err", err) - return nil, err - } - gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in performing gitops operation", "err", err) - return nil, err - } - installAppVersionRequest.GitHash = gitOpsResponse.GitHash - appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute - return appStoreGitOpsResponse, nil } diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go b/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go new file mode 100644 index 0000000000..3ffb86cf9f --- /dev/null +++ b/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go @@ -0,0 +1,204 @@ +package appStoreDeploymentCommon + +import ( + "fmt" + "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/go-pg/pg" + "github.com/google/go-github/github" + "github.com/microsoft/azure-devops-go-api/azuredevops" + copy2 "github.com/otiai10/copy" + "github.com/xanzy/go-gitlab" + "net/http" + "os" + "path/filepath" + "regexp" +) + +func (impl AppStoreDeploymentCommonServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { + //update values yaml in chart + noTargetFound := false + if err != nil { + if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) + noTargetFound = true + } + if err.Error() == util.BITBUCKET_REPO_NOT_FOUND_ERROR { + impl.logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) + noTargetFound = true + } + } + return noTargetFound, err +} + +// CreateGitOpsRepoAndPushChart is a wrapper for creating gitops repo and pushing chart to created repo +func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, bool, string, error) { + repoURL, isNew, err := impl.CreateGitOpsRepo(installAppVersionRequest) + if err != nil { + impl.logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) + return nil, false, "", err + } + pushChartToGitRequest := ParseChartGitPushRequest(installAppVersionRequest, repoURL, builtChartPath) + chartGitAttribute, commitHash, err := impl.PushChartToGitopsRepo(pushChartToGitRequest, requirementsConfig, valuesConfig) + if err != nil { + impl.logger.Errorw("error in pushing chart to git", "err", err) + return nil, false, "", err + } + return chartGitAttribute, isNew, commitHash, err +} + +// CommitConfigToGit is used for committing values.yaml and requirements.yaml file config +func (impl AppStoreDeploymentCommonServiceImpl) CommitConfigToGit(chartConfig *util.ChartConfig) (string, error) { + gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + if err != nil { + if err == pg.ErrNoRows { + gitOpsConfigBitbucket.BitBucketWorkspaceId = "" + } else { + return "", err + } + } + gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} + gitHash, _, err := impl.gitFactory.Client.CommitValues(chartConfig, gitOpsConfig) + if err != nil { + impl.logger.Errorw("error in git commit", "err", err) + return "", err + } + return gitHash, nil +} + +func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { + appStoreGitOpsResponse := &AppStoreGitOpsResponse{} + chartGitAttribute, isNew, githash, err := impl.CreateGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) + if err != nil { + impl.logger.Errorw("Error in pushing chart to git", "err", err) + return appStoreGitOpsResponse, err + } + space := regexp.MustCompile(`\s+`) + appStoreName := space.ReplaceAllString(installAppVersionRequest.AppName, "-") + clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName + + // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. + // step-2 commit dependencies and values in git + if !isNew { + _, err = impl.CommitConfigToGit(manifestResponse.RequirementsConfig) + if err != nil { + impl.logger.Errorw("error in committing dependency config to git", "err", err) + return appStoreGitOpsResponse, err + } + err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err) + return appStoreGitOpsResponse, err + } + + githash, err = impl.CommitConfigToGit(manifestResponse.ValuesConfig) + if err != nil { + impl.logger.Errorw("error in committing values config to git", "err", err) + return appStoreGitOpsResponse, err + } + err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err) + return appStoreGitOpsResponse, err + } + } + appStoreGitOpsResponse.ChartGitAttribute = chartGitAttribute + appStoreGitOpsResponse.GitHash = githash + return appStoreGitOpsResponse, nil +} + +func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { + appStoreGitOpsResponse := &AppStoreGitOpsResponse{} + manifest, err := impl.GenerateManifest(installAppVersionRequest) + if err != nil { + impl.logger.Errorw("error in performing manifest and git operations", "err", err) + return nil, err + } + gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) + if err != nil { + impl.logger.Errorw("error in performing gitops operation", "err", err) + return nil, err + } + installAppVersionRequest.GitHash = gitOpsResponse.GitHash + appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute + return appStoreGitOpsResponse, nil +} + +// PushChartToGitopsRepo pushes built chart to gitOps repo +func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, string, error) { + space := regexp.MustCompile(`\s+`) + appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") + chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) + clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) + if _, err := os.Stat(clonedDir); os.IsNotExist(err) { + clonedDir, err = impl.gitFactory.GitService.Clone(PushChartToGitRequest.RepoURL, chartDir) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) + return nil, "", err + } + } else { + err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) + if err != nil { + return nil, "", err + } + } + acdAppName := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, PushChartToGitRequest.EnvName) + dir := filepath.Join(clonedDir, acdAppName) + err := os.MkdirAll(dir, os.ModePerm) + if err != nil { + impl.logger.Errorw("error in making dir", "err", err) + return nil, "", err + } + err = copy2.Copy(PushChartToGitRequest.TempChartRefDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, "", err + } + err = impl.AddConfigFileToChart(requirementsConfig, dir, clonedDir) + if err != nil { + impl.logger.Errorw("error in adding requirements.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) + return nil, "", err + } + err = impl.AddConfigFileToChart(valuesConfig, dir, clonedDir) + if err != nil { + impl.logger.Errorw("error in adding values.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) + return nil, "", err + } + userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) + commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + impl.logger.Warn("re-trying, taking pull and then push again") + err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) + return nil, "", err + } + err = copy2.Copy(PushChartToGitRequest.TempChartRefDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, "", err + } + commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + return nil, "", err + } + } + impl.logger.Debugw("template committed", "url", PushChartToGitRequest.RepoURL, "commit", commit) + defer impl.chartTemplateService.CleanDir(clonedDir) + return &util.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err +} From 9c0f2b882a32a39b88c3c96b046dc5e849aacf04 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 18 Jan 2024 12:28:28 +0530 Subject: [PATCH 23/83] gitOps refactoring --- Wire.go | 4 +- api/restHandler/CommonRestHanlder.go | 25 +- api/restHandler/GitOpsConfigRestHandler.go | 5 +- cmd/external-app/wire.go | 3 +- cmd/external-app/wire_gen.go | 15 +- internal/util/ChartService.go | 404 +----------------- internal/util/GitService.go | 1 + pkg/app/AppService.go | 19 +- pkg/app/ManifestPushService.go | 37 +- pkg/appClone/AppCloneService.go | 16 +- .../common/AppStoreDeploymentCommonService.go | 67 ++- .../AppStoreDeploymentFullModeService.go | 274 ++---------- .../service/AppStoreDeploymentService.go | 21 +- .../deployment/service/InstalledAppService.go | 27 +- .../tool/AppStoreDeploymentHelmService.go | 11 +- .../gitops/AppStoreDeploymentArgoCdService.go | 29 +- pkg/chart/ChartService.go | 26 +- pkg/commonService/CommonService.go | 3 - pkg/deployment/gitOps/common/bean/bean.go | 6 + .../gitOps/config/GitOpsConfigReadService.go | 133 ++++++ pkg/deployment/gitOps/config/bean/bean.go | 14 + .../remote/GitOpsRemoteOperationService.go | 316 ++++++++++++++ pkg/deployment/gitOps/remote/bean/bean.go | 7 + pkg/deployment/gitOps/wire_gitOps.go | 15 + pkg/deployment/wire_deployment.go | 14 + pkg/gitops/GitOpsConfigService.go | 104 ++--- .../AppDeploymentTypeChangeManager.go | 31 +- .../DeploymentPipelineConfigService.go | 54 +-- pkg/pipeline/WorkflowDagExecutor.go | 24 +- wire_gen.go | 60 +-- 30 files changed, 842 insertions(+), 923 deletions(-) create mode 100644 pkg/deployment/gitOps/common/bean/bean.go create mode 100644 pkg/deployment/gitOps/config/GitOpsConfigReadService.go create mode 100644 pkg/deployment/gitOps/config/bean/bean.go create mode 100644 pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go create mode 100644 pkg/deployment/gitOps/remote/bean/bean.go create mode 100644 pkg/deployment/gitOps/wire_gitOps.go create mode 100644 pkg/deployment/wire_deployment.go diff --git a/Wire.go b/Wire.go index 0dc8fefc60..7848ba4221 100644 --- a/Wire.go +++ b/Wire.go @@ -96,7 +96,7 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" - "github.com/devtron-labs/devtron/pkg/deployment/manifest" + deployment2 "github.com/devtron-labs/devtron/pkg/deployment" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -157,7 +157,7 @@ func InitializeApp() (*App, error) { apiToken.ApiTokenWireSet, webhookHelm.WebhookHelmWireSet, terminal.TerminalWireSet, - manifest.DeploymentManifestWireSet, + deployment2.DeploymentWireSet, // -------wireset end ---------- //------- diff --git a/api/restHandler/CommonRestHanlder.go b/api/restHandler/CommonRestHanlder.go index 41007976c8..3f95c46cf3 100644 --- a/api/restHandler/CommonRestHanlder.go +++ b/api/restHandler/CommonRestHanlder.go @@ -21,12 +21,9 @@ import ( "net/http" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/commonService" - "github.com/devtron-labs/devtron/pkg/gitops" "go.uber.org/zap" - "gopkg.in/go-playground/validator.v9" ) type CommonRestHanlder interface { @@ -34,25 +31,19 @@ type CommonRestHanlder interface { } type CommonRestHanlderImpl struct { - logger *zap.SugaredLogger - gitOpsConfigService gitops.GitOpsConfigService - userAuthService user.UserService - validator *validator.Validate - enforcer casbin.Enforcer - commonService commonService.CommonService + logger *zap.SugaredLogger + userAuthService user.UserService + commonService commonService.CommonService } func NewCommonRestHanlderImpl( logger *zap.SugaredLogger, - gitOpsConfigService gitops.GitOpsConfigService, userAuthService user.UserService, - validator *validator.Validate, enforcer casbin.Enforcer, commonService commonService.CommonService) *CommonRestHanlderImpl { + userAuthService user.UserService, + commonService commonService.CommonService) *CommonRestHanlderImpl { return &CommonRestHanlderImpl{ - logger: logger, - gitOpsConfigService: gitOpsConfigService, - userAuthService: userAuthService, - validator: validator, - enforcer: enforcer, - commonService: commonService, + logger: logger, + userAuthService: userAuthService, + commonService: commonService, } } diff --git a/api/restHandler/GitOpsConfigRestHandler.go b/api/restHandler/GitOpsConfigRestHandler.go index 120d310a8b..da9130f6c4 100644 --- a/api/restHandler/GitOpsConfigRestHandler.go +++ b/api/restHandler/GitOpsConfigRestHandler.go @@ -25,7 +25,6 @@ import ( bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/gitops" @@ -52,13 +51,12 @@ type GitOpsConfigRestHandlerImpl struct { validator *validator.Validate enforcer casbin.Enforcer teamService team.TeamService - gitOpsRepository repository.GitOpsConfigRepository } func NewGitOpsConfigRestHandlerImpl( logger *zap.SugaredLogger, gitOpsConfigService gitops.GitOpsConfigService, userAuthService user.UserService, - validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService, gitOpsRepository repository.GitOpsConfigRepository) *GitOpsConfigRestHandlerImpl { + validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService) *GitOpsConfigRestHandlerImpl { return &GitOpsConfigRestHandlerImpl{ logger: logger, gitOpsConfigService: gitOpsConfigService, @@ -66,7 +64,6 @@ func NewGitOpsConfigRestHandlerImpl( validator: validator, enforcer: enforcer, teamService: teamService, - gitOpsRepository: gitOpsRepository, } } diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 45c6a0f225..13b3901b88 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -43,6 +43,7 @@ import ( appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" "github.com/devtron-labs/devtron/pkg/attributes" delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/pipeline" @@ -79,7 +80,7 @@ func InitializeApp() (*App, error) { apiToken.ApiTokenWireSet, webhookHelm.WebhookHelmWireSet, terminal.TerminalWireSet, - + gitOps.GitOpsWireSet, NewApp, NewMuxRouter, util3.GetGlobalEnvVariables, diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index de881eb3d0..f664986f3c 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -66,6 +66,8 @@ import ( repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/genericNotes" repository6 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" @@ -95,7 +97,7 @@ import ( // Injectors from wire.go: func InitializeApp() (*App, error) { - config, err := sql.GetConfig() + sqlConfig, err := sql.GetConfig() if err != nil { return nil, err } @@ -103,7 +105,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - db, err := sql.NewDbConnection(config, sugaredLogger) + db, err := sql.NewDbConnection(sqlConfig, sugaredLogger) if err != nil { return nil, err } @@ -228,6 +230,7 @@ func InitializeApp() (*App, error) { return nil, err } dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) + chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) gitCliUtil := util.NewGitCliUtil(sugaredLogger) gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) @@ -238,9 +241,9 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) - chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigRepositoryImpl) + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) + gitOpsRemoteOperationServiceImpl := remote.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) @@ -281,7 +284,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, deploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) diff --git a/internal/util/ChartService.go b/internal/util/ChartService.go index 2deb276c30..f904ed4490 100644 --- a/internal/util/ChartService.go +++ b/internal/util/ChartService.go @@ -25,20 +25,11 @@ import ( "math/rand" "os" "path/filepath" - "regexp" "strconv" "strings" "time" dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" - - "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" - "github.com/devtron-labs/devtron/util" - "github.com/go-pg/pg" dirCopy "github.com/otiai10/copy" "go.opentelemetry.io/otel" "go.uber.org/zap" @@ -65,35 +56,21 @@ type ChartCreateResponse struct { } type ChartTemplateService interface { - FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error) + FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, error) GetChartVersion(location string) (string, error) - CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error) BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error) BuildChartProxyForHelmApps(chartCreateRequest *ChartCreateRequest) (chartCreateResponse *ChartCreateResponse, err error) - GitPull(clonedDir string, repoUrl string, appStoreName string) error GetDir() string CleanDir(dir string) - GetUserEmailIdAndNameForGitOpsCommit(userId int32) (emailId, name string) - GetGitOpsRepoName(appName string) string - GetGitOpsRepoNameFromUrl(gitRepoUrl string) string - CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *ChartGitAttribute, err error) - PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error) - CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error - UpdateGitRepoUrlInCharts(appId int, chartGitAttribute *ChartGitAttribute, userId int32) error - CreateAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (chartGitAttribute *ChartGitAttribute, err error) LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error) LoadChartFromDir(dir string) (*chart.Chart, error) CreateZipFileForChart(chart *chart.Chart, outputChartPathDir string) ([]byte, error) + PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error) } type ChartTemplateServiceImpl struct { - randSource rand.Source - logger *zap.SugaredLogger - gitFactory *GitFactory - globalEnvVariables *util.GlobalEnvVariables - gitOpsConfigRepository repository.GitOpsConfigRepository - userRepository repository2.UserRepository - chartRepository chartRepoRepository.ChartRepository + randSource rand.Source + logger *zap.SugaredLogger } type ChartValues struct { @@ -105,18 +82,10 @@ type ChartValues struct { ImageDescriptorTemplate string `json:"-"` } -func NewChartTemplateServiceImpl(logger *zap.SugaredLogger, - gitFactory *GitFactory, globalEnvVariables *util.GlobalEnvVariables, - gitOpsConfigRepository repository.GitOpsConfigRepository, - userRepository repository2.UserRepository, chartRepository chartRepoRepository.ChartRepository) *ChartTemplateServiceImpl { +func NewChartTemplateServiceImpl(logger *zap.SugaredLogger) *ChartTemplateServiceImpl { return &ChartTemplateServiceImpl{ - randSource: rand.NewSource(time.Now().UnixNano()), - logger: logger, - gitFactory: gitFactory, - globalEnvVariables: globalEnvVariables, - gitOpsConfigRepository: gitOpsConfigRepository, - userRepository: userRepository, - chartRepository: chartRepository, + randSource: rand.NewSource(time.Now().UnixNano()), + logger: logger, } } @@ -145,7 +114,7 @@ func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, e return chartContent.Version, nil } -func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error) { +func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() chartDir := filepath.Join(ChartWorkingDirPath, dir) @@ -153,7 +122,7 @@ func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { impl.logger.Errorw("err in creating dir", "dir", chartDir, "err", err) - return nil, nil, err + return nil, err } defer impl.CleanDir(chartDir) @@ -161,27 +130,26 @@ func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData if err != nil { impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) - return nil, nil, err + return nil, err } - archivePath, valuesYaml, err := impl.packageChart(chartDir, chartMetaData) + archivePath, valuesYaml, err := impl.PackageChart(chartDir, chartMetaData) if err != nil { impl.logger.Errorw("error in creating archive", "err", err) - return nil, nil, err + return nil, err } values, err := impl.getValues(chartDir, pipelineStrategyPath) if err != nil { impl.logger.Errorw("error in pushing chart", "path", archivePath, "err", err) - return nil, nil, err + return nil, err } values.Values = valuesYaml descriptor, err := ioutil.ReadFile(filepath.Clean(filepath.Join(chartDir, ".image_descriptor_template.json"))) if err != nil { impl.logger.Errorw("error in reading descriptor", "path", chartDir, "err", err) - return nil, nil, err + return nil, err } values.ImageDescriptorTemplate = string(descriptor) - chartGitAttr := &ChartGitAttribute{} - return values, chartGitAttr, nil + return values, nil } // TODO: convert BuildChart and BuildChartProxyForHelmApps into one function @@ -201,8 +169,8 @@ func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaDa impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) return "", err } - _, span := otel.Tracer("orchestrator").Start(ctx, "impl.packageChart") - _, _, err = impl.packageChart(tempReferenceTemplateDir, chartMetaData) + _, span := otel.Tracer("orchestrator").Start(ctx, "impl.PackageChart") + _, _, err = impl.PackageChart(tempReferenceTemplateDir, chartMetaData) span.End() if err != nil { impl.logger.Errorw("error in creating archive", "err", err) @@ -229,7 +197,7 @@ func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateReque impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) return chartCreateResponse, err } - _, valuesYaml, err := impl.packageChart(chartDir, chartMetaData) + _, valuesYaml, err := impl.PackageChart(chartDir, chartMetaData) if err != nil { impl.logger.Errorw("error in creating archive", "err", err) return chartCreateResponse, err @@ -239,121 +207,6 @@ func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateReque return chartCreateResponse, nil } -type ChartGitAttribute struct { - RepoUrl, ChartLocation string -} - -func (impl ChartTemplateServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *ChartGitAttribute, err error) { - //baseTemplateName replace whitespace - space := regexp.MustCompile(`\s+`) - gitOpsRepoName = space.ReplaceAllString(gitOpsRepoName, "-") - - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return nil, err - } - } - //getting user name & emailId for commit author data - userEmailId, userName := impl.GetUserEmailIdAndNameForGitOpsCommit(userId) - gitRepoRequest := &bean.GitOpsConfigDto{ - GitRepoName: gitOpsRepoName, - Description: fmt.Sprintf("helm chart for " + gitOpsRepoName), - Username: userName, - UserEmailId: userEmailId, - BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId, - BitBucketProjectKey: gitOpsConfigBitbucket.BitBucketProjectKey, - } - repoUrl, _, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) - for _, err := range detailedError.StageErrorMap { - if err != nil { - impl.logger.Errorw("error in creating git project", "name", gitOpsRepoName, "err", err) - return nil, err - } - } - return &ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join(baseTemplateName, version)}, nil -} - -func (impl ChartTemplateServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) { - chartDir := fmt.Sprintf("%s-%s", gitOpsRepoName, impl.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) - return err - } - } else { - err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) - if err != nil { - impl.logger.Errorw("error in pulling git repo", "url", repoUrl, "err", err) - return err - } - } - - dir := filepath.Join(clonedDir, referenceTemplate, version) - pushChartToGit := true - - //if chart already exists don't overrides it by reference template - if _, err := os.Stat(dir); os.IsNotExist(err) { - err = os.MkdirAll(dir, os.ModePerm) - if err != nil { - impl.logger.Errorw("error in making dir", "err", err) - return err - } - err = dirCopy.Copy(tempReferenceTemplateDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return err - } - } else { - // auto-healing : data corruption fix - sometimes reference chart contents are not pushed in git-ops repo. - // copying content from reference template dir to cloned dir (if Chart.yaml file is not found) - // if Chart.yaml file is not found, we are assuming here that reference chart contents are not pushed in git-ops repo - if _, err := os.Stat(filepath.Join(dir, "Chart.yaml")); os.IsNotExist(err) { - impl.logger.Infow("auto-healing: Chart.yaml not found in cloned repo from git-ops. copying content", "from", tempReferenceTemplateDir, "to", dir) - err = dirCopy.Copy(tempReferenceTemplateDir, dir) - if err != nil { - impl.logger.Errorw("error copying content in auto-healing", "err", err) - return err - } - } else { - // chart exists on git, hence not performing first commit - pushChartToGit = false - } - } - - // if push needed, then only push - if pushChartToGit { - userEmailId, userName := impl.GetUserEmailIdAndNameForGitOpsCommit(userId) - commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) - if err != nil { - return err - } - err = dirCopy.Copy(tempReferenceTemplateDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return err - } - commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - return err - } - } - impl.logger.Debugw("template committed", "url", repoUrl, "commit", commit) - } - - defer impl.CleanDir(clonedDir) - return nil -} - func (impl ChartTemplateServiceImpl) getValues(directory, pipelineStrategyPath string) (values *ChartValues, err error) { if fi, err := os.Stat(directory); err != nil { @@ -428,7 +281,7 @@ func (impl ChartTemplateServiceImpl) getValues(directory, pipelineStrategyPath s } -func (impl ChartTemplateServiceImpl) packageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error) { +func (impl ChartTemplateServiceImpl) PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error) { valid, err := chartutil.IsChartDir(tempReferenceTemplateDir) if err != nil { impl.logger.Errorw("error in validating base chart", "dir", tempReferenceTemplateDir, "err", err) @@ -479,187 +332,6 @@ func (impl ChartTemplateServiceImpl) GetDir() string { return strconv.FormatInt(r1, 10) } -func (impl ChartTemplateServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error) { - chartMetaData.ApiVersion = "v2" // ensure always v2 - dir := impl.GetDir() - chartDir := filepath.Join(ChartWorkingDirPath, dir) - impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) - err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling - if err != nil { - impl.logger.Errorw("err in creating dir", "dir", chartDir, "err", err) - return "", nil, err - } - defer impl.CleanDir(chartDir) - err = dirCopy.Copy(refChartLocation, chartDir) - - if err != nil { - impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) - return "", nil, err - } - archivePath, valuesYaml, err := impl.packageChart(chartDir, chartMetaData) - if err != nil { - impl.logger.Errorw("error in creating archive", "err", err) - return "", nil, err - } - - chartGitAttr, err := impl.CreateAndPushToGitChartProxy(chartMetaData.Name, chartDir, envName, installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in pushing chart to git ", "path", archivePath, "err", err) - return "", nil, err - } - if valuesYaml == "" { - valuesYaml = "{}" - } else { - valuesYamlByte, err := yaml.YAMLToJSON([]byte(valuesYaml)) - if err != nil { - return "", nil, err - } - valuesYaml = string(valuesYamlByte) - } - return valuesYaml, chartGitAttr, nil -} - -func (impl ChartTemplateServiceImpl) CreateAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (chartGitAttribute *ChartGitAttribute, err error) { - //baseTemplateName replace whitespace - space := regexp.MustCompile(`\s+`) - appStoreName = space.ReplaceAllString(appStoreName, "-") - - if len(installAppVersionRequest.GitOpsRepoName) == 0 { - //here git ops repo will be the app name, to breaking the mono repo structure - gitOpsRepoName := impl.GetGitOpsRepoName(installAppVersionRequest.AppName) - installAppVersionRequest.GitOpsRepoName = gitOpsRepoName - } - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return nil, err - } - } - //getting user name & emailId for commit author data - userEmailId, userName := impl.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) - gitRepoRequest := &bean.GitOpsConfigDto{ - GitRepoName: installAppVersionRequest.GitOpsRepoName, - Description: "helm chart for " + installAppVersionRequest.GitOpsRepoName, - Username: userName, - UserEmailId: userEmailId, - BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId, - BitBucketProjectKey: gitOpsConfigBitbucket.BitBucketProjectKey, - } - repoUrl, _, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) - for _, err := range detailedError.StageErrorMap { - if err != nil { - impl.logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) - return nil, err - } - } - - chartDir := fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, impl.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) - return nil, err - } - } else { - err = impl.GitPull(clonedDir, repoUrl, appStoreName) - if err != nil { - return nil, err - } - } - - acdAppName := fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, envName) - dir := filepath.Join(clonedDir, acdAppName) - err = os.MkdirAll(dir, os.ModePerm) - if err != nil { - impl.logger.Errorw("error in making dir", "err", err) - return nil, err - } - err = dirCopy.Copy(tmpChartLocation, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, err - } - commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.GitPull(clonedDir, repoUrl, acdAppName) - if err != nil { - return nil, err - } - err = dirCopy.Copy(tmpChartLocation, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, err - } - commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - return nil, err - } - } - impl.logger.Debugw("template committed", "url", repoUrl, "commit", commit) - defer impl.CleanDir(clonedDir) - return &ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join("", acdAppName)}, nil -} - -func (impl ChartTemplateServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error { - err := impl.gitFactory.GitService.Pull(clonedDir) //TODO check for local repo exists before clone - if err != nil { - impl.logger.Errorw("error in pulling git", "clonedDir", clonedDir, "err", err) - _, err := impl.gitFactory.GitService.Clone(repoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) - return err - } - return nil - } - return nil -} - -func (impl *ChartTemplateServiceImpl) GetUserEmailIdAndNameForGitOpsCommit(userId int32) (string, string) { - emailId := "devtron-bot@devtron.ai" - name := "devtron bot" - //getting emailId associated with user - userDetail, _ := impl.userRepository.GetById(userId) - if userDetail != nil && userDetail.EmailId != "admin" && userDetail.EmailId != "system" && len(userDetail.EmailId) > 0 { - emailId = userDetail.EmailId - } else { - emailIdGitOps, err := impl.gitOpsConfigRepository.GetEmailIdFromActiveGitOpsConfig() - if err != nil { - impl.logger.Errorw("error in getting emailId from active gitOps config", "err", err) - } else if len(emailIdGitOps) > 0 { - emailId = emailIdGitOps - } - } - //we are getting name from emailId(replacing special characters in with space) - emailComponents := strings.Split(emailId, "@") - regex, _ := regexp.Compile(`[^\w]`) - if regex != nil { - name = regex.ReplaceAllString(emailComponents[0], " ") - } - return emailId, name -} - -func (impl ChartTemplateServiceImpl) GetGitOpsRepoName(appName string) string { - var repoName string - if len(impl.globalEnvVariables.GitOpsRepoPrefix) == 0 { - repoName = appName - } else { - repoName = fmt.Sprintf("%s-%s", impl.globalEnvVariables.GitOpsRepoPrefix, appName) - } - return repoName -} - -func (impl ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) string { - gitRepoUrl = gitRepoUrl[strings.LastIndex(gitRepoUrl, "/")+1:] - gitRepoUrl = strings.ReplaceAll(gitRepoUrl, ".git", "") - return gitRepoUrl -} - // GetByteArrayRefChart this method will be used for getting byte array from reference chart to store in db func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 @@ -677,7 +349,7 @@ func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.M impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) return nil, err } - activePath, _, err := impl.packageChart(tempReferenceTemplateDir, chartMetaData) + activePath, _, err := impl.PackageChart(tempReferenceTemplateDir, chartMetaData) if err != nil { impl.logger.Errorw("error in creating archive", "err", err) return nil, err @@ -697,42 +369,6 @@ func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.M return bs, nil } -func (impl ChartTemplateServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error { - userEmailId, userName := impl.GetUserEmailIdAndNameForGitOpsCommit(userId) - gitOpsConfig, err := impl.gitOpsConfigRepository.GetGitOpsConfigActive() - config := &bean.GitOpsConfigDto{ - Username: userName, - UserEmailId: userEmailId, - GitRepoName: gitOpsRepoName, - BitBucketWorkspaceId: gitOpsConfig.BitBucketWorkspaceId, - } - _, err = impl.gitFactory.Client.CreateReadme(config) - if err != nil { - return err - } - return nil -} - -func (impl ChartTemplateServiceImpl) UpdateGitRepoUrlInCharts(appId int, chartGitAttribute *ChartGitAttribute, userId int32) error { - charts, err := impl.chartRepository.FindActiveChartsByAppId(appId) - if err != nil && pg.ErrNoRows != err { - return err - } - for _, ch := range charts { - if len(ch.GitRepoUrl) == 0 { - ch.GitRepoUrl = chartGitAttribute.RepoUrl - ch.ChartLocation = chartGitAttribute.ChartLocation - ch.UpdatedOn = time.Now() - ch.UpdatedBy = userId - err = impl.chartRepository.Update(ch) - if err != nil { - return err - } - } - } - return nil -} - func (impl ChartTemplateServiceImpl) LoadChartInBytes(ChartPath string, deleteChart bool) ([]byte, error) { var chartBytesArr []byte diff --git a/internal/util/GitService.go b/internal/util/GitService.go index 882772e523..06b2a47d63 100644 --- a/internal/util/GitService.go +++ b/internal/util/GitService.go @@ -52,6 +52,7 @@ const ( ) type GitClient interface { + //TODO: make all methods independent of GitOpsConfigDto, create own dto object CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error) diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 5a17c7dfcd..94898950cf 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -21,6 +21,9 @@ import ( "context" "encoding/json" "fmt" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "io/ioutil" "net/url" @@ -117,6 +120,8 @@ type AppServiceImpl struct { scopedVariableManager variables.ScopedVariableCMCSManager acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService + gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } type AppService interface { @@ -136,7 +141,7 @@ type AppService interface { //GetEnvOverrideByTriggerType(overrideRequest *bean.ValuesOverrideRequest, triggeredAt time.Time, ctx context.Context) (*chartConfig.EnvConfigOverride, error) //GetAppMetricsByTriggerType(overrideRequest *bean.ValuesOverrideRequest, ctx context.Context) (bool, error) //GetDeploymentStrategyByTriggerType(overrideRequest *bean.ValuesOverrideRequest, ctx context.Context) (*chartConfig.PipelineStrategy, error) - CreateGitopsRepo(app *app.App, userId int32) (gitopsRepoName string, chartGitAttr *ChartGitAttribute, err error) + CreateGitopsRepo(app *app.App, userId int32) (gitopsRepoName string, chartGitAttr *commonBean.ChartGitAttribute, err error) GetDeployedManifestByPipelineIdAndCDWorkflowId(appId int, envId int, cdWorkflowId int, ctx context.Context) ([]byte, error) //SetPipelineFieldsInOverrideRequest(overrideRequest *bean.ValuesOverrideRequest, pipeline *pipelineConfig.Pipeline) @@ -169,7 +174,9 @@ func NewAppService( installedAppVersionHistoryRepository repository4.InstalledAppVersionHistoryRepository, globalEnvVariables *util2.GlobalEnvVariables, scopedVariableManager variables.ScopedVariableCMCSManager, - acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService) *AppServiceImpl { + acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppServiceImpl { appServiceImpl := &AppServiceImpl{ environmentConfigRepository: environmentConfigRepository, mergeUtil: mergeUtil, @@ -198,6 +205,8 @@ func NewAppService( scopedVariableManager: scopedVariableManager, acdConfig: acdConfig, chartRefService: chartRefService, + gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } return appServiceImpl } @@ -901,13 +910,13 @@ func (impl *AppServiceImpl) BuildChartAndGetPath(appName string, envOverride *ch return tempReferenceTemplateDir, nil } -func (impl *AppServiceImpl) CreateGitopsRepo(app *app.App, userId int32) (gitopsRepoName string, chartGitAttr *ChartGitAttribute, err error) { +func (impl *AppServiceImpl) CreateGitopsRepo(app *app.App, userId int32) (gitopsRepoName string, chartGitAttr *commonBean.ChartGitAttribute, err error) { chart, err := impl.chartRepository.FindLatestChartForAppByAppId(app.Id) if err != nil && pg.ErrNoRows != err { return "", nil, err } - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(app.AppName) - chartGitAttr, err = impl.chartTemplateService.CreateGitRepositoryForApp(gitOpsRepoName, chart.ReferenceTemplate, chart.ChartVersion, userId) + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(app.AppName) + chartGitAttr, err = impl.gitOpsRemoteOperationService.CreateGitRepositoryForApp(gitOpsRepoName, chart.ReferenceTemplate, chart.ChartVersion, userId) if err != nil { impl.logger.Errorw("error in pushing chart to git ", "gitOpsRepoName", gitOpsRepoName, "err", err) return "", nil, err diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index f52731b204..1e32701e53 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -5,14 +5,14 @@ import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" . "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" - "github.com/go-pg/pg" "go.opentelemetry.io/otel" "go.uber.org/zap" "time" @@ -28,32 +28,32 @@ type GitOpsPushService interface { type GitOpsManifestPushServiceImpl struct { logger *zap.SugaredLogger - chartTemplateService util.ChartTemplateService - gitOpsConfigRepository repository.GitOpsConfigRepository gitFactory *GitFactory pipelineStatusTimelineService status2.PipelineStatusTimelineService pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService + gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewGitOpsManifestPushServiceImpl( logger *zap.SugaredLogger, - chartTemplateService util.ChartTemplateService, - gitOpsConfigRepository repository.GitOpsConfigRepository, gitFactory *GitFactory, pipelineStatusTimelineService status2.PipelineStatusTimelineService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, - acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService) *GitOpsManifestPushServiceImpl { + acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, - chartTemplateService: chartTemplateService, - gitOpsConfigRepository: gitOpsConfigRepository, gitFactory: gitFactory, pipelineStatusTimelineService: pipelineStatusTimelineService, pipelineStatusTimelineRepository: pipelineStatusTimelineRepository, acdConfig: acdConfig, chartRefService: chartRefService, + gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -105,7 +105,7 @@ func (impl *GitOpsManifestPushServiceImpl) PushChartToGitRepo(manifestPushTempla _, span := otel.Tracer("orchestrator").Start(ctx, "chartTemplateService.GetGitOpsRepoName") // CHART COMMIT and PUSH STARTS HERE, it will push latest version, if found modified on deployment template and overrides - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(manifestPushTemplate.AppName) + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(manifestPushTemplate.AppName) span.End() _, span = otel.Tracer("orchestrator").Start(ctx, "chartService.CheckChartExists") err := impl.chartRefService.CheckChartExists(manifestPushTemplate.ChartRefId) @@ -114,7 +114,7 @@ func (impl *GitOpsManifestPushServiceImpl) PushChartToGitRepo(manifestPushTempla impl.logger.Errorw("err in getting chart info", "err", err) return err } - err = impl.chartTemplateService.PushChartToGitRepo(gitOpsRepoName, manifestPushTemplate.ChartReferenceTemplate, manifestPushTemplate.ChartVersion, manifestPushTemplate.BuiltChartPath, manifestPushTemplate.RepoUrl, manifestPushTemplate.UserId) + err = impl.gitOpsRemoteOperationService.PushChartToGitRepo(gitOpsRepoName, manifestPushTemplate.ChartReferenceTemplate, manifestPushTemplate.ChartVersion, manifestPushTemplate.BuiltChartPath, manifestPushTemplate.RepoUrl, manifestPushTemplate.UserId) if err != nil { impl.logger.Errorw("error in pushing chart to git", "err", err) return err @@ -125,10 +125,10 @@ func (impl *GitOpsManifestPushServiceImpl) PushChartToGitRepo(manifestPushTempla func (impl *GitOpsManifestPushServiceImpl) CommitValuesToGit(manifestPushTemplate *bean.ManifestPushTemplate, ctx context.Context) (commitHash string, commitTime time.Time, err error) { commitHash = "" commitTime = time.Time{} - chartRepoName := impl.chartTemplateService.GetGitOpsRepoNameFromUrl(manifestPushTemplate.RepoUrl) + chartRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(manifestPushTemplate.RepoUrl) _, span := otel.Tracer("orchestrator").Start(ctx, "chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit") //getting username & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(manifestPushTemplate.UserId) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(manifestPushTemplate.UserId) span.End() chartGitAttr := &util.ChartConfig{ FileName: fmt.Sprintf("_%d-values.yaml", manifestPushTemplate.TargetEnvironmentName), @@ -140,15 +140,12 @@ func (impl *GitOpsManifestPushServiceImpl) CommitValuesToGit(manifestPushTemplat UserName: userName, UserEmailId: userEmailId, } - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return commitHash, commitTime, err - } + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return commitHash, commitTime, err } - gitOpsConfig := &bean2.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} + gitOpsConfig := &bean2.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} _, span = otel.Tracer("orchestrator").Start(ctx, "gitFactory.Client.CommitValues") commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) span.End() diff --git a/pkg/appClone/AppCloneService.go b/pkg/appClone/AppCloneService.go index 68fac6ef78..8affc7f2e2 100644 --- a/pkg/appClone/AppCloneService.go +++ b/pkg/appClone/AppCloneService.go @@ -31,6 +31,7 @@ import ( "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/chart" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/pipeline" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/go-pg/pg" @@ -44,7 +45,6 @@ type AppCloneService interface { type AppCloneServiceImpl struct { logger *zap.SugaredLogger pipelineBuilder pipeline.PipelineBuilder - materialRepository pipelineConfig.MaterialRepository chartService chart.ChartService configMapService pipeline.ConfigMapService appWorkflowService appWorkflow.AppWorkflowService @@ -55,27 +55,25 @@ type AppCloneServiceImpl struct { appRepository app2.AppRepository ciPipelineRepository pipelineConfig.CiPipelineRepository pipelineRepository pipelineConfig.PipelineRepository - appWorkflowRepository appWorkflow2.AppWorkflowRepository ciPipelineConfigService pipeline.CiPipelineConfigService + gitOpsConfigReadService config.GitOpsConfigReadService } func NewAppCloneServiceImpl(logger *zap.SugaredLogger, pipelineBuilder pipeline.PipelineBuilder, - materialRepository pipelineConfig.MaterialRepository, chartService chart.ChartService, configMapService pipeline.ConfigMapService, appWorkflowService appWorkflow.AppWorkflowService, appListingService app.AppListingService, propertiesConfigService pipeline.PropertiesConfigService, - ciTemplateOverrideRepository pipelineConfig.CiTemplateOverrideRepository, pipelineStageService pipeline.PipelineStageService, ciTemplateService pipeline.CiTemplateService, appRepository app2.AppRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, - pipelineRepository pipelineConfig.PipelineRepository, appWorkflowRepository appWorkflow2.AppWorkflowRepository, - ciPipelineConfigService pipeline.CiPipelineConfigService) *AppCloneServiceImpl { + pipelineRepository pipelineConfig.PipelineRepository, + ciPipelineConfigService pipeline.CiPipelineConfigService, + gitOpsConfigReadService config.GitOpsConfigReadService) *AppCloneServiceImpl { return &AppCloneServiceImpl{ logger: logger, pipelineBuilder: pipelineBuilder, - materialRepository: materialRepository, chartService: chartService, configMapService: configMapService, appWorkflowService: appWorkflowService, @@ -86,8 +84,8 @@ func NewAppCloneServiceImpl(logger *zap.SugaredLogger, appRepository: appRepository, ciPipelineRepository: ciPipelineRepository, pipelineRepository: pipelineRepository, - appWorkflowRepository: appWorkflowRepository, ciPipelineConfigService: ciPipelineConfigService, + gitOpsConfigReadService: gitOpsConfigReadService, } } @@ -985,7 +983,7 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c for deploymentType, allowed := range DeploymentAppConfigForEnvironment { AllowedDeploymentAppTypes[deploymentType] = allowed } - isGitopsConfigured, err := impl.pipelineBuilder.IsGitopsConfigured() + isGitopsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err != nil { impl.logger.Errorw("error in checking if gitOps configured", "err", err) return nil, err diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index ab912fda04..ed86999b8b 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -21,13 +21,15 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/devtron/api/bean" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" util2 "github.com/devtron-labs/devtron/pkg/appStore/util" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/go-pg/pg" "github.com/google/go-github/github" "github.com/microsoft/azure-devops-go-api/azuredevops" @@ -50,7 +52,7 @@ type AppStoreDeploymentCommonService interface { ParseGitRepoErrorResponse(err error) (bool, error) GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) - CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, bool, string, error) + CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) CommitConfigToGit(chartConfig *util.ChartConfig) (gitHash string, err error) GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) GetValuesString(chartName, valuesOverrideYaml string) (string, error) @@ -67,7 +69,8 @@ type AppStoreDeploymentCommonServiceImpl struct { environmentRepository repository2.EnvironmentRepository chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory - gitOpsConfigRepository repository3.GitOpsConfigRepository + gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewAppStoreDeploymentCommonServiceImpl( @@ -77,8 +80,8 @@ func NewAppStoreDeploymentCommonServiceImpl( environmentRepository repository2.EnvironmentRepository, chartTemplateService util.ChartTemplateService, gitFactory *util.GitFactory, - gitOpsConfigRepository repository3.GitOpsConfigRepository, -) *AppStoreDeploymentCommonServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -86,7 +89,8 @@ func NewAppStoreDeploymentCommonServiceImpl( environmentRepository: environmentRepository, chartTemplateService: chartTemplateService, gitFactory: gitFactory, - gitOpsConfigRepository: gitOpsConfigRepository, + gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -117,7 +121,7 @@ type AppStoreManifestResponse struct { } type AppStoreGitOpsResponse struct { - ChartGitAttribute *util.ChartGitAttribute + ChartGitAttribute *commonBean.ChartGitAttribute GitHash string } @@ -299,8 +303,8 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVer } argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) YamlConfig := &util.ChartConfig{ FileName: filename, FileContent: fileString, @@ -403,27 +407,23 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi if len(installAppVersionRequest.GitOpsRepoName) == 0 { //here gitops repo will be the app name, to breaking the mono repo structure - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) installAppVersionRequest.GitOpsRepoName = gitOpsRepoName } - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { - if err == pg.ErrNoRows { - err = nil - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return "", false, err - } + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return "", false, err } //getting user name & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) gitRepoRequest := &bean.GitOpsConfigDto{ GitRepoName: installAppVersionRequest.GitOpsRepoName, Description: "helm chart for " + installAppVersionRequest.GitOpsRepoName, Username: userName, UserEmailId: userEmailId, - BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId, - BitBucketProjectKey: gitOpsConfigBitbucket.BitBucketProjectKey, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, } repoUrl, isNew, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) for _, err := range detailedError.StageErrorMap { @@ -436,7 +436,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi } // PushChartToGitopsRepo pushes built chart to gitOps repo -func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, string, error) { +func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, string, error) { space := regexp.MustCompile(`\s+`) appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) @@ -448,7 +448,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT return nil, "", err } } else { - err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) + err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) if err != nil { return nil, "", err } @@ -475,12 +475,12 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT impl.logger.Errorw("error in adding values.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) return nil, "", err } - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) if err != nil { impl.logger.Errorw("error in pushing git", "err", err) impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.chartTemplateService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) + err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) if err != nil { impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) return nil, "", err @@ -498,7 +498,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT } impl.logger.Debugw("template committed", "url", PushChartToGitRequest.RepoURL, "commit", commit) defer impl.chartTemplateService.CleanDir(clonedDir) - return &util.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err + return &commonBean.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err } // AddConfigFileToChart will override requirements.yaml file in chart @@ -525,7 +525,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *uti } // CreateGitOpsRepoAndPushChart is a wrapper for creating gitops repo and pushing chart to created repo -func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*util.ChartGitAttribute, bool, string, error) { +func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { repoURL, isNew, err := impl.CreateGitOpsRepo(installAppVersionRequest) if err != nil { impl.logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) @@ -542,15 +542,12 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(ins // CommitConfigToGit is used for committing values.yaml and requirements.yaml file config func (impl AppStoreDeploymentCommonServiceImpl) CommitConfigToGit(chartConfig *util.ChartConfig) (string, error) { - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return "", err - } + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return "", err } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} + gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} gitHash, _, err := impl.gitFactory.Client.CommitValues(chartConfig, gitOpsConfig) if err != nil { impl.logger.Errorw("error in git commit", "err", err) @@ -578,7 +575,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons impl.logger.Errorw("error in committing dependency config to git", "err", err) return appStoreGitOpsResponse, err } - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) if err != nil { impl.logger.Errorw("error in git pull", "err", err) return appStoreGitOpsResponse, err @@ -589,7 +586,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons impl.logger.Errorw("error in committing values config to git", "err", err) return appStoreGitOpsResponse, err } - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) if err != nil { impl.logger.Errorw("error in git pull", "err", err) return appStoreGitOpsResponse, err diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 77d651bf19..6293aa0cb6 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -24,13 +24,11 @@ import ( "fmt" "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" - "path" - "regexp" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "time" - "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/argocdServer" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app/status" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" @@ -40,18 +38,12 @@ import ( repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/pkg/util" - util3 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" "github.com/go-pg/pg" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/client/argocdServer/repository" - "github.com/devtron-labs/devtron/internal/util" "go.uber.org/zap" - "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/proto/hapi/chart" - "sigs.k8s.io/yaml" ) const ( @@ -60,8 +52,7 @@ const ( ) type AppStoreDeploymentFullModeService interface { - AppStoreDeployOperationGIT(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, *util.ChartGitAttribute, error) - AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) SyncACD(acdAppName string, ctx context.Context) UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error @@ -70,67 +61,43 @@ type AppStoreDeploymentFullModeService interface { } type AppStoreDeploymentFullModeServiceImpl struct { - logger *zap.SugaredLogger - chartTemplateService util.ChartTemplateService - repositoryService repository.ServiceClient - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository5.EnvironmentRepository - acdClient application2.ServiceClient - ArgoK8sClient argocdServer.ArgoK8sClient - gitFactory *util.GitFactory - aCDAuthConfig *util2.ACDAuthConfig - globalEnvVariables *util3.GlobalEnvVariables - installedAppRepository repository4.InstalledAppRepository - tokenCache *util2.TokenCache - argoUserService argo.ArgoUserService - gitOpsConfigRepository repository3.GitOpsConfigRepository - pipelineStatusTimelineService status.PipelineStatusTimelineService - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - argoClientWrapperService argocdServer.ArgoClientWrapperService - pubSubClient *pubsub_lib.PubSubClientServiceImpl - installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository - ACDConfig *argocdServer.ACDConfig + logger *zap.SugaredLogger + acdClient application2.ServiceClient + ArgoK8sClient argocdServer.ArgoK8sClient + aCDAuthConfig *util2.ACDAuthConfig + argoUserService argo.ArgoUserService + pipelineStatusTimelineService status.PipelineStatusTimelineService + appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService + argoClientWrapperService argocdServer.ArgoClientWrapperService + pubSubClient *pubsub_lib.PubSubClientServiceImpl + installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository + ACDConfig *argocdServer.ACDConfig + gitOpsConfigReadService config.GitOpsConfigReadService } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, - chartTemplateService util.ChartTemplateService, - repositoryService repository.ServiceClient, - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository repository5.EnvironmentRepository, acdClient application2.ServiceClient, - argoK8sClient argocdServer.ArgoK8sClient, - gitFactory *util.GitFactory, aCDAuthConfig *util2.ACDAuthConfig, - globalEnvVariables *util3.GlobalEnvVariables, - installedAppRepository repository4.InstalledAppRepository, tokenCache *util2.TokenCache, - argoUserService argo.ArgoUserService, gitOpsConfigRepository repository3.GitOpsConfigRepository, - pipelineStatusTimelineService status.PipelineStatusTimelineService, + argoK8sClient argocdServer.ArgoK8sClient, aCDAuthConfig *util2.ACDAuthConfig, + argoUserService argo.ArgoUserService, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, argoClientWrapperService argocdServer.ArgoClientWrapperService, pubSubClient *pubsub_lib.PubSubClientServiceImpl, installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, ACDConfig *argocdServer.ACDConfig, -) *AppStoreDeploymentFullModeServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ - logger: logger, - chartTemplateService: chartTemplateService, - repositoryService: repositoryService, - appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, - acdClient: acdClient, - ArgoK8sClient: argoK8sClient, - gitFactory: gitFactory, - aCDAuthConfig: aCDAuthConfig, - globalEnvVariables: globalEnvVariables, - installedAppRepository: installedAppRepository, - tokenCache: tokenCache, - argoUserService: argoUserService, - gitOpsConfigRepository: gitOpsConfigRepository, - pipelineStatusTimelineService: pipelineStatusTimelineService, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, - argoClientWrapperService: argoClientWrapperService, - pubSubClient: pubSubClient, - installedAppRepositoryHistory: installedAppRepositoryHistory, - ACDConfig: ACDConfig, + logger: logger, + acdClient: acdClient, + ArgoK8sClient: argoK8sClient, + aCDAuthConfig: aCDAuthConfig, + argoUserService: argoUserService, + pipelineStatusTimelineService: pipelineStatusTimelineService, + appStoreDeploymentCommonService: appStoreDeploymentCommonService, + argoClientWrapperService: argoClientWrapperService, + pubSubClient: pubSubClient, + installedAppRepositoryHistory: installedAppRepositoryHistory, + ACDConfig: ACDConfig, + gitOpsConfigReadService: gitOpsConfigReadService, } err := appStoreDeploymentFullModeServiceImpl.SubscribeHelmInstallStatus() if err != nil { @@ -139,182 +106,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, return appStoreDeploymentFullModeServiceImpl } -func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationGIT(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, *util.ChartGitAttribute, error) { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installAppVersionRequest, nil, err - } - - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installAppVersionRequest, nil, err - } - - //STEP 1: Commit and PUSH on Gitlab - template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) - valid, err := chartutil.IsChartDir(chartPath) - if err != nil || !valid { - impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) - return installAppVersionRequest, nil, err - } - chartMeta := &chart.Metadata{ - Name: installAppVersionRequest.AppName, - Version: "1.0.1", - } - _, chartGitAttr, err := impl.chartTemplateService.CreateChartProxy(chartMeta, chartPath, environment.Name, installAppVersionRequest) - if err != nil { - return installAppVersionRequest, nil, err - } - - //STEP 3 - update requirements and values - argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name - dependency := appStoreBean.Dependency{ - Name: appStoreAppVersion.AppStore.Name, - Version: appStoreAppVersion.Version, - } - if appStoreAppVersion.AppStore.ChartRepo != nil { - dependency.Repository = appStoreAppVersion.AppStore.ChartRepo.Url - } - var dependencies []appStoreBean.Dependency - dependencies = append(dependencies, dependency) - requirementDependencies := &appStoreBean.Dependencies{ - Dependencies: dependencies, - } - requirementDependenciesByte, err := json.Marshal(requirementDependencies) - if err != nil { - return installAppVersionRequest, nil, err - } - requirementDependenciesByte, err = yaml.JSONToYAML(requirementDependenciesByte) - if err != nil { - return installAppVersionRequest, nil, err - } - - gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) - //getting username & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return installAppVersionRequest, nil, err - } - } - requirmentYamlConfig := &util.ChartConfig{ - FileName: appStoreBean.REQUIREMENTS_YAML_FILE, - FileContent: string(requirementDependenciesByte), - ChartName: chartMeta.Name, - ChartLocation: argocdAppName, - ChartRepoName: gitOpsRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), - UserEmailId: userEmailId, - UserName: userName, - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} - _, _, err = impl.gitFactory.Client.CommitValues(requirmentYamlConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return installAppVersionRequest, nil, err - } - - //GIT PULL - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(chartMeta.Name, "-") - clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttr.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return installAppVersionRequest, nil, err - } - - //update values yaml in chart - ValuesOverrideByte, err := yaml.YAMLToJSON([]byte(installAppVersionRequest.ValuesOverrideYaml)) - if err != nil { - impl.logger.Errorw("error in json patch", "err", err) - return installAppVersionRequest, nil, err - } - - var dat map[string]interface{} - err = json.Unmarshal(ValuesOverrideByte, &dat) - - valuesMap := make(map[string]map[string]interface{}) - valuesMap[appStoreAppVersion.AppStore.Name] = dat - valuesByte, err := json.Marshal(valuesMap) - if err != nil { - impl.logger.Errorw("error in marshaling", "err", err) - return installAppVersionRequest, nil, err - } - - valuesYamlConfig := &util.ChartConfig{ - FileName: appStoreBean.VALUES_YAML_FILE, - FileContent: string(valuesByte), - ChartName: chartMeta.Name, - ChartLocation: argocdAppName, - ChartRepoName: gitOpsRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), - UserEmailId: userEmailId, - UserName: userName, - } - - commitHash, _, err := impl.gitFactory.Client.CommitValues(valuesYamlConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - //update timeline status for git commit failed state - gitCommitStatus := pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED - gitCommitStatusDetail := fmt.Sprintf("Git commit failed - %v", err) - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: gitCommitStatus, - StatusDetail: gitCommitStatusDetail, - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - timelineErr := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if timelineErr != nil { - impl.logger.Errorw("error in creating timeline status for git commit", "err", timelineErr, "timeline", timeline) - } - return installAppVersionRequest, nil, err - } - //creating timeline for Git Commit stage - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, - StatusDetail: "Git commit done successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if err != nil { - impl.logger.Errorw("error in creating timeline status for git commit", "err", err, "timeline", timeline) - } - - //sync local dir with remote - err = impl.chartTemplateService.GitPull(clonedDir, chartGitAttr.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return installAppVersionRequest, nil, err - } - installAppVersionRequest.GitHash = commitHash - installAppVersionRequest.ACDAppName = argocdAppName - installAppVersionRequest.Environment = environment - - return installAppVersionRequest, chartGitAttr, nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() //STEP 4: registerInArgo @@ -373,7 +165,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) SyncACD(acdAppName string, ctx } } -func (impl AppStoreDeploymentFullModeServiceImpl) createInArgo(chartGitAttribute *util.ChartGitAttribute, ctx context.Context, envModel repository5.Environment, argocdAppName string) error { +func (impl AppStoreDeploymentFullModeServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, ctx context.Context, envModel repository5.Environment, argocdAppName string) error { appNamespace := envModel.Namespace if appNamespace == "" { appNamespace = "default" @@ -416,7 +208,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) GetGitOpsRepoName(appName stri } if application != nil { gitOpsRepoUrl := application.Spec.Source.RepoURL - gitOpsRepoName = impl.chartTemplateService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) + gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) } return gitOpsRepoName, nil } diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index 02e55ca006..89c61c6d09 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -39,11 +39,11 @@ import ( appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -106,8 +106,8 @@ type AppStoreDeploymentServiceImpl struct { installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository gitOpsRepository repository2.GitOpsConfigRepository deploymentTypeConfig *DeploymentServiceTypeConfig - ChartTemplateService util.ChartTemplateService aCDConfig *argocdServer.ACDConfig + gitOpsConfigReadService config.GitOpsConfigReadService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, @@ -117,8 +117,9 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep appStoreDeploymentArgoCdService appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService client.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, globalEnvVariables *util2.GlobalEnvVariables, - installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, attributesService attributes.AttributesService, - deploymentTypeConfig *DeploymentServiceTypeConfig, ChartTemplateService util.ChartTemplateService, aCDConfig *argocdServer.ACDConfig) *AppStoreDeploymentServiceImpl { + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, + deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, + gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ logger: logger, @@ -138,8 +139,8 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep installedAppRepositoryHistory: installedAppRepositoryHistory, gitOpsRepository: gitOpsRepository, deploymentTypeConfig: deploymentTypeConfig, - ChartTemplateService: ChartTemplateService, aCDConfig: aCDConfig, + gitOpsConfigReadService: gitOpsConfigReadService, } return appStoreDeploymentServiceImpl } @@ -247,7 +248,7 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVe installedAppModel.UpdatedOn = time.Now() installedAppModel.Active = true if util2.IsFullStack() { - installedAppModel.GitOpsRepoName = impl.ChartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) + installedAppModel.GitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) installAppVersionRequest.GitOpsRepoName = installedAppModel.GitOpsRepoName } installedApp, err := impl.installedAppRepository.CreateInstalledApp(installedAppModel, tx) @@ -1289,11 +1290,11 @@ func (impl *AppStoreDeploymentServiceImpl) CheckIfMonoRepoMigrationRequired(inst return false } } else { - gitOpsRepoName = impl.ChartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) + gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) } } //here will set new git repo name if required to migrate - newGitOpsRepoName := impl.ChartTemplateService.GetGitOpsRepoName(installedApp.App.AppName) + newGitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installedApp.App.AppName) //checking weather git repo migration needed or not, if existing git repo and new independent git repo is not same than go ahead with migration if newGitOpsRepoName != gitOpsRepoName { monoRepoMigrationRequired = true @@ -1447,11 +1448,11 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex return nil, err } } else { - gitOpsRepoName = impl.ChartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) + gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) } } //here will set new git repo name if required to migrate - newGitOpsRepoName := impl.ChartTemplateService.GetGitOpsRepoName(installedApp.App.AppName) + newGitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installedApp.App.AppName) //checking weather git repo migration needed or not, if existing git repo and new independent git repo is not same than go ahead with migration if newGitOpsRepoName != gitOpsRepoName { monoRepoMigrationRequired = true diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index f97b19e5eb..eb1c89ad53 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -20,6 +20,9 @@ package service import ( "bytes" "context" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + /* #nosec */ "crypto/sha1" "encoding/json" @@ -107,7 +110,6 @@ type InstalledAppService interface { type InstalledAppServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository2.InstalledAppRepository - chartTemplateService util.ChartTemplateService repositoryService repository.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository5.EnvironmentRepository @@ -137,11 +139,11 @@ type InstalledAppServiceImpl struct { k8sCommonService k8s.K8sCommonService k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig + gitOpsConfigReadService config.GitOpsConfigReadService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository, - chartTemplateService util.ChartTemplateService, repositoryService repository.ServiceClient, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, @@ -161,11 +163,11 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, - acdConfig *argocdServer.ACDConfig) (*InstalledAppServiceImpl, error) { + acdConfig *argocdServer.ACDConfig, + gitOpsConfigReadService config.GitOpsConfigReadService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, - chartTemplateService: chartTemplateService, repositoryService: repositoryService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, @@ -195,6 +197,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, k8sCommonService: k8sCommonService, k8sApplicationService: k8sApplicationService, acdConfig: acdConfig, + gitOpsConfigReadService: gitOpsConfigReadService, } err := impl.Subscribe() if err != nil { @@ -383,7 +386,7 @@ func (impl InstalledAppServiceImpl) createChartGroupEntryObject(installAppVersio } func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion *appStoreBean.InstallAppVersionDTO, ctx context.Context, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Name) - chartGitAttr := &util.ChartGitAttribute{} + chartGitAttr := &commonBean.ChartGitAttribute{} if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || installedAppVersion.Status == appStoreBean.ENQUEUED || installedAppVersion.Status == appStoreBean.QUE_ERROR || @@ -472,19 +475,15 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion impl.logger.Errorw("fetching error", "err", err) return nil, err } - gitOpsConfigBitbucket, err := impl.gitOpsRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - gitOpsConfigBitbucket.BitBucketProjectKey = "" - } else { - return nil, err - } + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return nil, err } config := &bean2.GitOpsConfigDto{ GitRepoName: installedAppVersion.GitOpsRepoName, - BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketProjectKey, - BitBucketProjectKey: gitOpsConfigBitbucket.BitBucketProjectKey, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, } repoUrl, err := impl.gitFactory.Client.GetRepoUrl(config) if err != nil { diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index 9716abb607..c317353f48 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -4,6 +4,7 @@ import ( "context" "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "net/http" "time" @@ -23,7 +24,7 @@ import ( ) type AppStoreDeploymentHelmService interface { - InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) @@ -36,7 +37,7 @@ type AppStoreDeploymentHelmService interface { DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error - UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error + UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error } type AppStoreDeploymentHelmServiceImpl struct { @@ -64,7 +65,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ } } -func (impl AppStoreDeploymentHelmServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { +func (impl AppStoreDeploymentHelmServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { err := impl.updateApplicationWithChartInfo(ctx, installAppVersionRequest.InstalledAppId, installAppVersionRequest.AppStoreVersion, installAppVersionRequest.ValuesOverrideYaml, installedAppVersionHistoryId) if err != nil { impl.Logger.Errorw("error in updating helm app", "err", err) @@ -73,7 +74,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) UpdateChartInfo(installAppVersionR return nil } -func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { @@ -476,6 +477,6 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateInstalledAppAndPipelineStat // TODO: Need to refactor this,refer below reason // This is being done as in ea mode wire argocd service is being binded to helmServiceImpl due to which we are restricted to implement this here. // RefreshAndUpdateACDApp this will update chart info in acd app if required in case of mono repo migration and will refresh argo app -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { +func (impl *AppStoreDeploymentHelmServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { return errors.New("this is not implemented") } diff --git a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go index 3b39254642..9bfcf39a40 100644 --- a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "net/http" "strings" "time" @@ -18,7 +19,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/constants" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/status" @@ -43,7 +43,7 @@ import ( type AppStoreDeploymentArgoCdService interface { //InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) - InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) GetAppStatus(installedAppAndEnvDetails repository.InstalledAppAndEnvDetails, w http.ResponseWriter, r *http.Request, token string) (string, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) @@ -56,8 +56,8 @@ type AppStoreDeploymentArgoCdService interface { DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error - UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error - UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error + UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error + UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error } type AppStoreDeploymentArgoCdServiceImpl struct { @@ -67,12 +67,10 @@ type AppStoreDeploymentArgoCdServiceImpl struct { chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository installedAppRepository repository.InstalledAppRepository installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory argoUserService argo.ArgoUserService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService helmAppService client.HelmAppService - gitOpsConfigRepository repository3.GitOpsConfigRepository appStatusService appStatus.AppStatusService pipelineStatusTimelineService status.PipelineStatusTimelineService userService user.UserService @@ -84,9 +82,9 @@ type AppStoreDeploymentArgoCdServiceImpl struct { func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, acdClient application2.ServiceClient, chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository, - installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, chartTemplateService util.ChartTemplateService, + installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - helmAppService client.HelmAppService, gitOpsConfigRepository repository3.GitOpsConfigRepository, appStatusService appStatus.AppStatusService, + helmAppService client.HelmAppService, appStatusService appStatus.AppStatusService, pipelineStatusTimelineService status.PipelineStatusTimelineService, userService user.UserService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, @@ -99,12 +97,10 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD chartGroupDeploymentRepository: chartGroupDeploymentRepository, installedAppRepository: installedAppRepository, installedAppRepositoryHistory: installedAppRepositoryHistory, - chartTemplateService: chartTemplateService, gitFactory: gitFactory, argoUserService: argoUserService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, helmAppService: helmAppService, - gitOpsConfigRepository: gitOpsConfigRepository, appStatusService: appStatusService, pipelineStatusTimelineService: pipelineStatusTimelineService, userService: userService, @@ -116,7 +112,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD } // UpdateAndSyncACDApps this will update chart info in acd app if required in case of mono repo migration and will refresh argo app -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { +func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { if isMonoRepoMigrationRequired { // update repo details on ArgoCD as repo is changed err := impl.UpdateChartInfo(installAppVersionRequest, ChartGitAttribute, 0, ctx) @@ -154,7 +150,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateAndSyncACDApps(installAppV } // UpdateChartInfo this will update chart info in acd app, needed when repo for an app is changed -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *util.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { +func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { installAppVersionRequest, err := impl.patchAcdApp(ctx, installAppVersionRequest, ChartGitAttribute) if err != nil { return err @@ -187,7 +183,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) SaveTimelineForACDHelmApps(insta return timelineErr } -func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest, err := impl.appStoreDeploymentFullModeService.AppStoreDeployOperationACD(installAppVersionRequest, chartGitAttr, ctx, tx) if err != nil { @@ -635,7 +631,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledApp(ctx context.C impl.Logger.Errorw("error in creating timeline status for deployment initiation for update of installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId) } //update values yaml in chart - installAppVersionRequest, err = impl.updateValuesYaml(environment, installedAppVersion, installAppVersionRequest, tx) + installAppVersionRequest, err = impl.updateValuesYaml(installAppVersionRequest, tx) if err != nil { impl.Logger.Errorw("error while commit values to git", "error", err) noTargetFound, _ := impl.appStoreDeploymentCommonService.ParseGitRepoErrorResponse(err) @@ -658,7 +654,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledApp(ctx context.C return installAppVersionRequest, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *util.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() //registerInArgo @@ -684,8 +680,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, return installAppVersionRequest, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYaml(environment *clusterRepository.Environment, installedAppVersion *repository.InstalledAppVersions, - installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 9939447811..4a9430fc46 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -67,6 +67,8 @@ type ChartService interface { PatchEnvOverrides(values json.RawMessage, oldChartType string, newChartType string) (json.RawMessage, error) ChartRefAutocompleteForAppOrEnv(appId int, envId int) (*bean2.ChartRefAutocompleteResponse, error) + + UpdateGitRepoUrlInCharts(appId int, repoUrl, chartLocation string, userId int32) error } type ChartServiceImpl struct { @@ -197,7 +199,7 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context if err != nil { return nil, err } - chartValues, _, err := impl.chartTemplateService.FetchValuesFromReferenceChart(chartMeta, refChart, templateName, templateRequest.UserId, pipelineStrategyPath) + chartValues, err := impl.chartTemplateService.FetchValuesFromReferenceChart(chartMeta, refChart, templateName, templateRequest.UserId, pipelineStrategyPath) if err != nil { return nil, err } @@ -320,7 +322,7 @@ func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest Template if err != nil { return nil, err } - chartValues, _, err := impl.chartTemplateService.FetchValuesFromReferenceChart(chartMeta, refChart, templateName, templateRequest.UserId, pipelineStrategyPath) + chartValues, err := impl.chartTemplateService.FetchValuesFromReferenceChart(chartMeta, refChart, templateName, templateRequest.UserId, pipelineStrategyPath) if err != nil { return nil, err } @@ -819,3 +821,23 @@ func (impl ChartServiceImpl) CheckIfChartRefUserUploadedByAppId(id int) (bool, e } return chartData.UserUploaded, err } + +func (impl *ChartServiceImpl) UpdateGitRepoUrlInCharts(appId int, repoUrl, chartLocation string, userId int32) error { + charts, err := impl.chartRepository.FindActiveChartsByAppId(appId) + if err != nil && pg.ErrNoRows != err { + return err + } + for _, ch := range charts { + if len(ch.GitRepoUrl) == 0 { + ch.GitRepoUrl = repoUrl + ch.ChartLocation = chartLocation + ch.UpdatedOn = time.Now() + ch.UpdatedBy = userId + err = impl.chartRepository.Update(ch) + if err != nil { + return err + } + } + } + return nil +} diff --git a/pkg/commonService/CommonService.go b/pkg/commonService/CommonService.go index c60e37d0de..4569dad013 100644 --- a/pkg/commonService/CommonService.go +++ b/pkg/commonService/CommonService.go @@ -40,7 +40,6 @@ type CommonServiceImpl struct { logger *zap.SugaredLogger chartRepository chartRepoRepository.ChartRepository environmentConfigRepository chartConfig.EnvConfigOverrideRepository - gitOpsRepository repository.GitOpsConfigRepository dockerReg dockerRegistryRepository.DockerArtifactStoreRepository attributeRepo repository.AttributesRepository gitProviderRepository repository.GitProviderRepository @@ -52,7 +51,6 @@ type CommonServiceImpl struct { func NewCommonServiceImpl(logger *zap.SugaredLogger, chartRepository chartRepoRepository.ChartRepository, environmentConfigRepository chartConfig.EnvConfigOverrideRepository, - gitOpsRepository repository.GitOpsConfigRepository, dockerReg dockerRegistryRepository.DockerArtifactStoreRepository, attributeRepo repository.AttributesRepository, gitProviderRepository repository.GitProviderRepository, @@ -62,7 +60,6 @@ func NewCommonServiceImpl(logger *zap.SugaredLogger, logger: logger, chartRepository: chartRepository, environmentConfigRepository: environmentConfigRepository, - gitOpsRepository: gitOpsRepository, dockerReg: dockerReg, attributeRepo: attributeRepo, gitProviderRepository: gitProviderRepository, diff --git a/pkg/deployment/gitOps/common/bean/bean.go b/pkg/deployment/gitOps/common/bean/bean.go new file mode 100644 index 0000000000..4241070a37 --- /dev/null +++ b/pkg/deployment/gitOps/common/bean/bean.go @@ -0,0 +1,6 @@ +package bean + +// TODO : rename +type ChartGitAttribute struct { + RepoUrl, ChartLocation string +} diff --git a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go new file mode 100644 index 0000000000..6daf96c6d3 --- /dev/null +++ b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go @@ -0,0 +1,133 @@ +package config + +import ( + "fmt" + bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/pkg/auth/user" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config/bean" + "github.com/devtron-labs/devtron/util" + "github.com/go-pg/pg" + "go.uber.org/zap" + "regexp" + "strings" +) + +type GitOpsConfigReadService interface { + IsGitOpsConfigured() (bool, error) + GetUserEmailIdAndNameForGitOpsCommit(userId int32) (string, string) + GetGitOpsRepoName(appName string) string + GetGitOpsRepoNameFromUrl(gitRepoUrl string) string + GetBitbucketMetadata() (*bean.BitbucketProviderMetadata, error) + GetGitOpsConfigActive() (*bean2.GitOpsConfigDto, error) +} + +type GitOpsConfigReadServiceImpl struct { + logger *zap.SugaredLogger + gitOpsRepository repository.GitOpsConfigRepository + userService user.UserService + globalEnvVariables *util.GlobalEnvVariables +} + +func NewGitOpsConfigReadServiceImpl(logger *zap.SugaredLogger, + gitOpsRepository repository.GitOpsConfigRepository, + userService user.UserService, + globalEnvVariables *util.GlobalEnvVariables) *GitOpsConfigReadServiceImpl { + return &GitOpsConfigReadServiceImpl{ + logger: logger, + gitOpsRepository: gitOpsRepository, + userService: userService, + globalEnvVariables: globalEnvVariables, + } +} + +func (impl *GitOpsConfigReadServiceImpl) IsGitOpsConfigured() (bool, error) { + isGitOpsConfigured := false + gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) + return false, err + } + if gitOpsConfig != nil && gitOpsConfig.Id > 0 { + isGitOpsConfigured = true + } + return isGitOpsConfigured, nil +} + +func (impl *GitOpsConfigReadServiceImpl) GetUserEmailIdAndNameForGitOpsCommit(userId int32) (string, string) { + emailId := bean.GitOpsCommitDefaultEmailId + name := bean.GitOpsCommitDefaultName + //getting emailId associated with user + userEmail, err := impl.userService.GetEmailById(userId) + if err != nil { + impl.logger.Errorw("error in getting user info by id", "err", err, "id", userId) + } + //TODO: export constant in user bean + if userEmail != "admin" && userEmail != "system" && len(userEmail) > 0 { + emailId = userEmail + } else { + emailIdGitOps, err := impl.gitOpsRepository.GetEmailIdFromActiveGitOpsConfig() + if err != nil { + impl.logger.Errorw("error in getting emailId from active gitOps config", "err", err) + } else if len(emailIdGitOps) > 0 { + emailId = emailIdGitOps + } + } + //we are getting name from emailId(replacing special characters in with space) + emailComponents := strings.Split(emailId, "@") + regex, _ := regexp.Compile(`[^\w]`) + if regex != nil { + name = regex.ReplaceAllString(emailComponents[0], " ") + } + return emailId, name +} + +func (impl *GitOpsConfigReadServiceImpl) GetGitOpsRepoName(appName string) string { + var repoName string + if len(impl.globalEnvVariables.GitOpsRepoPrefix) == 0 { + repoName = appName + } else { + repoName = fmt.Sprintf("%s-%s", impl.globalEnvVariables.GitOpsRepoPrefix, appName) + } + return repoName +} + +func (impl *GitOpsConfigReadServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) string { + gitRepoUrl = gitRepoUrl[strings.LastIndex(gitRepoUrl, "/")+1:] + gitRepoUrl = strings.ReplaceAll(gitRepoUrl, ".git", "") + return gitRepoUrl +} + +func (impl *GitOpsConfigReadServiceImpl) GetBitbucketMetadata() (*bean.BitbucketProviderMetadata, error) { + metadata := &bean.BitbucketProviderMetadata{} + gitOpsConfigBitbucket, err := impl.gitOpsRepository.GetGitOpsConfigByProvider(bean.BITBUCKET_PROVIDER) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error in fetching gitOps bitbucket config", "err", err) + return nil, err + } + if gitOpsConfigBitbucket != nil { + metadata.BitBucketWorkspaceId = gitOpsConfigBitbucket.BitBucketWorkspaceId + metadata.BitBucketProjectKey = gitOpsConfigBitbucket.BitBucketProjectKey + } + return metadata, nil +} + +func (impl *GitOpsConfigReadServiceImpl) GetGitOpsConfigActive() (*bean2.GitOpsConfigDto, error) { + model, err := impl.gitOpsRepository.GetGitOpsConfigActive() + if err != nil { + impl.logger.Errorw("error, GetGitOpsConfigActive", "err", err) + return nil, err + } + config := &bean2.GitOpsConfigDto{ + Id: model.Id, + Provider: model.Provider, + GitHubOrgId: model.GitHubOrgId, + GitLabGroupId: model.GitLabGroupId, + Active: model.Active, + UserId: model.CreatedBy, + AzureProjectName: model.AzureProject, + BitBucketWorkspaceId: model.BitBucketWorkspaceId, + BitBucketProjectKey: model.BitBucketProjectKey, + } + return config, err +} diff --git a/pkg/deployment/gitOps/config/bean/bean.go b/pkg/deployment/gitOps/config/bean/bean.go new file mode 100644 index 0000000000..8e6a43a51c --- /dev/null +++ b/pkg/deployment/gitOps/config/bean/bean.go @@ -0,0 +1,14 @@ +package bean + +const ( + GitOpsCommitDefaultEmailId = "devtron-bot@devtron.ai" + GitOpsCommitDefaultName = "devtron bot" +) + +// TODO: remove below object and its related methods to eliminate provider specific signature +type BitbucketProviderMetadata struct { + BitBucketWorkspaceId string + BitBucketProjectKey string +} + +const BITBUCKET_PROVIDER = "BITBUCKET_CLOUD" diff --git a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go new file mode 100644 index 0000000000..f956e862e8 --- /dev/null +++ b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go @@ -0,0 +1,316 @@ +package remote + +import ( + "fmt" + bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/internal/util" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote/bean" + dirCopy "github.com/otiai10/copy" + "go.uber.org/zap" + "k8s.io/helm/pkg/proto/hapi/chart" + "os" + "path/filepath" + "regexp" + "sigs.k8s.io/yaml" +) + +type GitOpsRemoteOperationService interface { + CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, + version string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error) + PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, + tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) + CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error + CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, + chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) + GitPull(clonedDir string, repoUrl string, appStoreName string) error +} + +type GitOpsRemoteOperationServiceImpl struct { + logger *zap.SugaredLogger + gitFactory *util.GitFactory + gitOpsConfigReadService config.GitOpsConfigReadService + chartTemplateService util.ChartTemplateService +} + +func NewGitOpsRemoteOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *util.GitFactory, + gitOpsConfigReadService config.GitOpsConfigReadService, + chartTemplateService util.ChartTemplateService) *GitOpsRemoteOperationServiceImpl { + return &GitOpsRemoteOperationServiceImpl{ + logger: logger, + gitOpsConfigReadService: gitOpsConfigReadService, + chartTemplateService: chartTemplateService, + } + +} + +func (impl *GitOpsRemoteOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, + version string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error) { + //baseTemplateName replace whitespace + space := regexp.MustCompile(`\s+`) + gitOpsRepoName = space.ReplaceAllString(gitOpsRepoName, "-") + + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() + if err != nil { + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return nil, err + } + //getting user name & emailId for commit author data + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) + gitRepoRequest := &bean2.GitOpsConfigDto{ + GitRepoName: gitOpsRepoName, + Description: fmt.Sprintf("helm chart for " + gitOpsRepoName), + Username: userName, + UserEmailId: userEmailId, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, + } + repoUrl, _, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) + for _, err := range detailedError.StageErrorMap { + if err != nil { + impl.logger.Errorw("error in creating git project", "name", gitOpsRepoName, "err", err) + return nil, err + } + } + return &commonBean.ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join(baseTemplateName, version)}, nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, + tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) { + chartDir := fmt.Sprintf("%s-%s", gitOpsRepoName, impl.chartTemplateService.GetDir()) + clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) + if _, err := os.Stat(clonedDir); os.IsNotExist(err) { + clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return err + } + } else { + err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) + if err != nil { + impl.logger.Errorw("error in pulling git repo", "url", repoUrl, "err", err) + return err + } + } + + dir := filepath.Join(clonedDir, referenceTemplate, version) + pushChartToGit := true + + //if chart already exists don't overrides it by reference template + if _, err := os.Stat(dir); os.IsNotExist(err) { + err = os.MkdirAll(dir, os.ModePerm) + if err != nil { + impl.logger.Errorw("error in making dir", "err", err) + return err + } + err = dirCopy.Copy(tempReferenceTemplateDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return err + } + } else { + // auto-healing : data corruption fix - sometimes reference chart contents are not pushed in git-ops repo. + // copying content from reference template dir to cloned dir (if Chart.yaml file is not found) + // if Chart.yaml file is not found, we are assuming here that reference chart contents are not pushed in git-ops repo + if _, err := os.Stat(filepath.Join(dir, "Chart.yaml")); os.IsNotExist(err) { + impl.logger.Infow("auto-healing: Chart.yaml not found in cloned repo from git-ops. copying content", "from", tempReferenceTemplateDir, "to", dir) + err = dirCopy.Copy(tempReferenceTemplateDir, dir) + if err != nil { + impl.logger.Errorw("error copying content in auto-healing", "err", err) + return err + } + } else { + // chart exists on git, hence not performing first commit + pushChartToGit = false + } + } + + // if push needed, then only push + if pushChartToGit { + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) + commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + impl.logger.Warn("re-trying, taking pull and then push again") + err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) + if err != nil { + return err + } + err = dirCopy.Copy(tempReferenceTemplateDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return err + } + commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + return err + } + } + impl.logger.Debugw("template committed", "url", repoUrl, "commit", commit) + } + + defer impl.chartTemplateService.CleanDir(clonedDir) + return nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error { + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) + gitOpsConfig, err := impl.gitOpsConfigReadService.GetGitOpsConfigActive() + if err != nil { + impl.logger.Errorw("error in getting active gitOps config", "err", err) + return err + } + //updating user email and name in request + if gitOpsConfig != nil { + gitOpsConfig.UserEmailId = userEmailId + gitOpsConfig.Username = userName + gitOpsConfig.GitRepoName = gitOpsRepoName + } + _, err = impl.gitFactory.Client.CreateReadme(gitOpsConfig) + if err != nil { + return err + } + return nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, + chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) { + chartMetaData.ApiVersion = "v2" // ensure always v2 + dir := impl.chartTemplateService.GetDir() + chartDir := filepath.Join(util.ChartWorkingDirPath, dir) + impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) + err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling + if err != nil { + impl.logger.Errorw("err in creating dir", "dir", chartDir, "err", err) + return "", nil, err + } + defer impl.chartTemplateService.CleanDir(chartDir) + err = dirCopy.Copy(refChartLocation, chartDir) + + if err != nil { + impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) + return "", nil, err + } + archivePath, valuesYaml, err := impl.chartTemplateService.PackageChart(chartDir, chartMetaData) + if err != nil { + impl.logger.Errorw("error in creating archive", "err", err) + return "", nil, err + } + + chartGitAttr, err := impl.createAndPushToGitChartProxy(chartMetaData.Name, chartDir, envName, chartProxyReq) + if err != nil { + impl.logger.Errorw("error in pushing chart to git ", "path", archivePath, "err", err) + return "", nil, err + } + if valuesYaml == "" { + valuesYaml = "{}" + } else { + valuesYamlByte, err := yaml.YAMLToJSON([]byte(valuesYaml)) + if err != nil { + return "", nil, err + } + valuesYaml = string(valuesYamlByte) + } + return valuesYaml, chartGitAttr, nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) createAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, + chartProxyReq *bean.ChartProxyReqDto) (chartGitAttribute *commonBean.ChartGitAttribute, err error) { + //baseTemplateName replace whitespace + space := regexp.MustCompile(`\s+`) + appStoreName = space.ReplaceAllString(appStoreName, "-") + + if len(chartProxyReq.GitOpsRepoName) == 0 { + //here git ops repo will be the app name, to breaking the mono repo structure + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(chartProxyReq.AppName) + chartProxyReq.GitOpsRepoName = gitOpsRepoName + } + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() + if err != nil { + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return nil, err + } + //getting user name & emailId for commit author data + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(chartProxyReq.UserId) + gitRepoRequest := &bean2.GitOpsConfigDto{ + GitRepoName: chartProxyReq.GitOpsRepoName, + Description: "helm chart for " + chartProxyReq.GitOpsRepoName, + Username: userName, + UserEmailId: userEmailId, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, + } + repoUrl, _, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) + for _, err := range detailedError.StageErrorMap { + if err != nil { + impl.logger.Errorw("error in creating git project", "name", chartProxyReq.GitOpsRepoName, "err", err) + return nil, err + } + } + + chartDir := fmt.Sprintf("%s-%s", chartProxyReq.AppName, impl.chartTemplateService.GetDir()) + clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) + if _, err := os.Stat(clonedDir); os.IsNotExist(err) { + clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return nil, err + } + } else { + err = impl.GitPull(clonedDir, repoUrl, appStoreName) + if err != nil { + return nil, err + } + } + + acdAppName := fmt.Sprintf("%s-%s", chartProxyReq.AppName, envName) + dir := filepath.Join(clonedDir, acdAppName) + err = os.MkdirAll(dir, os.ModePerm) + if err != nil { + impl.logger.Errorw("error in making dir", "err", err) + return nil, err + } + err = dirCopy.Copy(tmpChartLocation, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, err + } + commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + impl.logger.Warn("re-trying, taking pull and then push again") + err = impl.GitPull(clonedDir, repoUrl, acdAppName) + if err != nil { + return nil, err + } + err = dirCopy.Copy(tmpChartLocation, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, err + } + commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + return nil, err + } + } + impl.logger.Debugw("template committed", "url", repoUrl, "commit", commit) + defer impl.chartTemplateService.CleanDir(clonedDir) + return &commonBean.ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join("", acdAppName)}, nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error { + err := impl.gitFactory.GitService.Pull(clonedDir) //TODO check for local repo exists before clone + if err != nil { + impl.logger.Errorw("error in pulling git", "clonedDir", clonedDir, "err", err) + _, err := impl.gitFactory.GitService.Clone(repoUrl, appStoreName) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return err + } + return nil + } + return nil +} diff --git a/pkg/deployment/gitOps/remote/bean/bean.go b/pkg/deployment/gitOps/remote/bean/bean.go new file mode 100644 index 0000000000..361b0ec78c --- /dev/null +++ b/pkg/deployment/gitOps/remote/bean/bean.go @@ -0,0 +1,7 @@ +package bean + +type ChartProxyReqDto struct { + GitOpsRepoName string `json:"gitOpsRepoName"` + AppName string `json:"appName,omitempty"` + UserId int32 `json:"-"` +} diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go new file mode 100644 index 0000000000..7d5378d238 --- /dev/null +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -0,0 +1,15 @@ +package gitOps + +import ( + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/google/wire" +) + +var GitOpsWireSet = wire.NewSet( + config.NewGitOpsConfigReadServiceImpl, + wire.Bind(new(config.GitOpsConfigReadService), new(*config.GitOpsConfigReadServiceImpl)), + + remote.NewGitOpsRemoteOperationServiceImpl, + wire.Bind(new(remote.GitOpsRemoteOperationService), new(*remote.GitOpsRemoteOperationServiceImpl)), +) diff --git a/pkg/deployment/wire_deployment.go b/pkg/deployment/wire_deployment.go new file mode 100644 index 0000000000..5a959cd701 --- /dev/null +++ b/pkg/deployment/wire_deployment.go @@ -0,0 +1,14 @@ +package deployment + +import ( + "github.com/devtron-labs/devtron/pkg/deployment/gitOps" + "github.com/devtron-labs/devtron/pkg/deployment/manifest" + "github.com/google/wire" +) + +// TODO: add separate wire sets for full and ea mode when reached that level of transparency + +var DeploymentWireSet = wire.NewSet( + gitOps.GitOpsWireSet, + manifest.DeploymentManifestWireSet, +) diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index ed3c6bd27b..3b295f3a65 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -22,6 +22,8 @@ import ( "encoding/json" "fmt" util4 "github.com/devtron-labs/common-lib/utils/k8s" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config/bean" "math/rand" "net/http" "net/url" @@ -58,23 +60,22 @@ type GitOpsConfigService interface { GetGitOpsConfigById(id int) (*bean2.GitOpsConfigDto, error) GetAllGitOpsConfig() ([]*bean2.GitOpsConfigDto, error) GetGitOpsConfigByProvider(provider string) (*bean2.GitOpsConfigDto, error) - GetGitOpsConfigActive() (*bean2.GitOpsConfigDto, error) } const ( - GitOpsSecretName = "devtron-gitops-secret" - DryrunRepoName = "devtron-sample-repo-dryrun-" - DeleteRepoStage = "Delete Repo" - CommitOnRestStage = "Commit On Rest" - PushStage = "Push" - CloneStage = "Clone" - GetRepoUrlStage = "Get Repo RedirectionUrl" - CreateRepoStage = "Create Repo" - CloneHttp = "Clone Http" - CreateReadmeStage = "Create Readme" - GITHUB_PROVIDER = "GITHUB" - GITLAB_PROVIDER = "GITLAB" - BITBUCKET_PROVIDER = "BITBUCKET_CLOUD" + GitOpsSecretName = "devtron-gitops-secret" + DryrunRepoName = "devtron-sample-repo-dryrun-" + DeleteRepoStage = "Delete Repo" + CommitOnRestStage = "Commit On Rest" + PushStage = "Push" + CloneStage = "Clone" + GetRepoUrlStage = "Get Repo RedirectionUrl" + CreateRepoStage = "Create Repo" + CloneHttp = "Clone Http" + CreateReadmeStage = "Create Readme" + GITHUB_PROVIDER = "GITHUB" + GITLAB_PROVIDER = "GITLAB" + AZURE_DEVOPS_PROVIDER = "AZURE_DEVOPS" BITBUCKET_API_HOST = "https://api.bitbucket.org/2.0/" ) @@ -87,36 +88,37 @@ type DetailedErrorGitOpsConfigResponse struct { } type GitOpsConfigServiceImpl struct { - randSource rand.Source - logger *zap.SugaredLogger - globalEnvVariables *util2.GlobalEnvVariables - gitOpsRepository repository.GitOpsConfigRepository - K8sUtil *util4.K8sUtil - aCDAuthConfig *util3.ACDAuthConfig - clusterService cluster.ClusterService - gitFactory *util.GitFactory - chartTemplateService util.ChartTemplateService - argoUserService argo.ArgoUserService - clusterServiceCD cluster2.ServiceClient + randSource rand.Source + logger *zap.SugaredLogger + globalEnvVariables *util2.GlobalEnvVariables + gitOpsRepository repository.GitOpsConfigRepository + K8sUtil *util4.K8sUtil + aCDAuthConfig *util3.ACDAuthConfig + clusterService cluster.ClusterService + gitFactory *util.GitFactory + argoUserService argo.ArgoUserService + clusterServiceCD cluster2.ServiceClient + gitOpsConfigReadService config.GitOpsConfigReadService } func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, globalEnvVariables *util2.GlobalEnvVariables, gitOpsRepository repository.GitOpsConfigRepository, K8sUtil *util4.K8sUtil, aCDAuthConfig *util3.ACDAuthConfig, clusterService cluster.ClusterService, - gitFactory *util.GitFactory, chartTemplateService util.ChartTemplateService, argoUserService argo.ArgoUserService, clusterServiceCD cluster2.ServiceClient) *GitOpsConfigServiceImpl { + gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, + clusterServiceCD cluster2.ServiceClient, gitOpsConfigReadService config.GitOpsConfigReadService) *GitOpsConfigServiceImpl { return &GitOpsConfigServiceImpl{ - randSource: rand.NewSource(time.Now().UnixNano()), - logger: Logger, - globalEnvVariables: globalEnvVariables, - gitOpsRepository: gitOpsRepository, - K8sUtil: K8sUtil, - aCDAuthConfig: aCDAuthConfig, - clusterService: clusterService, - gitFactory: gitFactory, - chartTemplateService: chartTemplateService, - argoUserService: argoUserService, - clusterServiceCD: clusterServiceCD, + randSource: rand.NewSource(time.Now().UnixNano()), + logger: Logger, + globalEnvVariables: globalEnvVariables, + gitOpsRepository: gitOpsRepository, + K8sUtil: K8sUtil, + aCDAuthConfig: aCDAuthConfig, + clusterService: clusterService, + gitFactory: gitFactory, + argoUserService: argoUserService, + clusterServiceCD: clusterServiceCD, + gitOpsConfigReadService: gitOpsConfigReadService, } } @@ -287,7 +289,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req request.Host = fmt.Sprintf(request.Host+"/%s", groupName) } } - if strings.ToUpper(request.Provider) == BITBUCKET_PROVIDER { + if strings.ToUpper(request.Provider) == bean.BITBUCKET_PROVIDER { request.Host = util.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId } operationComplete := false @@ -488,7 +490,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon request.Host = fmt.Sprintf(request.Host+"/%s", groupName) } } - if strings.ToUpper(request.Provider) == BITBUCKET_PROVIDER { + if strings.ToUpper(request.Provider) == bean.BITBUCKET_PROVIDER { request.Host = util.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId } operationComplete := false @@ -661,26 +663,6 @@ type KeyDto struct { Key string `json:"key,omitempty"` } -func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigActive() (*bean2.GitOpsConfigDto, error) { - model, err := impl.gitOpsRepository.GetGitOpsConfigActive() - if err != nil { - impl.logger.Errorw("GetGitOpsConfigActive, error while getting error", "err", err) - return nil, err - } - config := &bean2.GitOpsConfigDto{ - Id: model.Id, - Provider: model.Provider, - GitHubOrgId: model.GitHubOrgId, - GitLabGroupId: model.GitLabGroupId, - Active: model.Active, - UserId: model.CreatedBy, - AzureProjectName: model.AzureProject, - BitBucketWorkspaceId: model.BitBucketWorkspaceId, - BitBucketProjectKey: model.BitBucketProjectKey, - } - return config, err -} - func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsConfigDto) DetailedErrorGitOpsConfigResponse { if impl.globalEnvVariables.SkipGitOpsValidation { return DetailedErrorGitOpsConfigResponse{} @@ -702,7 +684,7 @@ func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsCo /*if strings.ToUpper(config.Provider) == GITHUB_PROVIDER { config.Host = GITHUB_HOST }*/ - if strings.ToUpper(config.Provider) == BITBUCKET_PROVIDER { + if strings.ToUpper(config.Provider) == bean.BITBUCKET_PROVIDER { config.Host = util.BITBUCKET_CLONE_BASE_URL config.BitBucketProjectKey = strings.ToUpper(config.BitBucketProjectKey) } @@ -716,7 +698,7 @@ func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsCo } appName := DryrunRepoName + util2.Generate(6) //getting user name & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(config.UserId) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(config.UserId) config.UserEmailId = userEmailId config.GitRepoName = appName repoUrl, _, detailedErrorCreateRepo := client.CreateRepository(config) diff --git a/pkg/pipeline/AppDeploymentTypeChangeManager.go b/pkg/pipeline/AppDeploymentTypeChangeManager.go index 4e12e27092..5f340c755f 100644 --- a/pkg/pipeline/AppDeploymentTypeChangeManager.go +++ b/pkg/pipeline/AppDeploymentTypeChangeManager.go @@ -29,6 +29,8 @@ import ( "github.com/devtron-labs/devtron/internal/util" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/bean" + chartService "github.com/devtron-labs/devtron/pkg/chart" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/juju/errors" "go.uber.org/zap" "strconv" @@ -55,17 +57,18 @@ type AppDeploymentTypeChangeManager interface { } type AppDeploymentTypeChangeManagerImpl struct { - logger *zap.SugaredLogger - pipelineRepository pipelineConfig.PipelineRepository - workflowDagExecutor WorkflowDagExecutor - appService app2.AppService - chartTemplateService util.ChartTemplateService - appStatusRepository appStatus.AppStatusRepository - helmAppService client.HelmAppService - application application2.ServiceClient + logger *zap.SugaredLogger + pipelineRepository pipelineConfig.PipelineRepository + workflowDagExecutor WorkflowDagExecutor + appService app2.AppService + appStatusRepository appStatus.AppStatusRepository + helmAppService client.HelmAppService + application application2.ServiceClient appArtifactManager AppArtifactManager cdPipelineConfigService CdPipelineConfigService + gitOpsConfigReadService config.GitOpsConfigReadService + chartService chartService.ChartService } func NewAppDeploymentTypeChangeManagerImpl( @@ -73,23 +76,25 @@ func NewAppDeploymentTypeChangeManagerImpl( pipelineRepository pipelineConfig.PipelineRepository, workflowDagExecutor WorkflowDagExecutor, appService app2.AppService, - chartTemplateService util.ChartTemplateService, appStatusRepository appStatus.AppStatusRepository, helmAppService client.HelmAppService, application application2.ServiceClient, appArtifactManager AppArtifactManager, - cdPipelineConfigService CdPipelineConfigService) *AppDeploymentTypeChangeManagerImpl { + cdPipelineConfigService CdPipelineConfigService, + gitOpsConfigReadService config.GitOpsConfigReadService, + chartService chartService.ChartService) *AppDeploymentTypeChangeManagerImpl { return &AppDeploymentTypeChangeManagerImpl{ logger: logger, pipelineRepository: pipelineRepository, workflowDagExecutor: workflowDagExecutor, appService: appService, - chartTemplateService: chartTemplateService, appStatusRepository: appStatusRepository, helmAppService: helmAppService, application: application, appArtifactManager: appArtifactManager, cdPipelineConfigService: cdPipelineConfigService, + gitOpsConfigReadService: gitOpsConfigReadService, + chartService: chartService, } } @@ -397,7 +402,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context successfulPipelines := make([]*bean.DeploymentChangeStatus, 0) failedPipelines := make([]*bean.DeploymentChangeStatus, 0) - isGitOpsConfigured, gitOpsConfigErr := impl.cdPipelineConfigService.IsGitopsConfigured() + isGitOpsConfigured, gitOpsConfigErr := impl.gitOpsConfigReadService.IsGitOpsConfigured() // Iterate over all the pipelines in the environment for given deployment app type for _, pipeline := range pipelines { @@ -445,7 +450,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) DeleteDeploymentApps(ctx context impl.logger.Errorw("error in registering acd app", "err", err) } if AcdRegisterErr == nil { - RepoURLUpdateErr = impl.chartTemplateService.UpdateGitRepoUrlInCharts(pipeline.AppId, chartGitAttr, userId) + RepoURLUpdateErr = impl.chartService.UpdateGitRepoUrlInCharts(pipeline.AppId, chartGitAttr.RepoUrl, chartGitAttr.ChartLocation, userId) if RepoURLUpdateErr != nil { impl.logger.Errorw("error in updating git repo url in charts", "err", err) } diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 794f7bfaac..98e9c35512 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -41,6 +41,9 @@ import ( chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -109,8 +112,7 @@ type CdPipelineConfigService interface { MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDeleted(appId int, envId int, acdToken string, pipeline *pipelineConfig.Pipeline) (bool, error) //GetEnvironmentListForAutocompleteFilter : lists environment for given configuration GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*cluster.ResourceGroupingResponse, error) - IsGitopsConfigured() (bool, error) - RegisterInACD(gitOpsRepoName string, chartGitAttr *util.ChartGitAttribute, userId int32, ctx context.Context) error + RegisterInACD(gitOpsRepoName string, chartGitAttr *commonBean.ChartGitAttribute, userId int32, ctx context.Context) error } type CdPipelineConfigServiceImpl struct { @@ -130,11 +132,9 @@ type CdPipelineConfigServiceImpl struct { clusterRepository repository2.ClusterRepository helmAppService client.HelmAppService enforcerUtil rbac.EnforcerUtil - gitOpsRepository repository.GitOpsConfigRepository pipelineStrategyHistoryService history.PipelineStrategyHistoryService chartRepository chartRepoRepository.ChartRepository resourceGroupService resourceGroup2.ResourceGroupService - chartTemplateService util.ChartTemplateService propertiesConfigService PropertiesConfigService deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager @@ -147,6 +147,8 @@ type CdPipelineConfigServiceImpl struct { buildPipelineSwitchService BuildPipelineSwitchService argoClientWrapperService argocdServer.ArgoClientWrapperService deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -156,17 +158,18 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor ciCdPipelineOrchestrator CiCdPipelineOrchestrator, appStatusRepository appStatus.AppStatusRepository, ciPipelineRepository pipelineConfig.CiPipelineRepository, prePostCdScriptHistoryService history.PrePostCdScriptHistoryService, clusterRepository repository2.ClusterRepository, helmAppService client.HelmAppService, - enforcerUtil rbac.EnforcerUtil, gitOpsRepository repository.GitOpsConfigRepository, - pipelineStrategyHistoryService history.PipelineStrategyHistoryService, + enforcerUtil rbac.EnforcerUtil, pipelineStrategyHistoryService history.PipelineStrategyHistoryService, chartRepository chartRepoRepository.ChartRepository, resourceGroupService resourceGroup2.ResourceGroupService, - chartTemplateService util.ChartTemplateService, propertiesConfigService PropertiesConfigService, + propertiesConfigService PropertiesConfigService, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, scopedVariableManager variables.ScopedVariableManager, deploymentConfig *DeploymentServiceTypeConfig, application application.ServiceClient, customTagService CustomTagService, pipelineConfigListenerService PipelineConfigListenerService, devtronAppCMCSService DevtronAppCMCSService, ciPipelineConfigService CiPipelineConfigService, buildPipelineSwitchService BuildPipelineSwitchService, argoClientWrapperService argocdServer.ArgoClientWrapperService, - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService) *CdPipelineConfigServiceImpl { + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -184,11 +187,9 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor clusterRepository: clusterRepository, helmAppService: helmAppService, enforcerUtil: enforcerUtil, - gitOpsRepository: gitOpsRepository, pipelineStrategyHistoryService: pipelineStrategyHistoryService, chartRepository: chartRepository, resourceGroupService: resourceGroupService, - chartTemplateService: chartTemplateService, propertiesConfigService: propertiesConfigService, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, @@ -201,6 +202,8 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor buildPipelineSwitchService: buildPipelineSwitchService, argoClientWrapperService: argoClientWrapperService, deployedAppMetricsService: deployedAppMetricsService, + gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -341,8 +344,11 @@ func (impl *CdPipelineConfigServiceImpl) GetCdPipelineById(pipelineId int) (cdPi func (impl *CdPipelineConfigServiceImpl) CreateCdPipelines(pipelineCreateRequest *bean.CdPipelines, ctx context.Context) (*bean.CdPipelines, error) { //Validation for checking deployment App type - isGitOpsConfigured, err := impl.IsGitopsConfigured() - + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() + if err != nil { + impl.logger.Errorw("error in checking if gitOps is configured or not", "err", err) + return nil, err + } for _, pipeline := range pipelineCreateRequest.Pipelines { // skip creation of pipeline if envId is not set if pipeline.EnvironmentId <= 0 { @@ -1500,23 +1506,6 @@ func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter return result, nil } -func (impl *CdPipelineConfigServiceImpl) IsGitopsConfigured() (bool, error) { - - isGitOpsConfigured := false - gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() - - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) - return false, err - } - if gitOpsConfig != nil && gitOpsConfig.Id > 0 { - isGitOpsConfigured = true - } - - return isGitOpsConfigured, nil - -} - func (impl *CdPipelineConfigServiceImpl) validateDeploymentAppType(pipeline *bean.CDPipelineConfigObject, deploymentConfig map[string]bool) error { // Config value doesn't exist in attribute table @@ -1600,15 +1589,14 @@ func (impl *CdPipelineConfigServiceImpl) ValidateCDPipelineRequest(pipelineCreat } -func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, chartGitAttr *util.ChartGitAttribute, userId int32, ctx context.Context) error { - +func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, chartGitAttr *commonBean.ChartGitAttribute, userId int32, ctx context.Context) error { err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error while register git repo in argo", "err", err) emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "remote repository is empty"} if strings.Contains(err.Error(), emptyRepoErrorMessage[0]) || strings.Contains(err.Error(), emptyRepoErrorMessage[1]) { // - found empty repository, create some file in repository - err := impl.chartTemplateService.CreateReadmeInGitRepo(gitOpsRepoName, userId) + err := impl.gitOpsRemoteOperationService.CreateReadmeInGitRepo(gitOpsRepoName, userId) if err != nil { impl.logger.Errorw("error in creating file in git repo", "err", err) return err @@ -1920,7 +1908,7 @@ func (impl *CdPipelineConfigServiceImpl) updateCdPipeline(ctx context.Context, p return nil } -func (impl *CdPipelineConfigServiceImpl) updateGitRepoUrlInCharts(appId int, chartGitAttribute *util.ChartGitAttribute, userId int32) error { +func (impl *CdPipelineConfigServiceImpl) updateGitRepoUrlInCharts(appId int, chartGitAttribute *commonBean.ChartGitAttribute, userId int32) error { charts, err := impl.chartRepository.FindActiveChartsByAppId(appId) if err != nil && pg.ErrNoRows != err { return err diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index dedad255b4..1eebea4b9d 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -22,6 +22,7 @@ import ( "encoding/json" errors3 "errors" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "path" @@ -182,7 +183,6 @@ type WorkflowDagExecutorImpl struct { environmentConfigRepository chartConfig.EnvConfigOverrideRepository dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil - gitOpsConfigRepository repository.GitOpsConfigRepository gitFactory *util.GitFactory acdClient application2.ServiceClient argoClientWrapperService argocdServer.ArgoClientWrapperService @@ -190,6 +190,7 @@ type WorkflowDagExecutorImpl struct { ACDConfig *argocdServer.ACDConfig deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService chartRefService chartRef.ChartRefService + gitOpsConfigReadService config.GitOpsConfigReadService } const kedaAutoscaling = "kedaAutoscaling" @@ -284,7 +285,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository chartConfig.EnvConfigOverrideRepository, dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, - gitOpsConfigRepository repository.GitOpsConfigRepository, gitFactory *util.GitFactory, acdClient application2.ServiceClient, argoClientWrapperService argocdServer.ArgoClientWrapperService, @@ -292,7 +292,8 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi customTagService CustomTagService, ACDConfig *argocdServer.ACDConfig, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, - chartRefService chartRef.ChartRefService) *WorkflowDagExecutorImpl { + chartRefService chartRef.ChartRefService, + gitOpsConfigReadService config.GitOpsConfigReadService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, @@ -354,7 +355,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository: environmentConfigRepository, dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, - gitOpsConfigRepository: gitOpsConfigRepository, gitFactory: gitFactory, acdClient: acdClient, argoClientWrapperService: argoClientWrapperService, @@ -362,6 +362,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi ACDConfig: ACDConfig, deployedAppMetricsService: deployedAppMetricsService, chartRefService: chartRefService, + gitOpsConfigReadService: gitOpsConfigReadService, } config, err := types.GetCdConfig() if err != nil { @@ -4140,10 +4141,10 @@ func (impl *WorkflowDagExecutorImpl) mergeAndSave(envOverride *chartConfig.EnvCo commitHash := "" commitTime := time.Time{} if util.IsAcdApp(pipeline.DeploymentAppType) { - chartRepoName := impl.chartTemplateService.GetGitOpsRepoNameFromUrl(envOverride.Chart.GitRepoUrl) + chartRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(envOverride.Chart.GitRepoUrl) _, span = otel.Tracer("orchestrator").Start(ctx, "chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit") //getting username & emailId for commit author data - userEmailId, userName := impl.chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit(overrideRequest.UserId) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(overrideRequest.UserId) span.End() chartGitAttr := &util.ChartConfig{ FileName: fmt.Sprintf("_%d-values.yaml", envOverride.TargetEnvironment), @@ -4155,15 +4156,12 @@ func (impl *WorkflowDagExecutorImpl) mergeAndSave(envOverride *chartConfig.EnvCo UserName: userName, UserEmailId: userEmailId, } - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(util.BITBUCKET_PROVIDER) + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - } else { - return 0, 0, "", err - } + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return 0, 0, "", err } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: gitOpsConfigBitbucket.BitBucketWorkspaceId} + gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} _, span = otel.Tracer("orchestrator").Start(ctx, "gitFactory.Client.CommitValues") commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) span.End() diff --git a/wire_gen.go b/wire_gen.go index b010214e4a..420e078477 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -101,6 +101,8 @@ import ( "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" repository11 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" @@ -167,11 +169,11 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - config, err := sql.GetConfig() + sqlConfig, err := sql.GetConfig() if err != nil { return nil, err } - db, err := sql.NewDbConnection(config, sugaredLogger) + db, err := sql.NewDbConnection(sqlConfig, sugaredLogger) if err != nil { return nil, err } @@ -299,17 +301,8 @@ func InitializeApp() (*App, error) { chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) gitProviderRepositoryImpl := repository.NewGitProviderRepositoryImpl(db) - commonServiceImpl := commonService.NewCommonServiceImpl(sugaredLogger, chartRepositoryImpl, envConfigOverrideRepositoryImpl, gitOpsConfigRepositoryImpl, dockerArtifactStoreRepositoryImpl, attributesRepositoryImpl, gitProviderRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl) - gitCliUtil := util.NewGitCliUtil(sugaredLogger) - gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) - if err != nil { - return nil, err - } - globalEnvVariables, err := util2.GetGlobalEnvVariables() - if err != nil { - return nil, err - } - chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger, gitFactory, globalEnvVariables, gitOpsConfigRepositoryImpl, userRepositoryImpl, chartRepositoryImpl) + commonServiceImpl := commonService.NewCommonServiceImpl(sugaredLogger, chartRepositoryImpl, envConfigOverrideRepositoryImpl, dockerArtifactStoreRepositoryImpl, attributesRepositoryImpl, gitProviderRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl) + chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) devtronSecretConfig, err := util2.GetDevtronSecretName() if err != nil { return nil, err @@ -334,6 +327,10 @@ func InitializeApp() (*App, error) { enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) + globalEnvVariables, err := util2.GetGlobalEnvVariables() + if err != nil { + return nil, err + } scopedVariableRepositoryImpl := repository6.NewScopedVariableRepository(db, sugaredLogger) qualifiersMappingRepositoryImpl, err := resourceQualifiers.NewQualifiersMappingRepositoryImpl(db, sugaredLogger) if err != nil { @@ -373,7 +370,14 @@ func InitializeApp() (*App, error) { Logger: sugaredLogger, } chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl, utilMergeUtil) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl) + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) + gitCliUtil := util.NewGitCliUtil(sugaredLogger) + gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) + if err != nil { + return nil, err + } + gitOpsRemoteOperationServiceImpl := remote.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) validate, err := util.IntValidator() if err != nil { return nil, err @@ -432,7 +436,7 @@ func InitializeApp() (*App, error) { pipelineStrategyHistoryRepositoryImpl := repository8.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) manifestPushConfigRepositoryImpl := repository9.NewManifestPushConfigRepository(sugaredLogger, db) - gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, chartTemplateServiceImpl, gitOpsConfigRepositoryImpl, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl) + gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) genericNoteRepositoryImpl := repository12.NewGenericNoteRepositoryImpl(db) @@ -448,7 +452,7 @@ func InitializeApp() (*App, error) { repositoryServiceClientImpl := repository13.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitOpsConfigRepositoryImpl, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) @@ -489,15 +493,15 @@ func InitializeApp() (*App, error) { return nil, err } devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, gitOpsConfigRepositoryImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, chartTemplateServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) - appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, chartTemplateServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl) + chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) + appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl, chartServiceImpl) devtronAppConfigServiceImpl := pipeline.NewDevtronAppConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, appRepositoryImpl, pipelineRepositoryImpl, resourceGroupServiceImpl, enforcerUtilImpl, ciMaterialConfigServiceImpl) pipelineBuilderImpl := pipeline.NewPipelineBuilderImpl(sugaredLogger, materialRepositoryImpl, chartRepositoryImpl, ciPipelineConfigServiceImpl, ciMaterialConfigServiceImpl, appArtifactManagerImpl, devtronAppCMCSServiceImpl, devtronAppStrategyServiceImpl, appDeploymentTypeChangeManagerImpl, cdPipelineConfigServiceImpl, devtronAppConfigServiceImpl) deploymentTemplateValidationServiceImpl := deploymentTemplate.NewDeploymentTemplateValidationServiceImpl(sugaredLogger, chartRefServiceImpl, scopedVariableManagerImpl) - chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) dbMigrationServiceImpl := pipeline.NewDbMogrationService(sugaredLogger, dbMigrationConfigRepositoryImpl) ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) ciLogServiceImpl, err := pipeline.NewCiLogServiceImpl(sugaredLogger, ciServiceImpl, k8sUtil) @@ -513,7 +517,7 @@ func InitializeApp() (*App, error) { deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, userServiceImpl, cdWorkflowRepositoryImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, resourceGroupServiceImpl, imageTaggingServiceImpl, k8sUtil, workflowServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, customTagServiceImpl, argoClientWrapperServiceImpl, appServiceConfig, acdConfig) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) - appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, materialRepositoryImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, ciTemplateOverrideRepositoryImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineConfigServiceImpl) + appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, ciPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl) deploymentTemplateRepositoryImpl := repository.NewDeploymentTemplateRepositoryImpl(db, sugaredLogger) deploymentTemplateServiceImpl := generateManifest.NewDeploymentTemplateServiceImpl(sugaredLogger, chartServiceImpl, appListingServiceImpl, appListingRepositoryImpl, deploymentTemplateRepositoryImpl, helmAppServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, helmAppClientImpl, k8sUtil, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, chartRefServiceImpl) imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) @@ -540,16 +544,16 @@ func InitializeApp() (*App, error) { } tokenCache := util3.NewTokenCache(sugaredLogger, acdAuthConfig, userAuthServiceImpl) chartGroupDeploymentRepositoryImpl := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigRepositoryImpl) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, chartTemplateServiceImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, applicationServiceClientImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, globalEnvVariables, installedAppRepositoryImpl, tokenCache, argoUserServiceImpl, gitOpsConfigRepositoryImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, chartTemplateServiceImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, gitOpsConfigRepositoryImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, attributesServiceImpl, serviceDeploymentServiceTypeConfig, chartTemplateServiceImpl, acdConfig) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -559,7 +563,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartTemplateServiceImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig) + installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl) if err != nil { return nil, err } @@ -697,8 +701,8 @@ func InitializeApp() (*App, error) { imageScanRouterImpl := router.NewImageScanRouterImpl(imageScanRestHandlerImpl) policyRestHandlerImpl := restHandler.NewPolicyRestHandlerImpl(sugaredLogger, policyServiceImpl, userServiceImpl, userAuthServiceImpl, enforcerImpl, enforcerUtilImpl, environmentServiceImpl) policyRouterImpl := router.NewPolicyRouterImpl(policyRestHandlerImpl) - gitOpsConfigServiceImpl := gitops.NewGitOpsConfigServiceImpl(sugaredLogger, globalEnvVariables, gitOpsConfigRepositoryImpl, k8sUtil, acdAuthConfig, clusterServiceImplExtended, environmentServiceImpl, versionServiceImpl, gitFactory, chartTemplateServiceImpl, argoUserServiceImpl, serviceClientImpl) - gitOpsConfigRestHandlerImpl := restHandler.NewGitOpsConfigRestHandlerImpl(sugaredLogger, gitOpsConfigServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, gitOpsConfigRepositoryImpl) + gitOpsConfigServiceImpl := gitops.NewGitOpsConfigServiceImpl(sugaredLogger, globalEnvVariables, gitOpsConfigRepositoryImpl, k8sUtil, acdAuthConfig, clusterServiceImplExtended, gitFactory, argoUserServiceImpl, serviceClientImpl, gitOpsConfigReadServiceImpl) + gitOpsConfigRestHandlerImpl := restHandler.NewGitOpsConfigRestHandlerImpl(sugaredLogger, gitOpsConfigServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl) gitOpsConfigRouterImpl := router.NewGitOpsConfigRouterImpl(gitOpsConfigRestHandlerImpl) dashboardConfig, err := dashboard.GetConfig() if err != nil { @@ -711,7 +715,7 @@ func InitializeApp() (*App, error) { userAttributesServiceImpl := attributes.NewUserAttributesServiceImpl(sugaredLogger, userAttributesRepositoryImpl) userAttributesRestHandlerImpl := restHandler.NewUserAttributesRestHandlerImpl(sugaredLogger, enforcerImpl, userServiceImpl, userAttributesServiceImpl) userAttributesRouterImpl := router.NewUserAttributesRouterImpl(userAttributesRestHandlerImpl) - commonRestHanlderImpl := restHandler.NewCommonRestHanlderImpl(sugaredLogger, gitOpsConfigServiceImpl, userServiceImpl, validate, enforcerImpl, commonServiceImpl) + commonRestHanlderImpl := restHandler.NewCommonRestHanlderImpl(sugaredLogger, userServiceImpl, commonServiceImpl) commonRouterImpl := router.NewCommonRouterImpl(commonRestHanlderImpl) grafanaConfig, err := grafana.GetConfig() if err != nil { From 347e0849149f2fdb5b5ea6ffd3c0079bbce552b3 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 18 Jan 2024 13:34:53 +0530 Subject: [PATCH 24/83] moved gitClient code to a common wrapper service --- cmd/external-app/wire_gen.go | 4 +- internal/util/GitService.go | 1 - pkg/app/ManifestPushService.go | 26 ++------ .../common/AppStoreDeploymentCommonService.go | 35 ++--------- .../AppStoreDeploymentFullModeService.go | 10 +++- .../service/AppStoreDeploymentService.go | 12 ++-- .../deployment/service/InstalledAppService.go | 27 ++++----- .../tool/AppStoreDeploymentHelmService.go | 15 +++-- .../gitops/AppStoreDeploymentArgoCdService.go | 13 ++-- .../remote/GitOpsRemoteOperationService.go | 59 +++++++++++++++++++ pkg/pipeline/WorkflowDagExecutor.go | 24 +++----- wire_gen.go | 14 ++--- 12 files changed, 129 insertions(+), 111 deletions(-) diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index f664986f3c..da0adc1866 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -274,7 +274,7 @@ func InitializeApp() (*App, error) { appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) chartGroupDeploymentRepositoryImpl := repository4.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) deploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() if err != nil { @@ -284,7 +284,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) diff --git a/internal/util/GitService.go b/internal/util/GitService.go index 06b2a47d63..882772e523 100644 --- a/internal/util/GitService.go +++ b/internal/util/GitService.go @@ -52,7 +52,6 @@ const ( ) type GitClient interface { - //TODO: make all methods independent of GitOpsConfigDto, create own dto object CreateRepository(config *bean2.GitOpsConfigDto) (url string, isNew bool, detailedErrorGitOpsConfigActions DetailedErrorGitOpsConfigActions) CommitValues(config *ChartConfig, gitOpsConfig *bean2.GitOpsConfigDto) (commitHash string, commitTime time.Time, err error) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error) diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 1e32701e53..937023f39b 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -3,11 +3,9 @@ package app import ( "context" "fmt" - bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" - . "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" @@ -28,7 +26,6 @@ type GitOpsPushService interface { type GitOpsManifestPushServiceImpl struct { logger *zap.SugaredLogger - gitFactory *GitFactory pipelineStatusTimelineService status2.PipelineStatusTimelineService pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository acdConfig *argocdServer.ACDConfig @@ -37,9 +34,7 @@ type GitOpsManifestPushServiceImpl struct { gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } -func NewGitOpsManifestPushServiceImpl( - logger *zap.SugaredLogger, - gitFactory *GitFactory, +func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineService status2.PipelineStatusTimelineService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, @@ -47,7 +42,6 @@ func NewGitOpsManifestPushServiceImpl( gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, - gitFactory: gitFactory, pipelineStatusTimelineService: pipelineStatusTimelineService, pipelineStatusTimelineRepository: pipelineStatusTimelineRepository, acdConfig: acdConfig, @@ -140,26 +134,14 @@ func (impl *GitOpsManifestPushServiceImpl) CommitValuesToGit(manifestPushTemplat UserName: userName, UserEmailId: userEmailId, } - bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() - if err != nil { - impl.logger.Errorw("error in getting bitbucket metadata", "err", err) - return commitHash, commitTime, err - } - gitOpsConfig := &bean2.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} - _, span = otel.Tracer("orchestrator").Start(ctx, "gitFactory.Client.CommitValues") - commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) + + _, span = otel.Tracer("orchestrator").Start(ctx, "gitOpsRemoteOperationService.CommitValues") + commitHash, commitTime, err = impl.gitOpsRemoteOperationService.CommitValues(chartGitAttr) span.End() if err != nil { impl.logger.Errorw("error in git commit", "err", err) return commitHash, commitTime, err } - if commitTime.IsZero() { - commitTime = time.Now() - } - span.End() - if err != nil { - return commitHash, commitTime, err - } return commitHash, commitTime, nil } diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index ed86999b8b..08460991af 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -53,7 +53,6 @@ type AppStoreDeploymentCommonService interface { GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) - CommitConfigToGit(chartConfig *util.ChartConfig) (gitHash string, err error) GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) GetValuesString(chartName, valuesOverrideYaml string) (string, error) GetRequirementsString(appStoreVersionId int) (string, error) @@ -404,7 +403,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifest(installAppVersi // CreateGitOpsRepo creates a gitOps repo with readme func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { - if len(installAppVersionRequest.GitOpsRepoName) == 0 { //here gitops repo will be the app name, to breaking the mono repo structure gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) @@ -416,21 +414,16 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi return "", false, err } //getting user name & emailId for commit author data - userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) gitRepoRequest := &bean.GitOpsConfigDto{ GitRepoName: installAppVersionRequest.GitOpsRepoName, Description: "helm chart for " + installAppVersionRequest.GitOpsRepoName, - Username: userName, - UserEmailId: userEmailId, BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, } - repoUrl, isNew, detailedError := impl.gitFactory.Client.CreateRepository(gitRepoRequest) - for _, err := range detailedError.StageErrorMap { - if err != nil { - impl.logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) - return "", false, err - } + repoUrl, isNew, err := impl.gitOpsRemoteOperationService.CreateRepository(gitRepoRequest, installAppVersionRequest.UserId) + if err != nil { + impl.logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) + return "", false, err } return repoUrl, isNew, err } @@ -540,22 +533,6 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(ins return chartGitAttribute, isNew, commitHash, err } -// CommitConfigToGit is used for committing values.yaml and requirements.yaml file config -func (impl AppStoreDeploymentCommonServiceImpl) CommitConfigToGit(chartConfig *util.ChartConfig) (string, error) { - bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() - if err != nil { - impl.logger.Errorw("error in getting bitbucket metadata", "err", err) - return "", err - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} - gitHash, _, err := impl.gitFactory.Client.CommitValues(chartConfig, gitOpsConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return "", err - } - return gitHash, nil -} - func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { appStoreGitOpsResponse := &AppStoreGitOpsResponse{} chartGitAttribute, isNew, githash, err := impl.CreateGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) @@ -570,7 +547,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. // step-2 commit dependencies and values in git if !isNew { - _, err = impl.CommitConfigToGit(manifestResponse.RequirementsConfig) + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.RequirementsConfig) if err != nil { impl.logger.Errorw("error in committing dependency config to git", "err", err) return appStoreGitOpsResponse, err @@ -581,7 +558,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons return appStoreGitOpsResponse, err } - githash, err = impl.CommitConfigToGit(manifestResponse.ValuesConfig) + githash, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.ValuesConfig) if err != nil { impl.logger.Errorw("error in committing values config to git", "err", err) return appStoreGitOpsResponse, err diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 6293aa0cb6..bbed6844f3 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -26,6 +26,7 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "time" "github.com/devtron-labs/devtron/client/argocdServer" @@ -73,6 +74,7 @@ type AppStoreDeploymentFullModeServiceImpl struct { installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository ACDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, @@ -84,7 +86,8 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, pubSubClient *pubsub_lib.PubSubClientServiceImpl, installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, ACDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentFullModeServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ logger: logger, acdClient: acdClient, @@ -98,6 +101,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory: installedAppRepositoryHistory, ACDConfig: ACDConfig, gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } err := appStoreDeploymentFullModeServiceImpl.SubscribeHelmInstallStatus() if err != nil { @@ -226,7 +230,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) UpdateValuesYaml(installAppVer impl.logger.Errorw("error in getting git commit config", "err", err) } - commitHash, err := impl.appStoreDeploymentCommonService.CommitConfigToGit(valuesGitConfig) + commitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) if err != nil { impl.logger.Errorw("error in git commit", "err", err) return installAppVersionRequest, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) @@ -250,7 +254,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) UpdateRequirementYaml(installA return err } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(requirementsGitConfig) + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) if err != nil { impl.logger.Errorw("error in values commit", "err", err) return errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index 89c61c6d09..9ae90a3e2c 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -44,6 +44,7 @@ import ( cluster2 "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -108,6 +109,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, @@ -119,7 +121,8 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep globalEnvVariables *util2.GlobalEnvVariables, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentServiceImpl { appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ logger: logger, @@ -141,6 +144,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep deploymentTypeConfig: deploymentTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } return appStoreDeploymentServiceImpl } @@ -1474,12 +1478,12 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } else if isChartChanged || isVersionChanged { // update dependency if chart or chart version is changed - _, requirementsCommitErr = impl.appStoreDeploymentCommonService.CommitConfigToGit(manifest.RequirementsConfig) - gitHash, valuesCommitErr = impl.appStoreDeploymentCommonService.CommitConfigToGit(manifest.ValuesConfig) + _, _, requirementsCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.RequirementsConfig) + gitHash, _, valuesCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.ValuesConfig) } else { // only values are changed in update, so commit values config - gitHash, valuesCommitErr = impl.appStoreDeploymentCommonService.CommitConfigToGit(manifest.ValuesConfig) + gitHash, _, valuesCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.ValuesConfig) } if valuesCommitErr != nil || requirementsCommitErr != nil { diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index eb1c89ad53..507b3a4974 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -22,6 +22,7 @@ import ( "context" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" /* #nosec */ "crypto/sha1" @@ -122,7 +123,6 @@ type InstalledAppServiceImpl struct { chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository envService cluster2.EnvironmentService ArgoK8sClient argocdServer.ArgoK8sClient - gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig gitOpsRepository repository3.GitOpsConfigRepository userService user.UserService @@ -140,6 +140,7 @@ type InstalledAppServiceImpl struct { k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, @@ -154,7 +155,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, tokenCache *util2.TokenCache, chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, envService cluster2.EnvironmentService, argoK8sClient argocdServer.ArgoK8sClient, - gitFactory *util.GitFactory, aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, + aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, @@ -163,8 +164,8 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineService status.PipelineStatusTimelineService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, - acdConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService) (*InstalledAppServiceImpl, error) { + acdConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -180,7 +181,6 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, chartGroupDeploymentRepository: chartGroupDeploymentRepository, envService: envService, ArgoK8sClient: argoK8sClient, - gitFactory: gitFactory, aCDAuthConfig: aCDAuthConfig, gitOpsRepository: gitOpsRepository, userService: userService, @@ -198,6 +198,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, k8sApplicationService: k8sApplicationService, acdConfig: acdConfig, gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } err := impl.Subscribe() if err != nil { @@ -475,21 +476,13 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion impl.logger.Errorw("fetching error", "err", err) return nil, err } - bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() - if err != nil { - impl.logger.Errorw("error in getting bitbucket metadata", "err", err) - return nil, err - } - config := &bean2.GitOpsConfigDto{ - GitRepoName: installedAppVersion.GitOpsRepoName, - BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, - BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, - } - repoUrl, err := impl.gitFactory.Client.GetRepoUrl(config) + + repoUrl, err := impl.gitOpsRemoteOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) if err != nil { //will allow to continue to persist status on next operation - impl.logger.Errorw("fetching error", "err", err) + impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) } + chartGitAttr.RepoUrl = repoUrl chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index c317353f48..520cf28025 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -5,6 +5,7 @@ import ( "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "net/http" "time" @@ -49,10 +50,15 @@ type AppStoreDeploymentHelmServiceImpl struct { installedAppRepository repository.InstalledAppRepository appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } -func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository clusterRepository.EnvironmentRepository, helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentHelmServiceImpl { +func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, + environmentRepository clusterRepository.EnvironmentRepository, helmAppClient client.HelmAppClient, + installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, @@ -62,6 +68,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ installedAppRepository: installedAppRepository, appStoreDeploymentCommonService: appStoreDeploymentCommonService, OCIRegistryConfigRepository: OCIRegistryConfigRepository, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -322,7 +329,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateRequirementDependencies(ins impl.Logger.Errorw("error in getting git config for helm app", "err", err) return err } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(requirementsGitConfig) + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) if err != nil { impl.Logger.Errorw("error in committing config to git for helm app", "err", err) return err @@ -347,7 +354,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installA impl.Logger.Errorw("error in getting git config for helm app", "err", err) return err } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(valuesGitConfig) + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) if err != nil { impl.Logger.Errorw("error in committing config to git for helm app", "err", err) return err diff --git a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go index 9bfcf39a40..972ed626ea 100644 --- a/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/gitops/AppStoreDeploymentArgoCdService.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "net/http" "strings" "time" @@ -67,7 +68,6 @@ type AppStoreDeploymentArgoCdServiceImpl struct { chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository installedAppRepository repository.InstalledAppRepository installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - gitFactory *util.GitFactory argoUserService argo.ArgoUserService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService helmAppService client.HelmAppService @@ -78,18 +78,19 @@ type AppStoreDeploymentArgoCdServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, acdClient application2.ServiceClient, chartGroupDeploymentRepository repository.ChartGroupDeploymentRepository, installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, - gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, helmAppService client.HelmAppService, appStatusService appStatus.AppStatusService, pipelineStatusTimelineService status.PipelineStatusTimelineService, userService user.UserService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, -) *AppStoreDeploymentArgoCdServiceImpl { + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentArgoCdServiceImpl { return &AppStoreDeploymentArgoCdServiceImpl{ Logger: logger, appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, @@ -97,7 +98,6 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD chartGroupDeploymentRepository: chartGroupDeploymentRepository, installedAppRepository: installedAppRepository, installedAppRepositoryHistory: installedAppRepositoryHistory, - gitFactory: gitFactory, argoUserService: argoUserService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, helmAppService: helmAppService, @@ -108,6 +108,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, argoClientWrapperService: argoClientWrapperService, acdConfig: acdConfig, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -604,7 +605,7 @@ func (impl *AppStoreDeploymentArgoCdServiceImpl) UpdateRequirementDependencies(i impl.Logger.Errorw("error in getting git config for helm app", "err", err) return err } - _, err = impl.appStoreDeploymentCommonService.CommitConfigToGit(requirementsGitConfig) + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) if err != nil { impl.Logger.Errorw("error in committing config to git for helm app", "err", err) return err @@ -697,7 +698,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYaml(installAppVersi impl.Logger.Errorw("error in getting git config for helm app", "err", err) return nil, err } - gitHash, err := impl.appStoreDeploymentCommonService.CommitConfigToGit(valuesGitConfig) + gitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) if err != nil { impl.Logger.Errorw("error in git commit", "err", err) _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) diff --git a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go index f956e862e8..18369cccf3 100644 --- a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go +++ b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go @@ -14,6 +14,7 @@ import ( "path/filepath" "regexp" "sigs.k8s.io/yaml" + "time" ) type GitOpsRemoteOperationService interface { @@ -25,6 +26,9 @@ type GitOpsRemoteOperationService interface { CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) GitPull(clonedDir string, repoUrl string, appStoreName string) error + CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) + CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) + GetRepoUrlByRepoName(repoName string) (string, error) } type GitOpsRemoteOperationServiceImpl struct { @@ -314,3 +318,58 @@ func (impl *GitOpsRemoteOperationServiceImpl) GitPull(clonedDir string, repoUrl } return nil } + +func (impl *GitOpsRemoteOperationServiceImpl) CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) { + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() + if err != nil { + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return commitHash, commitTime, err + } + gitOpsConfig := &bean2.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} + commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) + if err != nil { + impl.logger.Errorw("error in git commit", "err", err) + return commitHash, commitTime, err + } + if commitTime.IsZero() { + commitTime = time.Now() + } + return commitHash, commitTime, nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) { + //getting user name & emailId for commit author data + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) + if dto != nil { + dto.UserEmailId = userEmailId + dto.Username = userName + } + repoUrl, isNew, detailedError := impl.gitFactory.Client.CreateRepository(dto) + for _, err := range detailedError.StageErrorMap { + if err != nil { + impl.logger.Errorw("error in creating git project", "err", err, "req", dto) + return "", false, err + } + } + return repoUrl, isNew, nil +} + +func (impl *GitOpsRemoteOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (string, error) { + repoUrl := "" + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() + if err != nil { + impl.logger.Errorw("error in getting bitbucket metadata", "err", err) + return repoUrl, err + } + dto := &bean2.GitOpsConfigDto{ + GitRepoName: repoName, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, + } + repoUrl, err = impl.gitFactory.Client.GetRepoUrl(dto) + if err != nil { + //will allow to continue to persist status on next operation + impl.logger.Errorw("error in getting repo url", "err", err, "repoName", repoName) + } + return repoUrl, nil +} diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 1eebea4b9d..e3f72bebd3 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -23,6 +23,7 @@ import ( errors3 "errors" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "path" @@ -183,7 +184,6 @@ type WorkflowDagExecutorImpl struct { environmentConfigRepository chartConfig.EnvConfigOverrideRepository dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository mergeUtil *util.MergeUtil - gitFactory *util.GitFactory acdClient application2.ServiceClient argoClientWrapperService argocdServer.ArgoClientWrapperService customTagService CustomTagService @@ -191,6 +191,7 @@ type WorkflowDagExecutorImpl struct { deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } const kedaAutoscaling = "kedaAutoscaling" @@ -285,7 +286,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository chartConfig.EnvConfigOverrideRepository, dbMigrationConfigRepository pipelineConfig.DbMigrationConfigRepository, mergeUtil *util.MergeUtil, - gitFactory *util.GitFactory, acdClient application2.ServiceClient, argoClientWrapperService argocdServer.ArgoClientWrapperService, pipelineConfigListenerService PipelineConfigListenerService, @@ -293,7 +293,8 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi ACDConfig *argocdServer.ACDConfig, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, chartRefService chartRef.ChartRefService, - gitOpsConfigReadService config.GitOpsConfigReadService) *WorkflowDagExecutorImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, @@ -355,7 +356,6 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi environmentConfigRepository: environmentConfigRepository, dbMigrationConfigRepository: dbMigrationConfigRepository, mergeUtil: mergeUtil, - gitFactory: gitFactory, acdClient: acdClient, argoClientWrapperService: argoClientWrapperService, customTagService: customTagService, @@ -363,6 +363,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi deployedAppMetricsService: deployedAppMetricsService, chartRefService: chartRefService, gitOpsConfigReadService: gitOpsConfigReadService, + gitOpsRemoteOperationService: gitOpsRemoteOperationService, } config, err := types.GetCdConfig() if err != nil { @@ -4139,7 +4140,7 @@ func (impl *WorkflowDagExecutorImpl) mergeAndSave(envOverride *chartConfig.EnvCo } commitHash := "" - commitTime := time.Time{} + commitTime := time.Now() //setting default to current time, if not acd type then will go as it is else will get overriden if util.IsAcdApp(pipeline.DeploymentAppType) { chartRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(envOverride.Chart.GitRepoUrl) _, span = otel.Tracer("orchestrator").Start(ctx, "chartTemplateService.GetUserEmailIdAndNameForGitOpsCommit") @@ -4156,23 +4157,14 @@ func (impl *WorkflowDagExecutorImpl) mergeAndSave(envOverride *chartConfig.EnvCo UserName: userName, UserEmailId: userEmailId, } - bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() - if err != nil { - impl.logger.Errorw("error in getting bitbucket metadata", "err", err) - return 0, 0, "", err - } - gitOpsConfig := &bean.GitOpsConfigDto{BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId} - _, span = otel.Tracer("orchestrator").Start(ctx, "gitFactory.Client.CommitValues") - commitHash, commitTime, err = impl.gitFactory.Client.CommitValues(chartGitAttr, gitOpsConfig) + _, span = otel.Tracer("orchestrator").Start(ctx, "gitOpsRemoteOperationService.CommitValues") + commitHash, commitTime, err = impl.gitOpsRemoteOperationService.CommitValues(chartGitAttr) span.End() if err != nil { impl.logger.Errorw("error in git commit", "err", err) return 0, 0, "", err } } - if commitTime.IsZero() { - commitTime = time.Now() - } pipelineOverride := &chartConfig.PipelineOverride{ Id: override.Id, GitHash: commitHash, diff --git a/wire_gen.go b/wire_gen.go index 420e078477..443233e933 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -436,7 +436,7 @@ func InitializeApp() (*App, error) { pipelineStrategyHistoryRepositoryImpl := repository8.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) manifestPushConfigRepositoryImpl := repository9.NewManifestPushConfigRepository(sugaredLogger, db) - gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, gitFactory, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) genericNoteRepositoryImpl := repository12.NewGenericNoteRepositoryImpl(db) @@ -452,7 +452,7 @@ func InitializeApp() (*App, error) { repositoryServiceClientImpl := repository13.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, gitFactory, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, dbMigrationConfigRepositoryImpl, mergeUtil, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) @@ -545,15 +545,15 @@ func InitializeApp() (*App, error) { tokenCache := util3.NewTokenCache(sugaredLogger, acdAuthConfig, userAuthServiceImpl) chartGroupDeploymentRepositoryImpl := repository3.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl) + appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, gitFactory, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOpsRemoteOperationServiceImpl) serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, globalEnvVariables, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -563,7 +563,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, gitFactory, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl) + installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, repositoryServiceClientImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, tokenCache, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, argoK8sClientImpl, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) if err != nil { return nil, err } From f91f682d2a20ff2574ec21c7292e5fe44b14315f Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Thu, 18 Jan 2024 15:45:54 +0530 Subject: [PATCH 25/83] chore: AppStoreDeployment Install flow refactoring --- pkg/appStore/adapter/Adapter.go | 160 ++++++++++ pkg/appStore/bean/bean.go | 26 +- .../common/AppStoreDeploymentCommonService.go | 57 +--- .../repository/InstalledAppModels.go | 69 +++++ .../repository/InstalledAppRepository.go | 143 ++++----- .../repository/InstalledAppVersionHistory.go | 12 + .../service/AppStoreDeploymentDBService.go | 180 +++++++++++ .../service/AppStoreDeploymentService.go | 286 +----------------- .../service/AppStoreDeploymentService_test.go | 6 +- .../deployment/service/InstalledAppService.go | 4 +- .../service/InstalledAppService_test.go | 18 +- pkg/appStore/deployment/service/Notes.go | 109 ++++--- pkg/sql/UtilStructs.go | 14 + 13 files changed, 598 insertions(+), 486 deletions(-) create mode 100644 pkg/appStore/adapter/Adapter.go create mode 100644 pkg/appStore/deployment/repository/InstalledAppModels.go create mode 100644 pkg/appStore/deployment/service/AppStoreDeploymentDBService.go diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go new file mode 100644 index 0000000000..4065e755d0 --- /dev/null +++ b/pkg/appStore/adapter/Adapter.go @@ -0,0 +1,160 @@ +package adapter + +import ( + "encoding/json" + "fmt" + "github.com/devtron-labs/devtron/internal/util" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" +) + +// NewInstallAppModel is used to generate new repository.InstalledApps model to be saved; +// Note: Do not use for update operations +func NewInstallAppModel(chart *appStoreBean.InstallAppVersionDTO, status appStoreBean.AppstoreDeploymentStatus) *repository.InstalledApps { + installAppModel := &repository.InstalledApps{ + AppId: chart.AppId, + EnvironmentId: chart.EnvironmentId, + DeploymentAppType: chart.DeploymentAppType, + } + if status != appStoreBean.WF_UNKNOWN { + installAppModel.UpdateStatus(status) + } + installAppModel.CreateAuditLog(chart.UserId) + installAppModel.UpdateGitOpsRepoName(chart.GitOpsRepoName) + installAppModel.MarkActive() + return installAppModel +} + +// NewInstallAppVersionsModel is used to generate new repository.InstalledAppVersions model to be saved; +// Note: Do not use for update operations +func NewInstallAppVersionsModel(chart *appStoreBean.InstallAppVersionDTO) *repository.InstalledAppVersions { + installedAppVersions := &repository.InstalledAppVersions{ + InstalledAppId: chart.InstalledAppId, + AppStoreApplicationVersionId: chart.AppStoreVersion, + ValuesYaml: chart.ValuesOverrideYaml, + ReferenceValueId: chart.ReferenceValueId, + ReferenceValueKind: chart.ReferenceValueKind, + } + installedAppVersions.CreateAuditLog(chart.UserId) + installedAppVersions.MarkActive() + return installedAppVersions +} + +// NewInstallAppVersionHistoryModel is used to generate new repository.InstalledAppVersionHistory model to be saved; +// Note: Do not use for update operations +func NewInstallAppVersionHistoryModel(chart *appStoreBean.InstallAppVersionDTO, status string, helmInstallConfigDTO appStoreBean.HelmReleaseStatusConfig) (*repository.InstalledAppVersionHistory, error) { + installedAppVersions := &repository.InstalledAppVersionHistory{ + InstalledAppVersionId: chart.InstalledAppVersionId, + ValuesYamlRaw: chart.ValuesOverrideYaml, + } + helmInstallConfig, err := json.Marshal(helmInstallConfigDTO) + if err != nil { + return nil, err + } + installedAppVersions.HelmReleaseStatusConfig = string(helmInstallConfig) + installedAppVersions.SetStartedOn() + installedAppVersions.SetStatus(status) + installedAppVersions.CreateAuditLog(chart.UserId) + return installedAppVersions, nil +} + +// NewClusterInstalledAppsModel is used to generate new repository.ClusterInstalledApps model to be saved; +// Note: Do not use for update operations +func NewClusterInstalledAppsModel(chart *appStoreBean.InstallAppVersionDTO, clusterId int) *repository.ClusterInstalledApps { + clusterInstalledAppsModel := &repository.ClusterInstalledApps{ + ClusterId: clusterId, + InstalledAppId: chart.InstalledAppId, + } + clusterInstalledAppsModel.CreateAuditLog(chart.UserId) + return clusterInstalledAppsModel +} + +// NewInstalledAppDeploymentAction is used to generate appStoreBean.InstalledAppDeploymentAction from deploymentAppType +func NewInstalledAppDeploymentAction(deploymentAppType string) *appStoreBean.InstalledAppDeploymentAction { + installedAppDeploymentAction := &appStoreBean.InstalledAppDeploymentAction{} + switch deploymentAppType { + case util.PIPELINE_DEPLOYMENT_TYPE_ACD: + installedAppDeploymentAction.PerformGitOps = true + installedAppDeploymentAction.PerformACDDeployment = true + installedAppDeploymentAction.PerformHelmDeployment = false + case util.PIPELINE_DEPLOYMENT_TYPE_HELM: + installedAppDeploymentAction.PerformGitOps = false + installedAppDeploymentAction.PerformACDDeployment = false + installedAppDeploymentAction.PerformHelmDeployment = true + case util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD: + installedAppDeploymentAction.PerformGitOps = false + installedAppDeploymentAction.PerformHelmDeployment = false + installedAppDeploymentAction.PerformACDDeployment = false + } + return installedAppDeploymentAction +} + +// GenerateInstallAppVersionDTO converts repository.InstalledApps and repository.InstalledAppVersions db object to appStoreBean.InstallAppVersionDTO bean +func GenerateInstallAppVersionDTO(chart *repository.InstalledApps, installedAppVersion *repository.InstalledAppVersions) *appStoreBean.InstallAppVersionDTO { + chartVersionApp := installedAppVersion.AppStoreApplicationVersion + + var chartRepoName, chartRepoUrl, Username, Password string + if chartVersionApp.AppStore.ChartRepoId != 0 { + chartRepo := chartVersionApp.AppStore.ChartRepo + chartRepoName = chartRepo.Name + chartRepoUrl = chartRepo.Url + Username = chartRepo.UserName + Password = chartRepo.Password + } else { + chartRepo := chartVersionApp.AppStore.DockerArtifactStore + chartRepoName = chartRepo.Id + chartRepoUrl = fmt.Sprintf("%s://%s/%s", + "oci", + chartVersionApp.AppStore.DockerArtifactStore.RegistryURL, + chartVersionApp.AppStore.Name) + Username = chartVersionApp.AppStore.DockerArtifactStore.Username + Password = chartVersionApp.AppStore.DockerArtifactStore.Password + } + + return &appStoreBean.InstallAppVersionDTO{ + EnvironmentId: chart.EnvironmentId, + AppId: chart.AppId, + TeamId: chart.App.TeamId, + TeamName: chart.App.Team.Name, + AppOfferingMode: chart.App.AppOfferingMode, + ClusterId: chart.Environment.ClusterId, + Namespace: chart.Environment.Namespace, + AppName: chart.App.AppName, + EnvironmentName: chart.Environment.Name, + InstalledAppId: chart.Id, + DeploymentAppType: chart.DeploymentAppType, + + Id: installedAppVersion.Id, + InstalledAppVersionId: installedAppVersion.Id, + InstallAppVersionChartDTO: &appStoreBean.InstallAppVersionChartDTO{ + AppStoreChartId: chartVersionApp.AppStore.Id, + ChartName: chartVersionApp.Name, + ChartVersion: chartVersionApp.Version, + InstallAppVersionChartRepoDTO: &appStoreBean.InstallAppVersionChartRepoDTO{ + RepoName: chartRepoName, + RepoUrl: chartRepoUrl, + UserName: Username, + Password: Password, + }, + }, + AppStoreApplicationVersionId: installedAppVersion.AppStoreApplicationVersionId, + } +} + +// GenerateInstallAppVersionMinDTO converts repository.InstalledApps db object to appStoreBean.InstallAppVersionDTO bean; +// Note: It only generates a minimal DTO and doesn't include repository.InstalledAppVersions data +func GenerateInstallAppVersionMinDTO(chart *repository.InstalledApps) *appStoreBean.InstallAppVersionDTO { + return &appStoreBean.InstallAppVersionDTO{ + EnvironmentId: chart.EnvironmentId, + InstalledAppId: chart.Id, + AppId: chart.AppId, + AppOfferingMode: chart.App.AppOfferingMode, + ClusterId: chart.Environment.ClusterId, + Namespace: chart.Environment.Namespace, + AppName: chart.App.AppName, + EnvironmentName: chart.Environment.Name, + TeamId: chart.App.TeamId, + TeamName: chart.App.Team.Name, + DeploymentAppType: chart.DeploymentAppType, + } +} diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 314e0fd7f6..767777c2c1 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -63,7 +63,7 @@ type InstalledAppDto struct { } type InstallAppVersionDTO struct { - Id int `json:"id,omitempty"` + Id int `json:"id,omitempty"` // TODO: redundant data; refers to InstalledAppVersionId AppId int `json:"appId,omitempty"` AppName string `json:"appName,omitempty"` TeamId int `json:"teamId,omitempty"` @@ -76,8 +76,8 @@ type InstallAppVersionDTO struct { ValuesOverrideYaml string `json:"valuesOverrideYaml,omitempty"` Readme string `json:"readme,omitempty"` UserId int32 `json:"-"` - ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` - ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED EXISTING"` + ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` // TODO: ineffective usage of omitempty; can be removed + ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED EXISTING"` // TODO: ineffective usage of omitempty; can be removed ACDAppName string `json:"-"` Environment *repository2.Environment `json:"-"` ChartGroupEntryId int `json:"-"` @@ -96,14 +96,22 @@ type InstallAppVersionDTO struct { GitHash string `json:"gitHash"` EnvironmentName string `json:"-"` InstallAppVersionChartDTO *InstallAppVersionChartDTO `json:"-"` - DeploymentAppType string `json:"deploymentAppType"` + DeploymentAppType string `json:"deploymentAppType"` // TODO: instead of string, use enum AcdPartialDelete bool `json:"acdPartialDelete"` InstalledAppDeleteResponse *InstalledAppDeleteResponseDTO `json:"deleteResponse,omitempty"` AppStoreApplicationVersionId int - PerformGitOpsForHelmApp bool `json:"performGitOpsForHelmApp"` - PerformGitOps bool `json:"performGitOps"` - PerformACDDeployment bool `json:"performACDDeployment"` - PerformHelmDeployment bool `json:"performHelmDeployment"` +} + +func (chart *InstallAppVersionDTO) UpdateDeploymentAppType(deploymentAppType string) { + chart.DeploymentAppType = deploymentAppType +} + +// InstalledAppDeploymentAction is an internal struct for Helm App deployment; used to decide the deployment steps to be performed +type InstalledAppDeploymentAction struct { + PerformGitOpsForHelmApp bool + PerformGitOps bool + PerformACDDeployment bool + PerformHelmDeployment bool } type InstalledAppDeleteResponseDTO struct { @@ -144,7 +152,7 @@ type InstalledAppsResponse struct { EnvironmentName string `json:"environmentName"` DeployedAt time.Time `json:"deployedAt"` DeployedBy string `json:"deployedBy"` - DeploymentAppType string `json:"deploymentAppType,omitempty"` + DeploymentAppType string `json:"deploymentAppType,omitempty"` // TODO: instead of string, use enum InstalledAppsId int `json:"installedAppId"` Readme string `json:"readme"` EnvironmentId int `json:"environmentId"` diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 44ca59836e..0a63b9420f 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -23,6 +23,7 @@ import ( "github.com/devtron-labs/devtron/api/bean" repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" @@ -141,7 +142,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetInstalledAppByClusterNamespac if err != nil { return nil, err } - return impl.convert(installedApp, installedAppVersion), nil + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil } return nil, nil @@ -153,59 +154,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetInstalledAppByInstalledAppId( return nil, err } installedApp := &installedAppVersion.InstalledApp - return impl.convert(installedApp, installedAppVersion), nil -} - -// converts db object to bean -func (impl AppStoreDeploymentCommonServiceImpl) convert(chart *repository.InstalledApps, installedAppVersion *repository.InstalledAppVersions) *appStoreBean.InstallAppVersionDTO { - - chartVersionApp := installedAppVersion.AppStoreApplicationVersion - - var chartRepoName, chartRepoUrl, Username, Password string - if installedAppVersion.AppStoreApplicationVersion.AppStore.ChartRepoId != 0 { - chartRepo := installedAppVersion.AppStoreApplicationVersion.AppStore.ChartRepo - chartRepoName = chartRepo.Name - chartRepoUrl = chartRepo.Url - Username = chartRepo.UserName - Password = chartRepo.Password - } else { - chartRepo := installedAppVersion.AppStoreApplicationVersion.AppStore.DockerArtifactStore - chartRepoName = chartRepo.Id - chartRepoUrl = fmt.Sprintf("%s://%s/%s", - "oci", - installedAppVersion.AppStoreApplicationVersion.AppStore.DockerArtifactStore.RegistryURL, - installedAppVersion.AppStoreApplicationVersion.AppStore.Name) - Username = installedAppVersion.AppStoreApplicationVersion.AppStore.DockerArtifactStore.Username - Password = installedAppVersion.AppStoreApplicationVersion.AppStore.DockerArtifactStore.Password - } - - return &appStoreBean.InstallAppVersionDTO{ - EnvironmentId: chart.EnvironmentId, - Id: chart.Id, - AppId: chart.AppId, - TeamId: chart.App.TeamId, - TeamName: chart.App.Team.Name, - AppOfferingMode: chart.App.AppOfferingMode, - ClusterId: chart.Environment.ClusterId, - Namespace: chart.Environment.Namespace, - AppName: chart.App.AppName, - EnvironmentName: chart.Environment.Name, - InstalledAppId: chart.Id, - InstalledAppVersionId: installedAppVersion.Id, - InstallAppVersionChartDTO: &appStoreBean.InstallAppVersionChartDTO{ - AppStoreChartId: chartVersionApp.AppStore.Id, - ChartName: chartVersionApp.Name, - ChartVersion: chartVersionApp.Version, - InstallAppVersionChartRepoDTO: &appStoreBean.InstallAppVersionChartRepoDTO{ - RepoName: chartRepoName, - RepoUrl: chartRepoUrl, - UserName: Username, - Password: Password, - }, - }, - DeploymentAppType: chart.DeploymentAppType, - AppStoreApplicationVersionId: installedAppVersion.AppStoreApplicationVersionId, - } + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil } func (impl AppStoreDeploymentCommonServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { diff --git a/pkg/appStore/deployment/repository/InstalledAppModels.go b/pkg/appStore/deployment/repository/InstalledAppModels.go new file mode 100644 index 0000000000..56ea99d0d7 --- /dev/null +++ b/pkg/appStore/deployment/repository/InstalledAppModels.go @@ -0,0 +1,69 @@ +package repository + +import ( + "time" +) + +// TODO: Remove dependencies on native queries and the structs used in it + +// GitOpsAppDetails is used to operate on native query; This should be avoided. +// Usage func: InstalledAppRepository.GetAllGitOpsAppNameAndInstalledAppMapping +type GitOpsAppDetails struct { + GitOpsAppName string `sql:"git_ops_app_name"` + InstalledAppId int `sql:"installed_app_id"` +} + +// InstalledAppsWithChartDetails is used to operate on native query; This should be avoided. +// Usage func: InstalledAppRepository.GetAllInstalledApps +type InstalledAppsWithChartDetails struct { + AppStoreApplicationName string `json:"app_store_application_name"` + ChartRepoName string `json:"chart_repo_name"` + DockerArtifactStoreId string `json:"docker_artifact_store_id"` + AppName string `json:"app_name"` + EnvironmentName string `json:"environment_name"` + InstalledAppVersionId int `json:"installed_app_version_id"` + AppStoreApplicationVersionId int `json:"app_store_application_version_id"` + Icon string `json:"icon"` + Readme string `json:"readme"` + CreatedOn time.Time `json:"created_on"` + UpdatedOn time.Time `json:"updated_on"` + Id int `json:"id"` + EnvironmentId int `json:"environment_id"` + Deprecated bool `json:"deprecated"` + ClusterName string `json:"clusterName"` + Namespace string `json:"namespace"` + TeamId int `json:"teamId"` + ClusterId int `json:"clusterId"` + AppOfferingMode string `json:"app_offering_mode"` + AppStatus string `json:"app_status"` + DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"` +} + +// InstalledAppAndEnvDetails is used to operate on native query; This should be avoided. +// Usage functions: InstalledAppRepository.GetAllInstalledAppsByChartRepoId and InstalledAppRepository.GetAllInstalledAppsByAppStoreId +type InstalledAppAndEnvDetails struct { + EnvironmentName string `json:"environment_name"` + EnvironmentId int `json:"environment_id"` + AppName string `json:"app_name"` + AppOfferingMode string `json:"appOfferingMode"` + UpdatedOn time.Time `json:"updated_on"` + EmailId string `json:"email_id"` + InstalledAppVersionId int `json:"installed_app_version_id"` + AppId int `json:"app_id"` + InstalledAppId int `json:"installed_app_id"` + AppStoreApplicationVersionId int `json:"app_store_application_version_id"` + AppStatus string `json:"app_status"` + DeploymentAppType string `json:"-"` +} + +// InstallAppDeleteRequest is used to operate on native query; This should be avoided. +// Usage func: InstalledAppRepository.GetInstalledAppByGitHash +type InstallAppDeleteRequest struct { + InstalledAppId int `json:"installed_app_id,omitempty,notnull"` + AppName string `json:"app_name,omitempty"` + AppId int `json:"app_id,omitempty"` + EnvironmentId int `json:"environment_id,omitempty"` + AppOfferingMode string `json:"app_offering_mode"` + ClusterId int `json:"cluster_id"` + Namespace string `json:"namespace"` +} diff --git a/pkg/appStore/deployment/repository/InstalledAppRepository.go b/pkg/appStore/deployment/repository/InstalledAppRepository.go index 134887be61..d4d91de2a1 100644 --- a/pkg/appStore/deployment/repository/InstalledAppRepository.go +++ b/pkg/appStore/deployment/repository/InstalledAppRepository.go @@ -31,9 +31,62 @@ import ( "github.com/go-pg/pg/orm" "go.uber.org/zap" "strconv" - "time" ) +type InstalledApps struct { + TableName struct{} `sql:"installed_apps" pg:",discard_unknown_columns"` + Id int `sql:"id,pk"` + AppId int `sql:"app_id,notnull"` + EnvironmentId int `sql:"environment_id,notnull"` + Active bool `sql:"active, notnull"` + GitOpsRepoName string `sql:"git_ops_repo_name"` + DeploymentAppType string `sql:"deployment_app_type"` // TODO: instead of string, use enum + Status appStoreBean.AppstoreDeploymentStatus `sql:"status"` + DeploymentAppDeleteRequest bool `sql:"deployment_app_delete_request"` + Notes string `json:"notes"` + App app.App + Environment repository.Environment + sql.AuditLog +} + +func (model *InstalledApps) MarkActive() { + model.Active = true +} + +func (model *InstalledApps) MarkInActive() { + model.Active = false +} + +func (model *InstalledApps) UpdateStatus(status appStoreBean.AppstoreDeploymentStatus) { + model.Status = status +} + +func (model *InstalledApps) UpdateGitOpsRepoName(gitOpsRepoName string) { + model.GitOpsRepoName = gitOpsRepoName +} + +type InstalledAppVersions struct { + TableName struct{} `sql:"installed_app_versions" pg:",discard_unknown_columns"` + Id int `sql:"id,pk"` + InstalledAppId int `sql:"installed_app_id,notnull"` + AppStoreApplicationVersionId int `sql:"app_store_application_version_id,notnull"` + ValuesYaml string `sql:"values_yaml_raw"` + Active bool `sql:"active, notnull"` + ReferenceValueId int `sql:"reference_value_id"` + ReferenceValueKind string `sql:"reference_value_kind"` + sql.AuditLog + InstalledApp InstalledApps + AppStoreApplicationVersion appStoreDiscoverRepository.AppStoreApplicationVersion +} + +func (model *InstalledAppVersions) MarkActive() { + model.Active = true +} + +func (model *InstalledAppVersions) MarkInActive() { + model.Active = false +} + type InstalledAppRepository interface { CreateInstalledApp(model *InstalledApps, tx *pg.Tx) (*InstalledApps, error) CreateInstalledAppVersion(model *InstalledAppVersions, tx *pg.Tx) (*InstalledAppVersions, error) @@ -43,7 +96,7 @@ type InstalledAppRepository interface { GetInstalledAppVersion(id int) (*InstalledAppVersions, error) GetInstalledAppVersionAny(id int) (*InstalledAppVersions, error) GetAllInstalledApps(filter *appStoreBean.AppStoreFilter) ([]InstalledAppsWithChartDetails, error) - GetAllIntalledAppsByAppStoreId(appStoreId int) ([]InstalledAppAndEnvDetails, error) + GetAllInstalledAppsByAppStoreId(appStoreId int) ([]InstalledAppAndEnvDetails, error) GetAllInstalledAppsByChartRepoId(chartRepoId int) ([]InstalledAppAndEnvDetails, error) GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId int, envId int) (*InstalledAppVersions, error) FetchNotes(installedAppId int) (*InstalledApps, error) @@ -81,94 +134,10 @@ type InstalledAppRepositoryImpl struct { Logger *zap.SugaredLogger } -type InstallAppDeleteRequest struct { - InstalledAppId int `json:"installed_app_id,omitempty,notnull"` - AppName string `json:"app_name,omitempty"` - AppId int `json:"app_id,omitempty"` - EnvironmentId int `json:"environment_id,omitempty"` - AppOfferingMode string `json:"app_offering_mode"` - ClusterId int `json:"cluster_id"` - Namespace string `json:"namespace"` -} - func NewInstalledAppRepositoryImpl(Logger *zap.SugaredLogger, dbConnection *pg.DB) *InstalledAppRepositoryImpl { return &InstalledAppRepositoryImpl{dbConnection: dbConnection, Logger: Logger} } -type InstalledApps struct { - TableName struct{} `sql:"installed_apps" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - AppId int `sql:"app_id,notnull"` - EnvironmentId int `sql:"environment_id,notnull"` - Active bool `sql:"active, notnull"` - GitOpsRepoName string `sql:"git_ops_repo_name"` - DeploymentAppType string `sql:"deployment_app_type"` - Status appStoreBean.AppstoreDeploymentStatus `sql:"status"` - DeploymentAppDeleteRequest bool `sql:"deployment_app_delete_request"` - Notes string `json:"notes"` - App app.App - Environment repository.Environment - sql.AuditLog -} - -type InstalledAppVersions struct { - TableName struct{} `sql:"installed_app_versions" pg:",discard_unknown_columns"` - Id int `sql:"id,pk"` - InstalledAppId int `sql:"installed_app_id,notnull"` - AppStoreApplicationVersionId int `sql:"app_store_application_version_id,notnull"` - ValuesYaml string `sql:"values_yaml_raw"` - Active bool `sql:"active, notnull"` - ReferenceValueId int `sql:"reference_value_id"` - ReferenceValueKind string `sql:"reference_value_kind"` - sql.AuditLog - InstalledApp InstalledApps - AppStoreApplicationVersion appStoreDiscoverRepository.AppStoreApplicationVersion -} - -type GitOpsAppDetails struct { - GitOpsAppName string `sql:"git_ops_app_name"` - InstalledAppId int `sql:"installed_app_id"` -} - -type InstalledAppsWithChartDetails struct { - AppStoreApplicationName string `json:"app_store_application_name"` - ChartRepoName string `json:"chart_repo_name"` - DockerArtifactStoreId string `json:"docker_artifact_store_id"` - AppName string `json:"app_name"` - EnvironmentName string `json:"environment_name"` - InstalledAppVersionId int `json:"installed_app_version_id"` - AppStoreApplicationVersionId int `json:"app_store_application_version_id"` - Icon string `json:"icon"` - Readme string `json:"readme"` - CreatedOn time.Time `json:"created_on"` - UpdatedOn time.Time `json:"updated_on"` - Id int `json:"id"` - EnvironmentId int `json:"environment_id"` - Deprecated bool `json:"deprecated"` - ClusterName string `json:"clusterName"` - Namespace string `json:"namespace"` - TeamId int `json:"teamId"` - ClusterId int `json:"clusterId"` - AppOfferingMode string `json:"app_offering_mode"` - AppStatus string `json:"app_status"` - DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"` -} - -type InstalledAppAndEnvDetails struct { - EnvironmentName string `json:"environment_name"` - EnvironmentId int `json:"environment_id"` - AppName string `json:"app_name"` - AppOfferingMode string `json:"appOfferingMode"` - UpdatedOn time.Time `json:"updated_on"` - EmailId string `json:"email_id"` - InstalledAppVersionId int `json:"installed_app_version_id"` - AppId int `json:"app_id"` - InstalledAppId int `json:"installed_app_id"` - AppStoreApplicationVersionId int `json:"app_store_application_version_id"` - AppStatus string `json:"app_status"` - DeploymentAppType string `json:"-"` -} - func (impl InstalledAppRepositoryImpl) CreateInstalledApp(model *InstalledApps, tx *pg.Tx) (*InstalledApps, error) { err := tx.Insert(model) if err != nil { @@ -427,7 +396,7 @@ func (impl InstalledAppRepositoryImpl) GetAllInstalledApps(filter *appStoreBean. return installedAppsWithChartDetails, err } -func (impl InstalledAppRepositoryImpl) GetAllIntalledAppsByAppStoreId(appStoreId int) ([]InstalledAppAndEnvDetails, error) { +func (impl InstalledAppRepositoryImpl) GetAllInstalledAppsByAppStoreId(appStoreId int) ([]InstalledAppAndEnvDetails, error) { var installedAppAndEnvDetails []InstalledAppAndEnvDetails var queryTemp = "select env.environment_name, env.id as environment_id, a.app_name, a.app_offering_mode, ia.updated_on, u.email_id," + " asav.id as app_store_application_version_id, iav.id as installed_app_version_id, ia.id as installed_app_id, ia.app_id, ia.deployment_app_type, app_status.status as app_status" + diff --git a/pkg/appStore/deployment/repository/InstalledAppVersionHistory.go b/pkg/appStore/deployment/repository/InstalledAppVersionHistory.go index f914c749ac..4b2b127632 100644 --- a/pkg/appStore/deployment/repository/InstalledAppVersionHistory.go +++ b/pkg/appStore/deployment/repository/InstalledAppVersionHistory.go @@ -46,6 +46,18 @@ type InstalledAppVersionHistory struct { sql.AuditLog } +func (model *InstalledAppVersionHistory) SetStartedOn() { + model.StartedOn = time.Now() +} + +func (model *InstalledAppVersionHistory) SetFinishedOn() { + model.FinishedOn = time.Now() +} + +func (model *InstalledAppVersionHistory) SetStatus(status string) { + model.Status = status +} + func (impl InstalledAppVersionHistoryRepositoryImpl) CreateInstalledAppVersionHistory(model *InstalledAppVersionHistory, tx *pg.Tx) (*InstalledAppVersionHistory, error) { err := tx.Insert(model) if err != nil { diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go b/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go new file mode 100644 index 0000000000..106684e385 --- /dev/null +++ b/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go @@ -0,0 +1,180 @@ +package service + +import ( + "fmt" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStore/adapter" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/bean" + util2 "github.com/devtron-labs/devtron/util" + "github.com/go-pg/pg" + "net/http" +) + +func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { + + var isInternalUse = impl.deploymentTypeConfig.IsInternalUse + + isGitOpsConfigured := false + gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) + return nil, err + } + if gitOpsConfig != nil && gitOpsConfig.Id > 0 { + isGitOpsConfigured = true + } + + if isInternalUse && !isGitOpsConfigured && installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD { + impl.logger.Errorw("gitops not configured but selected for CD") + err := &util.ApiError{ + HttpStatusCode: http.StatusBadRequest, + InternalMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", + UserMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", + } + return nil, err + } + + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) + if err != nil { + impl.logger.Errorw("fetching error", "err", err) + return nil, err + } + + var isOCIRepo bool + if appStoreAppVersion.AppStore.DockerArtifactStore != nil { + isOCIRepo = true + } else { + isOCIRepo = false + } + + var appInstallationMode string + if util2.IsBaseStack() || util2.IsHelmApp(installAppVersionRequest.AppOfferingMode) { + appInstallationMode = util2.SERVER_MODE_HYPERION + } else { + appInstallationMode = util2.SERVER_MODE_FULL + } + + // create env if env not exists for clusterId and namespace for hyperion mode + if util2.IsHelmApp(appInstallationMode) { + envId, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) + if err != nil { + return nil, err + } + installAppVersionRequest.EnvironmentId = envId + } + + environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching error", "err", err) + return nil, err + } + installAppVersionRequest.Environment = environment + installAppVersionRequest.ACDAppName = fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.Environment.Name) + installAppVersionRequest.ClusterId = environment.ClusterId + appCreateRequest := &bean.CreateAppDTO{ + Id: installAppVersionRequest.AppId, + AppName: installAppVersionRequest.AppName, + TeamId: installAppVersionRequest.TeamId, + UserId: installAppVersionRequest.UserId, + } + + appCreateRequest, err = impl.createAppForAppStore(appCreateRequest, tx, appInstallationMode, skipAppCreation) + if err != nil { + impl.logger.Errorw("error while creating app", "error", err) + return nil, err + } + installAppVersionRequest.AppId = appCreateRequest.Id + + if !isInternalUse { + if isGitOpsConfigured && appInstallationMode == util2.SERVER_MODE_FULL && !isOCIRepo { + installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD + } else { + installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM + } + } + if installAppVersionRequest.DeploymentAppType == "" { + if isGitOpsConfigured && !isOCIRepo { + installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD + } else { + installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM + } + } + + if util2.IsFullStack() { + installAppVersionRequest.GitOpsRepoName = impl.ChartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) + } + + installedAppModel := adapter.NewInstallAppModel(installAppVersionRequest, appStoreBean.DEPLOY_INIT) + installedApp, err := impl.installedAppRepository.CreateInstalledApp(installedAppModel, tx) + if err != nil { + impl.logger.Errorw("error while creating install app", "error", err) + return nil, err + } + installAppVersionRequest.InstalledAppId = installedApp.Id + + installedAppVersions := adapter.NewInstallAppVersionsModel(installAppVersionRequest) + _, err = impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersions, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + + installAppVersionRequest.InstalledAppVersionId = installedAppVersions.Id + installAppVersionRequest.Id = installedAppVersions.Id + + helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ + InstallAppVersionHistoryId: 0, + Message: "Install initiated", + IsReleaseInstalled: false, + ErrorInInstallation: false, + } + installedAppVersionHistory, err := adapter.NewInstallAppVersionHistoryModel(installAppVersionRequest, pipelineConfig.WorkflowInProgress, helmInstallConfigDTO) + if err != nil { + impl.logger.Errorw("error in helm install config marshal", "err", err) + } + _, err = impl.installedAppRepositoryHistory.CreateInstalledAppVersionHistory(installedAppVersionHistory, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + + installAppVersionRequest.InstalledAppVersionHistoryId = installedAppVersionHistory.Id + if installAppVersionRequest.DefaultClusterComponent { + clusterInstalledAppsModel := adapter.NewClusterInstalledAppsModel(installAppVersionRequest, environment.ClusterId) + err = impl.clusterInstalledAppsRepository.Save(clusterInstalledAppsModel, tx) + if err != nil { + impl.logger.Errorw("error while creating cluster install app", "error", err) + return nil, err + } + } + return installAppVersionRequest, nil +} + +func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return false, err + } + // Rollback tx on error. + defer tx.Rollback() + installedApp, err := impl.installedAppRepository.GetInstalledApp(installAppId) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return false, err + } + installedApp.Status = status + _, err = impl.installedAppRepository.UpdateInstalledApp(installedApp, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return false, err + } + err = tx.Commit() + if err != nil { + impl.logger.Errorw("error while commit db transaction to db", "error", err) + return false, err + } + return true, nil +} diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index a06b2c76dc..597eb63971 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -33,6 +33,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository3 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" @@ -72,7 +73,6 @@ type AppStoreDeploymentService interface { GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error - UpdateNotesForInstalledApp(installAppId int, notes string) (bool, error) UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error } @@ -141,238 +141,6 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep return appStoreDeploymentServiceImpl } -func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { - - var isInternalUse = impl.deploymentTypeConfig.IsInternalUse - - isGitOpsConfigured := false - gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) - return nil, err - } - if gitOpsConfig != nil && gitOpsConfig.Id > 0 { - isGitOpsConfigured = true - } - - if isInternalUse && !isGitOpsConfigured && installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD { - impl.logger.Errorw("gitops not configured but selected for CD") - err := &util.ApiError{ - HttpStatusCode: http.StatusBadRequest, - InternalMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", - UserMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", - } - return nil, err - } - - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - - var isOCIRepo bool - if appStoreAppVersion.AppStore.DockerArtifactStore != nil { - isOCIRepo = true - } else { - isOCIRepo = false - } - - var appInstallationMode string - if util2.IsBaseStack() || util2.IsHelmApp(installAppVersionRequest.AppOfferingMode) { - appInstallationMode = util2.SERVER_MODE_HYPERION - } else { - appInstallationMode = util2.SERVER_MODE_FULL - } - - // create env if env not exists for clusterId and namespace for hyperion mode - if util2.IsHelmApp(appInstallationMode) { - envId, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) - if err != nil { - return nil, err - } - installAppVersionRequest.EnvironmentId = envId - } - - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - installAppVersionRequest.Environment = environment - installAppVersionRequest.ACDAppName = fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.Environment.Name) - installAppVersionRequest.ClusterId = environment.ClusterId - appCreateRequest := &bean.CreateAppDTO{ - Id: installAppVersionRequest.AppId, - AppName: installAppVersionRequest.AppName, - TeamId: installAppVersionRequest.TeamId, - UserId: installAppVersionRequest.UserId, - } - - appCreateRequest, err = impl.createAppForAppStore(appCreateRequest, tx, appInstallationMode, skipAppCreation) - if err != nil { - impl.logger.Errorw("error while creating app", "error", err) - return nil, err - } - installAppVersionRequest.AppId = appCreateRequest.Id - - installedAppModel := &repository.InstalledApps{ - AppId: appCreateRequest.Id, - EnvironmentId: environment.Id, - Status: appStoreBean.DEPLOY_INIT, - } - - if !isInternalUse { - if isGitOpsConfigured && appInstallationMode == util2.SERVER_MODE_FULL && !isOCIRepo { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - if installAppVersionRequest.DeploymentAppType == "" { - if isGitOpsConfigured && !isOCIRepo { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - - installedAppModel.DeploymentAppType = installAppVersionRequest.DeploymentAppType - installedAppModel.CreatedBy = installAppVersionRequest.UserId - installedAppModel.UpdatedBy = installAppVersionRequest.UserId - installedAppModel.CreatedOn = time.Now() - installedAppModel.UpdatedOn = time.Now() - installedAppModel.Active = true - if util2.IsFullStack() { - installedAppModel.GitOpsRepoName = impl.ChartTemplateService.GetGitOpsRepoName(installAppVersionRequest.AppName) - installAppVersionRequest.GitOpsRepoName = installedAppModel.GitOpsRepoName - } - installedApp, err := impl.installedAppRepository.CreateInstalledApp(installedAppModel, tx) - if err != nil { - impl.logger.Errorw("error while creating install app", "error", err) - return nil, err - } - installAppVersionRequest.InstalledAppId = installedApp.Id - - installedAppVersions := &repository.InstalledAppVersions{ - InstalledAppId: installAppVersionRequest.InstalledAppId, - AppStoreApplicationVersionId: appStoreAppVersion.Id, - ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, - //Values: "{}", - } - installedAppVersions.CreatedBy = installAppVersionRequest.UserId - installedAppVersions.UpdatedBy = installAppVersionRequest.UserId - installedAppVersions.CreatedOn = time.Now() - installedAppVersions.UpdatedOn = time.Now() - installedAppVersions.Active = true - installedAppVersions.ReferenceValueId = installAppVersionRequest.ReferenceValueId - installedAppVersions.ReferenceValueKind = installAppVersionRequest.ReferenceValueKind - _, err = impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersions, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - installAppVersionRequest.InstalledAppVersionId = installedAppVersions.Id - installAppVersionRequest.Id = installedAppVersions.Id - - installedAppVersionHistory := &repository.InstalledAppVersionHistory{} - installedAppVersionHistory.InstalledAppVersionId = installedAppVersions.Id - installedAppVersionHistory.ValuesYamlRaw = installAppVersionRequest.ValuesOverrideYaml - installedAppVersionHistory.CreatedBy = installAppVersionRequest.UserId - installedAppVersionHistory.CreatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.StartedOn = time.Now() - installedAppVersionHistory.Status = pipelineConfig.WorkflowInProgress - helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ - InstallAppVersionHistoryId: 0, - Message: "Install initiated", - IsReleaseInstalled: false, - ErrorInInstallation: false, - } - helmInstallConfig, err := json.Marshal(helmInstallConfigDTO) - if err != nil { - impl.logger.Errorw("error in helm install config marshal", "err") - } - installedAppVersionHistory.HelmReleaseStatusConfig = string(helmInstallConfig) - _, err = impl.installedAppRepositoryHistory.CreateInstalledAppVersionHistory(installedAppVersionHistory, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - installAppVersionRequest.InstalledAppVersionHistoryId = installedAppVersionHistory.Id - if installAppVersionRequest.DefaultClusterComponent { - clusterInstalledAppsModel := &repository.ClusterInstalledApps{ - ClusterId: environment.ClusterId, - InstalledAppId: installAppVersionRequest.InstalledAppId, - } - clusterInstalledAppsModel.CreatedBy = installAppVersionRequest.UserId - clusterInstalledAppsModel.UpdatedBy = installAppVersionRequest.UserId - clusterInstalledAppsModel.CreatedOn = time.Now() - clusterInstalledAppsModel.UpdatedOn = time.Now() - err = impl.clusterInstalledAppsRepository.Save(clusterInstalledAppsModel, tx) - if err != nil { - impl.logger.Errorw("error while creating cluster install app", "error", err) - return nil, err - } - } - return installAppVersionRequest, nil -} - -func (impl AppStoreDeploymentServiceImpl) UpdateNotesForInstalledApp(installAppId int, notes string) (bool, error) { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return false, err - } - // Rollback tx on error. - defer tx.Rollback() - installedApp, err := impl.installedAppRepository.GetInstalledApp(installAppId) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return false, err - } - installedApp.Notes = notes - _, err = impl.installedAppRepository.UpdateInstalledApp(installedApp, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return false, err - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while commit db transaction to db", "error", err) - return false, err - } - return true, nil -} - -func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return false, err - } - // Rollback tx on error. - defer tx.Rollback() - installedApp, err := impl.installedAppRepository.GetInstalledApp(installAppId) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return false, err - } - installedApp.Status = status - _, err = impl.installedAppRepository.UpdateInstalledApp(installedApp, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return false, err - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while commit db transaction to db", "error", err) - return false, err - } - return true, nil -} - func (impl *AppStoreDeploymentServiceImpl) IsChartRepoActive(appStoreVersionId int) (bool, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(appStoreVersionId) if err != nil { @@ -402,7 +170,7 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a impl.logger.Errorw(" error", "err", err) return nil, err } - impl.updateDeploymentParametersInRequest(installAppVersionRequest, installAppVersionRequest.DeploymentAppType) + installedAppDeploymentAction := adapter.NewInstalledAppDeploymentAction(installAppVersionRequest.DeploymentAppType) if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) || util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) @@ -419,7 +187,7 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a } var gitOpsResponse *appStoreDeploymentCommon.AppStoreGitOpsResponse - if installAppVersionRequest.PerformGitOps { + if installedAppDeploymentAction.PerformGitOps { gitOpsResponse, err = impl.appStoreDeploymentCommonService.GitOpsOperations(manifest, installAppVersionRequest) if err != nil { impl.logger.Errorw("error in doing gitops operation", "err", err) @@ -603,26 +371,12 @@ func (impl AppStoreDeploymentServiceImpl) GetInstalledApp(id int) (*appStoreBean impl.logger.Errorw("error while fetching from db", "error", err) return nil, err } - chartTemplate := impl.chartAdaptor2(app) + chartTemplate := adapter.GenerateInstallAppVersionMinDTO(app) return chartTemplate, nil } -// converts db object to bean -func (impl AppStoreDeploymentServiceImpl) chartAdaptor2(chart *repository.InstalledApps) *appStoreBean.InstallAppVersionDTO { - return &appStoreBean.InstallAppVersionDTO{ - EnvironmentId: chart.EnvironmentId, - InstalledAppId: chart.Id, - AppId: chart.AppId, - AppOfferingMode: chart.App.AppOfferingMode, - ClusterId: chart.Environment.ClusterId, - Namespace: chart.Environment.Namespace, - AppName: chart.App.AppName, - EnvironmentName: chart.Environment.Name, - } -} - func (impl AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) { - installedApps, err := impl.installedAppRepository.GetAllIntalledAppsByAppStoreId(appStoreId) + installedApps, err := impl.installedAppRepository.GetAllInstalledAppsByAppStoreId(appStoreId) if err != nil && !util.IsErrNoRows(err) { impl.logger.Error(err) return nil, err @@ -1298,27 +1052,6 @@ func (impl *AppStoreDeploymentServiceImpl) CheckIfMonoRepoMigrationRequired(inst return monoRepoMigrationRequired } -func (impl *AppStoreDeploymentServiceImpl) updateDeploymentParametersInRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, deploymentAppType string) { - - installAppVersionRequest.DeploymentAppType = deploymentAppType - - switch installAppVersionRequest.DeploymentAppType { - case util.PIPELINE_DEPLOYMENT_TYPE_ACD: - installAppVersionRequest.PerformGitOps = true - installAppVersionRequest.PerformACDDeployment = true - installAppVersionRequest.PerformHelmDeployment = false - case util.PIPELINE_DEPLOYMENT_TYPE_HELM: - installAppVersionRequest.PerformGitOps = false - installAppVersionRequest.PerformACDDeployment = false - installAppVersionRequest.PerformHelmDeployment = true - case util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD: - installAppVersionRequest.PerformGitOps = false - installAppVersionRequest.PerformHelmDeployment = false - installAppVersionRequest.PerformACDDeployment = false - } - -} - func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { // db operations @@ -1334,8 +1067,9 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex if err != nil { return nil, err } + installAppVersionRequest.UpdateDeploymentAppType(installedApp.DeploymentAppType) - impl.updateDeploymentParametersInRequest(installAppVersionRequest, installedApp.DeploymentAppType) + installedAppDeploymentAction := adapter.NewInstalledAppDeploymentAction(installedApp.DeploymentAppType) var installedAppVersion *repository.InstalledAppVersions @@ -1433,7 +1167,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex monoRepoMigrationRequired := false gitOpsResponse := &appStoreDeploymentCommon.AppStoreGitOpsResponse{} - if installAppVersionRequest.PerformGitOps { + if installedAppDeploymentAction.PerformGitOps { // required if gitOps repo name is changed, gitOps repo name will change if env variable which we use as suffix changes gitOpsRepoName := installedApp.GitOpsRepoName @@ -1511,14 +1245,14 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } } - if installAppVersionRequest.PerformACDDeployment { + if installedAppDeploymentAction.PerformACDDeployment { // refresh update repo details on ArgoCD if repo is changed err = impl.appStoreDeploymentArgoCdService.UpdateAndSyncACDApps(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, monoRepoMigrationRequired, ctx, tx) if err != nil { impl.logger.Errorw("error in acd patch request", "err", err) return nil, err } - } else if installAppVersionRequest.PerformHelmDeployment { + } else if installedAppDeploymentAction.PerformHelmDeployment { err = impl.appStoreDeploymentHelmService.UpdateChartInfo(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, installAppVersionRequest.InstalledAppVersionHistoryId, ctx) if err != nil { if err != nil { diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go index 79a6fd1f9f..e0589afb1b 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go @@ -9,7 +9,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" repository5 "github.com/devtron-labs/devtron/pkg/auth/user/repository" @@ -134,7 +134,7 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl db, _ := sql.NewDbConnection(config, sugaredLogger) gitOpsRepository := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - chartGroupDeploymentRepository := repository5.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + chartGroupDeploymentRepository := repository6.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) appStoreDiscoverRepository := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) @@ -171,11 +171,11 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl clusterService, nil, nil, - nil, InstalledAppVersionHistoryRepository, gitOpsRepository, nil, &DeploymentServiceTypeConfig{IsInternalUse: internalUse}, + nil, nil) return AppStoreDeploymentServiceImpl diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index aebe347bcd..a6192db3e6 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -172,7 +172,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, k8sApplicationService: k8sApplicationService, acdConfig: acdConfig, } - err := impl.Subscribe() + err := impl.subscribe() if err != nil { return nil, err } @@ -606,7 +606,7 @@ func (impl *InstalledAppServiceImpl) triggerDeploymentEvent(installAppVersions [ } } -func (impl *InstalledAppServiceImpl) Subscribe() error { +func (impl *InstalledAppServiceImpl) subscribe() error { callback := func(msg *model.PubSubMsg) { impl.logger.Debug("cd stage event received") //defer msg.Ack() diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index b28d642ec6..4c70d39142 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -4,13 +4,10 @@ import ( "testing" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" - repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository" repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" @@ -28,9 +25,6 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { type fields struct { logger *zap.SugaredLogger installedAppRepository repository4.InstalledAppRepository - chartTemplateService util.ChartTemplateService - refChartDir appStoreBean.RefChartProxyDir - repositoryService repository2.ServiceClient appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository.EnvironmentRepository teamRepository team.TeamRepository @@ -38,10 +32,8 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { acdClient application.ServiceClient appStoreValuesService service.AppStoreValuesService pubsubClient *pubsub.PubSubClientServiceImpl - tokenCache *util2.TokenCache chartGroupDeploymentRepository repository5.ChartGroupDeploymentRepository envService cluster.EnvironmentService - ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *util.GitFactory aCDAuthConfig *util2.ACDAuthConfig gitOpsRepository repository3.GitOpsConfigRepository @@ -65,11 +57,9 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { impl := &InstalledAppServiceImpl{ - logger: tt.fields.logger, - installedAppRepository: tt.fields.installedAppRepository, - chartTemplateService: tt.fields.chartTemplateService, - refChartDir: tt.fields.refChartDir, - repositoryService: tt.fields.repositoryService, + logger: tt.fields.logger, + installedAppRepository: tt.fields.installedAppRepository, + appStoreApplicationVersionRepository: tt.fields.appStoreApplicationVersionRepository, environmentRepository: tt.fields.environmentRepository, teamRepository: tt.fields.teamRepository, @@ -77,10 +67,8 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { acdClient: tt.fields.acdClient, appStoreValuesService: tt.fields.appStoreValuesService, pubsubClient: tt.fields.pubsubClient, - tokenCache: tt.fields.tokenCache, chartGroupDeploymentRepository: tt.fields.chartGroupDeploymentRepository, envService: tt.fields.envService, - ArgoK8sClient: tt.fields.ArgoK8sClient, gitFactory: tt.fields.gitFactory, aCDAuthConfig: tt.fields.aCDAuthConfig, gitOpsRepository: tt.fields.gitOpsRepository, diff --git a/pkg/appStore/deployment/service/Notes.go b/pkg/appStore/deployment/service/Notes.go index 88ce454af6..33595afc25 100644 --- a/pkg/appStore/deployment/service/Notes.go +++ b/pkg/appStore/deployment/service/Notes.go @@ -9,6 +9,54 @@ import ( "regexp" ) +func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { + //check notes.txt in db + installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) + if err != nil && err != pg.ErrNoRows { + return "", err + } + installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) + if err != nil { + if err == pg.ErrNoRows { + return "", fmt.Errorf("values are outdated. please fetch the latest version and try again") + } + impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) + return "", err + } + chartVersion := installedAppVerison.AppStoreApplicationVersion.Version + if err != nil { + impl.logger.Errorw("error fetching chart version in installed app service", "err", err) + return "", err + } + re := regexp.MustCompile(`CHART VERSION: ([0-9]+\.[0-9]+\.[0-9]+)`) + newStr := re.ReplaceAllString(installedApp.Notes, "CHART VERSION: "+chartVersion) + installedApp.Notes = newStr + appName := installedApp.App.AppName + if err != nil { + impl.logger.Errorw("error fetching notes from db", "err", err) + return "", err + } + isValidAuth := checkNotesAuth(token, appName, envId) + if !isValidAuth { + impl.logger.Errorw("unauthorized user", "isValidAuth", isValidAuth) + return "", fmt.Errorf("unauthorized user") + } + //if notes is not present in db then below call will happen + if installedApp.Notes == "" { + notes, _, err := impl.findNotesForArgoApplication(installedAppId, envId) + if err != nil { + impl.logger.Errorw("error fetching notes", "err", err) + return "", err + } + if notes == "" { + impl.logger.Errorw("error fetching notes", "err", err) + } + return notes, err + } + + return installedApp.Notes, nil +} + func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, envId int) (string, string, error) { installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) if err != nil { @@ -60,7 +108,7 @@ func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, impl.logger.Errorw("error in fetching notes", "err", err) return notes, appName, err } - _, err = impl.appStoreDeploymentService.UpdateNotesForInstalledApp(installedAppId, notes) + _, err = impl.updateNotesForInstalledApp(installedAppId, notes) if err != nil { impl.logger.Errorw("error in updating notes in db ", "err", err) return notes, appName, err @@ -69,50 +117,31 @@ func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, return notes, appName, nil } -func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { - //check notes.txt in db - installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) - if err != nil && err != pg.ErrNoRows { - return "", err - } - installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) + +// updateNotesForInstalledApp will update the notes in repository.InstalledApps table +func (impl *InstalledAppServiceImpl) updateNotesForInstalledApp(installAppId int, notes string) (bool, error) { + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() if err != nil { - if err == pg.ErrNoRows { - return "", fmt.Errorf("values are outdated. please fetch the latest version and try again") - } - impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) - return "", err + return false, err } - chartVersion := installedAppVerison.AppStoreApplicationVersion.Version + // Rollback tx on error. + defer tx.Rollback() + installedApp, err := impl.installedAppRepository.GetInstalledApp(installAppId) if err != nil { - impl.logger.Errorw("error fetching chart version in installed app service", "err", err) - return "", err + impl.logger.Errorw("error while fetching from db", "error", err) + return false, err } - re := regexp.MustCompile(`CHART VERSION: ([0-9]+\.[0-9]+\.[0-9]+)`) - newStr := re.ReplaceAllString(installedApp.Notes, "CHART VERSION: "+chartVersion) - installedApp.Notes = newStr - appName := installedApp.App.AppName + installedApp.Notes = notes + _, err = impl.installedAppRepository.UpdateInstalledApp(installedApp, tx) if err != nil { - impl.logger.Errorw("error fetching notes from db", "err", err) - return "", err + impl.logger.Errorw("error while fetching from db", "error", err) + return false, err } - isValidAuth := checkNotesAuth(token, appName, envId) - if !isValidAuth { - impl.logger.Errorw("unauthorized user", "isValidAuth", isValidAuth) - return "", fmt.Errorf("unauthorized user") - } - //if notes is not present in db then below call will happen - if installedApp.Notes == "" { - notes, _, err := impl.findNotesForArgoApplication(installedAppId, envId) - if err != nil { - impl.logger.Errorw("error fetching notes", "err", err) - return "", err - } - if notes == "" { - impl.logger.Errorw("error fetching notes", "err", err) - } - return notes, err + err = tx.Commit() + if err != nil { + impl.logger.Errorw("error while commit db transaction to db", "error", err) + return false, err } - - return installedApp.Notes, nil + return true, nil } diff --git a/pkg/sql/UtilStructs.go b/pkg/sql/UtilStructs.go index bb8553f1e5..a067135431 100644 --- a/pkg/sql/UtilStructs.go +++ b/pkg/sql/UtilStructs.go @@ -36,3 +36,17 @@ func NewDefaultAuditLog(userId int32) AuditLog { UpdatedBy: userId, } } + +// CreateAuditLog can be used by any repository to create AuditLog for insert operation +func (model *AuditLog) CreateAuditLog(userId int32) { + model.CreatedOn = time.Now() + model.UpdatedOn = time.Now() + model.CreatedBy = userId + model.UpdatedBy = userId +} + +// UpdateAuditLog can be used by any repository to update AuditLog for update operation +func (model *AuditLog) UpdateAuditLog(userId int32) { + model.UpdatedOn = time.Now() + model.UpdatedBy = userId +} From 4842b83b1a744b8a0115b155e1af85021587e8f7 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 18 Jan 2024 17:30:20 +0530 Subject: [PATCH 26/83] review changes --- api/deployment/DeploymentConfigRestHandler.go | 9 ++- internal/util/ChartService.go | 12 ++-- pkg/app/AppService.go | 5 +- pkg/chart/ChartService.go | 4 +- .../repository/ChartRefRepository.go | 10 +-- .../chartRef/ChartRefService.go | 64 +++++++++---------- .../deploymentTemplate/chartRef/bean/bean.go | 11 ++-- .../DeployementTemplateService.go | 2 +- pkg/pipeline/WorkflowDagExecutor.go | 3 +- 9 files changed, 57 insertions(+), 63 deletions(-) diff --git a/api/deployment/DeploymentConfigRestHandler.go b/api/deployment/DeploymentConfigRestHandler.go index 8e27a52a5d..ac877b17cc 100644 --- a/api/deployment/DeploymentConfigRestHandler.go +++ b/api/deployment/DeploymentConfigRestHandler.go @@ -17,7 +17,6 @@ import ( "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/chart" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/gorilla/mux" "github.com/juju/errors" @@ -99,7 +98,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo return } - chartInfo, err := handler.chartRefService.ExtractChartIfMissing(fileBytes, chartRepoRepository.RefChartDirPath, "") + chartInfo, err := handler.chartRefService.ExtractChartIfMissing(fileBytes, bean.RefChartDirPath, "") if err != nil { if chartInfo != nil && chartInfo.TemporaryFolder != "" { @@ -108,7 +107,7 @@ func (handler *DeploymentConfigRestHandlerImpl) CreateChartFromFile(w http.Respo handler.Logger.Errorw("error in deleting temp dir ", "err", err1) } } - if err.Error() == bean.CHART_ALREADY_EXISTS_INTERNAL_ERROR || err.Error() == bean.CHART_NAME_RESERVED_INTERNAL_ERROR { + if err.Error() == bean.ChartAlreadyExistsInternalError || err.Error() == bean.ChartNameReservedInternalError { common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } @@ -175,7 +174,7 @@ func (handler *DeploymentConfigRestHandlerImpl) SaveChart(w http.ResponseWriter, return } - location := filepath.Join(chartRepoRepository.RefChartDirPath, request.FileId) + location := filepath.Join(bean.RefChartDirPath, request.FileId) if request.Action == "Save" { file, err := ioutil.ReadFile(filepath.Join(location, "output.json")) if err != nil { @@ -231,7 +230,7 @@ func (handler *DeploymentConfigRestHandlerImpl) DownloadChart(w http.ResponseWri common.WriteJsonResp(w, fmt.Errorf("error in parsing chartRefId : %s must be integer", chartRefId), nil, http.StatusBadRequest) return } - manifestByteArr, err := handler.chartRefService.GetCustomChartInBytes(chartRefId) + manifestByteArr, err := handler.chartRefService.GetChartInBytes(chartRefId) if err != nil { handler.Logger.Errorw("error in converting chart to bytes", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) diff --git a/internal/util/ChartService.go b/internal/util/ChartService.go index 2deb276c30..d40c5ff39e 100644 --- a/internal/util/ChartService.go +++ b/internal/util/ChartService.go @@ -51,7 +51,7 @@ const ( PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd" PIPELINE_DEPLOYMENT_TYPE_HELM = "helm" PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD = "manifest_download" - ChartWorkingDirPath = "/tmp/charts/" + CHART_WORKING_DIR_PATH = "/tmp/charts/" ) type ChartCreateRequest struct { @@ -148,7 +148,7 @@ func (impl ChartTemplateServiceImpl) GetChartVersion(location string) (string, e func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData *chart.Metadata, refChartLocation string, templateName string, userId int32, pipelineStrategyPath string) (*ChartValues, *ChartGitAttribute, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - chartDir := filepath.Join(ChartWorkingDirPath, dir) + chartDir := filepath.Join(CHART_WORKING_DIR_PATH, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -188,7 +188,7 @@ func (impl ChartTemplateServiceImpl) FetchValuesFromReferenceChart(chartMetaData func (impl ChartTemplateServiceImpl) BuildChart(ctx context.Context, chartMetaData *chart.Metadata, referenceTemplatePath string) (string, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - tempReferenceTemplateDir := filepath.Join(ChartWorkingDirPath, dir) + tempReferenceTemplateDir := filepath.Join(CHART_WORKING_DIR_PATH, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir) err := os.MkdirAll(tempReferenceTemplateDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -216,7 +216,7 @@ func (impl ChartTemplateServiceImpl) BuildChartProxyForHelmApps(chartCreateReque chartMetaData := chartCreateRequest.ChartMetaData chartMetaData.ApiVersion = "v2" // ensure always v2 dir := impl.GetDir() - chartDir := filepath.Join(ChartWorkingDirPath, dir) + chartDir := filepath.Join(CHART_WORKING_DIR_PATH, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -482,7 +482,7 @@ func (impl ChartTemplateServiceImpl) GetDir() string { func (impl ChartTemplateServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, *ChartGitAttribute, error) { chartMetaData.ApiVersion = "v2" // ensure always v2 dir := impl.GetDir() - chartDir := filepath.Join(ChartWorkingDirPath, dir) + chartDir := filepath.Join(CHART_WORKING_DIR_PATH, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling if err != nil { @@ -664,7 +664,7 @@ func (impl ChartTemplateServiceImpl) GetGitOpsRepoNameFromUrl(gitRepoUrl string) func (impl ChartTemplateServiceImpl) GetByteArrayRefChart(chartMetaData *chart.Metadata, referenceTemplatePath string) ([]byte, error) { chartMetaData.ApiVersion = "v1" // ensure always v1 dir := impl.GetDir() - tempReferenceTemplateDir := filepath.Join(ChartWorkingDirPath, dir) + tempReferenceTemplateDir := filepath.Join(CHART_WORKING_DIR_PATH, dir) impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", tempReferenceTemplateDir) err := os.MkdirAll(tempReferenceTemplateDir, os.ModePerm) //hack for concurrency handling if err != nil { diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 5a17c7dfcd..1e4b6cbb8b 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + bean3 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "io/ioutil" "net/url" "os" @@ -873,7 +874,7 @@ func (impl *AppServiceImpl) BuildChartAndGetPath(appName string, envOverride *ch Name: appName, Version: envOverride.Chart.ChartVersion, } - referenceTemplatePath := path.Join(chartRepoRepository.RefChartDirPath, envOverride.Chart.ReferenceTemplate) + referenceTemplatePath := path.Join(bean3.RefChartDirPath, envOverride.Chart.ReferenceTemplate) // Load custom charts to referenceTemplatePath if not exists if _, err := os.Stat(referenceTemplatePath); os.IsNotExist(err) { chartRefValue, err := impl.chartRefService.FindById(envOverride.Chart.ChartRefId) @@ -882,7 +883,7 @@ func (impl *AppServiceImpl) BuildChartAndGetPath(appName string, envOverride *ch return "", err } if chartRefValue.ChartData != nil { - chartInfo, err := impl.chartRefService.ExtractChartIfMissing(chartRefValue.ChartData, chartRepoRepository.RefChartDirPath, chartRefValue.Location) + chartInfo, err := impl.chartRefService.ExtractChartIfMissing(chartRefValue.ChartData, bean3.RefChartDirPath, chartRefValue.Location) if chartInfo != nil && chartInfo.TemporaryFolder != "" { err1 := os.RemoveAll(chartInfo.TemporaryFolder) if err1 != nil { diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 536b336c37..58222ac4e2 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -168,7 +168,7 @@ func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context return nil, err } - refChart, templateName, err, _, pipelineStrategyPath := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) + refChart, templateName, _, pipelineStrategyPath, err := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) if err != nil { return nil, err } @@ -334,7 +334,7 @@ func (impl ChartServiceImpl) CreateChartFromEnvOverride(templateRequest Template return nil, err } - refChart, templateName, err, _, pipelineStrategyPath := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) + refChart, templateName, _, pipelineStrategyPath, err := impl.chartRefService.GetRefChart(templateRequest.ChartRefId) if err != nil { return nil, err } diff --git a/pkg/chartRepo/repository/ChartRefRepository.go b/pkg/chartRepo/repository/ChartRefRepository.go index 33f9d69fc5..b62a9d280f 100644 --- a/pkg/chartRepo/repository/ChartRefRepository.go +++ b/pkg/chartRepo/repository/ChartRefRepository.go @@ -7,10 +7,6 @@ import ( "strings" ) -const ( - RefChartDirPath = "scripts/devtron-reference-helm-charts" -) - type ChartRef struct { tableName struct{} `sql:"chart_ref" pg:",discard_unknown_columns"` Id int `sql:"id,pk"` @@ -44,7 +40,7 @@ type ChartRefRepository interface { CheckIfDataExists(location string) (bool, error) FetchChart(name string) ([]*ChartRef, error) FetchInfoOfChartConfiguredInApp(appId int) (*ChartRef, error) - FetchAllChartInfoByUploadFlag(userUploaded bool) ([]*ChartRef, error) + FetchAllNonUserUploadedChartInfo() ([]*ChartRef, error) } type ChartRefRepositoryImpl struct { dbConnection *pg.DB @@ -124,10 +120,10 @@ func (impl ChartRefRepositoryImpl) FetchChart(name string) ([]*ChartRef, error) return chartRefs, err } -func (impl ChartRefRepositoryImpl) FetchAllChartInfoByUploadFlag(userUploaded bool) ([]*ChartRef, error) { +func (impl ChartRefRepositoryImpl) FetchAllNonUserUploadedChartInfo() ([]*ChartRef, error) { var repo []*ChartRef err := impl.dbConnection.Model(&repo). - Where("user_uploaded = ?", userUploaded). + Where("user_uploaded = ?", false). Select() if err != nil { return repo, err diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go index 2b10d904b6..58964b0876 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -24,6 +24,8 @@ import ( ) type ChartRefService interface { + //below methods are for getting data from db + GetDefault() (*bean.ChartRefDto, error) GetAll() ([]*bean.ChartRefDto, error) GetAllChartMetadata() (map[string]bean.ChartRefMetaData, error) @@ -31,22 +33,23 @@ type ChartRefService interface { FindByVersionAndName(version, name string) (*bean.ChartRefDto, error) FetchInfoOfChartConfiguredInApp(appId int) (*bean.ChartRefDto, error) ChartRefAutocomplete() ([]*bean.ChartRefAutocompleteDto, error) + CheckChartExists(chartRefId int) error + ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) + + //below methods are for custom chart SaveCustomChart(req *bean.CustomChartRefDto) error FetchCustomChartsInfo() ([]*bean.ChartDto, error) ValidateCustomChartUploadedFileFormat(fileName string) error - GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) + //below methods are for chart file data actions + GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) - - ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) - - CheckChartExists(chartRefId int) error - GetRefChart(chartRefId int) (string, string, error, string, string) + GetRefChart(chartRefId int) (string, string, string, string, error) ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*bean.ChartDataInfo, error) - GetCustomChartInBytes(chartRefId int) ([]byte, error) + GetChartInBytes(chartRefId int) ([]byte, error) } type ChartRefServiceImpl struct { @@ -61,7 +64,7 @@ func NewChartRefServiceImpl(logger *zap.SugaredLogger, chartTemplateService util.ChartTemplateService, mergeUtil util.MergeUtil) *ChartRefServiceImpl { // cache devtron reference charts list - devtronChartList, _ := chartRefRepository.FetchAllChartInfoByUploadFlag(false) + devtronChartList, _ := chartRefRepository.FetchAllNonUserUploadedChartInfo() setReservedChartList(devtronChartList) return &ChartRefServiceImpl{ logger: logger, @@ -165,7 +168,7 @@ func (impl *ChartRefServiceImpl) SaveCustomChart(req *bean.CustomChartRefDto) er return nil } -func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, error, string, string) { +func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, string, string, error) { var template string var version string //path of file in chart from where strategy config is to be taken @@ -175,12 +178,12 @@ func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, er if err != nil { chartRef, err = impl.chartRefRepository.GetDefault() if err != nil { - return "", "", err, "", "" + return "", "", "", "", err } } else if chartRef.UserUploaded { - refChartLocation := filepath.Join(chartRepoRepository.RefChartDirPath, chartRef.Location) + refChartLocation := filepath.Join(bean.RefChartDirPath, chartRef.Location) if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { - chartInfo, err := impl.ExtractChartIfMissing(chartRef.ChartData, chartRepoRepository.RefChartDirPath, chartRef.Location) + chartInfo, err := impl.ExtractChartIfMissing(chartRef.ChartData, bean.RefChartDirPath, chartRef.Location) if chartInfo != nil && chartInfo.TemporaryFolder != "" { err1 := os.RemoveAll(chartInfo.TemporaryFolder) if err1 != nil { @@ -189,7 +192,7 @@ func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, er } if err != nil { impl.logger.Errorw("Error regarding uploaded chart", "err", err) - return "", "", err, "", "" + return "", "", "", "", err } } @@ -200,7 +203,7 @@ func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, er } else { chartRef, err := impl.chartRefRepository.GetDefault() if err != nil { - return "", "", err, "", "" + return "", "", "", "", err } template = chartRef.Location version = chartRef.Version @@ -208,17 +211,17 @@ func (impl *ChartRefServiceImpl) GetRefChart(chartRefId int) (string, string, er } //TODO VIKI- fetch from chart ref table - chartPath := path.Join(chartRepoRepository.RefChartDirPath, template) + chartPath := path.Join(bean.RefChartDirPath, template) valid, err := chartutil.IsChartDir(chartPath) if err != nil || !valid { impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) - return "", "", err, "", "" + return "", "", "", "", err } - return chartPath, template, nil, version, pipelineStrategyPath + return chartPath, template, version, pipelineStrategyPath, nil } func (impl *ChartRefServiceImpl) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) { - refChart, _, err, _, _ := impl.GetRefChart(chartRefId) + refChart, _, _, _, err := impl.GetRefChart(chartRefId) if err != nil { impl.logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) return nil, nil, err @@ -262,7 +265,7 @@ func (impl *ChartRefServiceImpl) ChartRefAutocomplete() ([]*bean.ChartRefAutocom return chartRefs, nil } -func (impl *ChartRefServiceImpl) GetCustomChartInBytes(chartRefId int) ([]byte, error) { +func (impl *ChartRefServiceImpl) GetChartInBytes(chartRefId int) ([]byte, error) { chartRef, err := impl.chartRefRepository.FindById(chartRefId) if err != nil { impl.logger.Errorw("error getting chart data", "chartRefId", chartRefId, "err", err) @@ -273,7 +276,7 @@ func (impl *ChartRefServiceImpl) GetCustomChartInBytes(chartRefId int) ([]byte, return chartRef.ChartData, nil } // For Devtron reference charts the chart will be load from the directory location - refChartPath := filepath.Join(chartRepoRepository.RefChartDirPath, chartRef.Location) + refChartPath := filepath.Join(bean.RefChartDirPath, chartRef.Location) manifestByteArr, err := impl.chartTemplateService.LoadChartInBytes(refChartPath, false) if err != nil { impl.logger.Errorw("error in converting chart to bytes", "err", err) @@ -322,9 +325,9 @@ func (impl *ChartRefServiceImpl) CheckChartExists(chartRefId int) error { impl.logger.Errorw("error in finding ref chart by id", "err", err) return err } - refChartLocation := filepath.Join(chartRepoRepository.RefChartDirPath, chartRefValue.Location) + refChartLocation := filepath.Join(bean.RefChartDirPath, chartRefValue.Location) if _, err := os.Stat(refChartLocation); os.IsNotExist(err) { - chartInfo, err := impl.ExtractChartIfMissing(chartRefValue.ChartData, chartRepoRepository.RefChartDirPath, chartRefValue.Location) + chartInfo, err := impl.ExtractChartIfMissing(chartRefValue.ChartData, bean.RefChartDirPath, chartRefValue.Location) if chartInfo != nil && chartInfo.TemporaryFolder != "" { err1 := os.RemoveAll(chartInfo.TemporaryFolder) if err1 != nil { @@ -342,7 +345,7 @@ func (impl *ChartRefServiceImpl) GetAppOverrideForDefaultTemplate(chartRefId int return nil, "", err } - refChart, _, err, _, _ := impl.GetRefChart(chartRefId) + refChart, _, _, _, err := impl.GetRefChart(chartRefId) if err != nil { return nil, "", err } @@ -396,7 +399,7 @@ func (impl *ChartRefServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[ return nil, "", err } - refChartDir, _, err, version, _ := impl.GetRefChart(chartRefId) + refChartDir, _, version, _, err := impl.GetRefChart(chartRefId) if err != nil { impl.logger.Errorw("refChartDir Not Found err, JsonSchemaExtractFromFile", err) return nil, "", err @@ -430,14 +433,7 @@ func (impl *ChartRefServiceImpl) JsonSchemaExtractFromFile(chartRefId int) (map[ func (impl *ChartRefServiceImpl) ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*bean.ChartDataInfo, error) { binaryDataReader := bytes.NewReader(chartData) dir := impl.chartTemplateService.GetDir() - chartInfo := &bean.ChartDataInfo{ - ChartName: "", - ChartVersion: "", - ChartLocation: "", - TemporaryFolder: "", - Description: "", - Message: "", - } + chartInfo := &bean.ChartDataInfo{} temporaryChartWorkingDir := filepath.Clean(filepath.Join(refChartDir, dir)) err := os.MkdirAll(temporaryChartWorkingDir, os.ModePerm) if err != nil { @@ -504,7 +500,7 @@ func (impl *ChartRefServiceImpl) ExtractChartIfMissing(chartData []byte, refChar impl.logger.Errorw("request err, chart name is reserved by Devtron") err = &util.ApiError{ Code: constants.ChartNameAlreadyReserved, - InternalMessage: bean.CHART_NAME_RESERVED_INTERNAL_ERROR, + InternalMessage: bean.ChartNameReservedInternalError, UserMessage: fmt.Sprintf("The name '%s' is reserved for a chart provided by Devtron", chartName), } return chartInfo, err @@ -520,7 +516,7 @@ func (impl *ChartRefServiceImpl) ExtractChartIfMissing(chartData []byte, refChar impl.logger.Errorw("request err, chart name and version exists already in the database") err = &util.ApiError{ Code: constants.ChartCreatedAlreadyExists, - InternalMessage: bean.CHART_ALREADY_EXISTS_INTERNAL_ERROR, + InternalMessage: bean.ChartAlreadyExistsInternalError, UserMessage: fmt.Sprintf("%s of %s exists already in the database", chartVersion, chartName), } return chartInfo, err diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go index b0f662e04e..0a2428435e 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/bean/bean.go @@ -3,11 +3,12 @@ package bean import "github.com/devtron-labs/devtron/pkg/sql" const ( - DeploymentChartType = "Deployment" - RolloutChartType = "Rollout Deployment" - ReferenceChart = "reference-chart" - CHART_ALREADY_EXISTS_INTERNAL_ERROR = "Chart exists already, try uploading another chart" - CHART_NAME_RESERVED_INTERNAL_ERROR = "Change the name of the chart and try uploading again" + DeploymentChartType = "Deployment" + RolloutChartType = "Rollout Deployment" + ReferenceChart = "reference-chart" + RefChartDirPath = "scripts/devtron-reference-helm-charts" + ChartAlreadyExistsInternalError = "Chart exists already, try uploading another chart" + ChartNameReservedInternalError = "Change the name of the chart and try uploading again" ) type ChartDataInfo struct { diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index b35924856a..5d5241d564 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -304,7 +304,7 @@ func (impl DeploymentTemplateServiceImpl) extractScopeData(request DeploymentTem } func (impl DeploymentTemplateServiceImpl) GenerateManifest(ctx context.Context, chartRefId int, valuesYaml string) (*openapi2.TemplateChartResponse, error) { - refChart, template, err, version, _ := impl.chartRefService.GetRefChart(chartRefId) + refChart, template, version, _, err := impl.chartRefService.GetRefChart(chartRefId) if err != nil { impl.Logger.Errorw("error in getting refChart", "err", err, "chartRefId", chartRefId) return nil, err diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index fd54856752..f32c6b997f 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -24,6 +24,7 @@ import ( "fmt" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + bean5 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "path" "strconv" "strings" @@ -3499,7 +3500,7 @@ func (impl *WorkflowDagExecutorImpl) createHelmAppForCdPipeline(overrideRequest Name: pipeline.App.AppName, Version: envOverride.Chart.ChartVersion, } - referenceTemplatePath := path.Join(chartRepoRepository.RefChartDirPath, envOverride.Chart.ReferenceTemplate) + referenceTemplatePath := path.Join(bean5.RefChartDirPath, envOverride.Chart.ReferenceTemplate) if util.IsHelmApp(pipeline.DeploymentAppType) { referenceChartByte := envOverride.Chart.ReferenceChart From ab494c1cf6c9000ef06290f1ae21456d4e73b235 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 19 Jan 2024 12:40:43 +0530 Subject: [PATCH 27/83] wip --- pkg/pipeline/PropertiesConfig.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 210bef4093..c9792a9240 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -367,6 +367,23 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit namespace = env.Namespace } + if isOverride { //case of override, to do app metrics operation + envLevelMetricsUpdateReq := &bean2.DeployedAppMetricsRequest{ + EnableMetrics: isAppMetricsEnabled, + AppId: chart.AppId, + EnvId: environmentId, + ChartRefId: chart.ChartRefId, + UserId: userId, + } + err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) + if err != nil { + impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) + return nil, isAppMetricsEnabled, err + } + //updating metrics flag because it might be possible that the chartRef used was not supported and that could have override the metrics flag got in request + isAppMetricsEnabled = envLevelMetricsUpdateReq.EnableMetrics + } + envOverride, err := impl.envConfigRepo.GetByChartAndEnvironment(chart.Id, environmentId) if err != nil && !errors.IsNotFound(err) { return nil, isAppMetricsEnabled, err @@ -427,20 +444,6 @@ func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoReposit impl.logger.Errorw("error in creating envconfig", "data", envOverride, "error", err) return nil, isAppMetricsEnabled, err } - envLevelMetricsUpdateReq := &bean2.DeployedAppMetricsRequest{ - EnableMetrics: isAppMetricsEnabled, - AppId: chart.AppId, - EnvId: environmentId, - ChartRefId: chart.ChartRefId, - UserId: userId, - } - err = impl.deployedAppMetricsService.CreateOrUpdateAppOrEnvLevelMetrics(context.Background(), envLevelMetricsUpdateReq) - if err != nil { - impl.logger.Errorw("error, CheckAndUpdateAppOrEnvLevelMetrics", "err", err, "req", envLevelMetricsUpdateReq) - return nil, isAppMetricsEnabled, err - } - //updating metrics flag because it might be possible that the chartRef used was not supported and that could have override the metrics flag got in request - isAppMetricsEnabled = envLevelMetricsUpdateReq.EnableMetrics err = impl.deploymentTemplateHistoryService.CreateDeploymentTemplateHistoryFromEnvOverrideTemplate(envOverride, tx, isAppMetricsEnabled, 0) if err != nil { impl.logger.Errorw("error in creating entry for env deployment template history", "err", err, "envOverride", envOverride) From 0120e15600328cc1e6380c4e4b757efba2fcbc81 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 19 Jan 2024 19:57:51 +0530 Subject: [PATCH 28/83] fix for unsupported charts --- pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index 2144b71cd5..f866a09825 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -95,7 +95,6 @@ func (impl *DeployedAppMetricsServiceImpl) CreateOrUpdateAppOrEnvLevelMetrics(ct if !(isAppMetricsSupported) { //chart does not have metrics support, disabling req.EnableMetrics = false - return nil } if req.EnvId == 0 { _, span := otel.Tracer("orchestrator").Start(ctx, "createOrUpdateAppLevelMetrics") From 0b44511ad33fcbcc26411bfe7f32957c668c8746 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Sun, 21 Jan 2024 02:50:56 +0530 Subject: [PATCH 29/83] refactoring: App Store deployment services --- Wire.go | 3 - api/appStore/InstalledAppRestHandler.go | 2 +- .../AppStoreDeploymentRestHandler.go | 5 +- .../deployment/CommonDeploymentRestHandler.go | 50 ++- api/bean/GitOpsConfig.go | 1 + api/helm-app/HelmAppRestHandler.go | 120 ++----- api/helm-app/bean.go | 24 -- api/helm-app/bean/bean.go | 82 +++++ api/helm-app/{ => gRPC}/applicationClient.go | 11 +- api/helm-app/{ => gRPC}/applist.pb.go | 2 +- api/helm-app/{ => gRPC}/applist.proto | 0 api/helm-app/{ => gRPC}/applist_grpc.pb.go | 2 +- api/helm-app/mocks/HelmAppClient.go | 220 ++++++------ api/helm-app/mocks/HelmAppService.go | 109 +++--- api/helm-app/{ => service}/HelmAppService.go | 146 ++++---- api/helm-app/wire_helmApp.go | 14 +- .../application/k8sApplicationRestHandler.go | 2 +- api/restHandler/AppListingRestHandler.go | 28 +- api/restHandler/AppRestHandler.go | 2 +- client/telemetry/TelemetryEventClient.go | 10 +- .../telemetry/TelemetryEventClientExtended.go | 2 +- cmd/external-app/wire_gen.go | 62 ++-- internal/util/ChartService.go | 28 +- pkg/app/integrationTest/AppService_test.go | 7 +- pkg/appStore/bean/bean.go | 9 - pkg/appStore/deployment/adapter/Adapter.go | 26 ++ .../common/AppStoreDeploymentCommonService.go | 259 +------------- .../common/AppStoreDeploymentGitService.go | 184 ---------- .../AppStoreDeploymentFullModeService.go | 289 --------------- .../service/AppStoreDeploymentDBService.go | 32 ++ .../service/AppStoreDeploymentService.go | 93 ++--- .../service/AppStoreDeploymentService_test.go | 2 +- .../deployment/service/InstalledAppService.go | 84 +++-- pkg/appStore/deployment/service/Notes.go | 8 +- .../deployment/service/ResourceTree.go | 4 +- .../tool/AppStoreDeploymentArgoCdService.go | 336 +++++++++++------- .../tool/AppStoreDeploymentGitOpsService.go | 272 ++++++++++++++ .../tool/AppStoreDeploymentHelmService.go | 135 +++---- pkg/appStore/deployment/tool/bean/bean.go | 17 + pkg/bulkAction/BulkUpdateService.go | 2 +- .../UserTerminalAccessService.go | 2 +- .../remote/GitOpsRemoteOperationService.go | 148 +++++--- pkg/deployment/gitOps/remote/bean/bean.go | 9 + .../DeployementTemplateService.go | 18 +- .../DeployementTemplateService_test.go | 2 +- pkg/k8s/K8sCommonService.go | 4 +- pkg/k8s/application/k8sApplicationService.go | 5 +- .../application/k8sApplicationService_test.go | 2 +- .../mocks/K8sApplicationService.go | 2 +- pkg/k8s/bean.go | 2 +- .../kubernetesResourceHistoryService.go | 2 +- pkg/module/ModuleCronService.go | 23 +- pkg/module/ModuleService.go | 5 +- .../AppDeploymentTypeChangeManager.go | 10 +- pkg/pipeline/CdHandler.go | 2 +- .../DeploymentPipelineConfigService.go | 2 +- pkg/pipeline/DockerRegistryConfig.go | 5 +- pkg/pipeline/DockerRegistryConfig_test.go | 2 +- pkg/pipeline/WorkflowDagExecutor.go | 47 +-- pkg/server/ServerCacheService.go | 2 +- pkg/server/ServerService.go | 5 +- pkg/webhook/helm/WebhookHelmService.go | 14 +- wire_gen.go | 38 +- 63 files changed, 1439 insertions(+), 1596 deletions(-) delete mode 100644 api/helm-app/bean.go create mode 100644 api/helm-app/bean/bean.go rename api/helm-app/{ => gRPC}/applicationClient.go (96%) rename api/helm-app/{ => gRPC}/applist.pb.go (99%) rename api/helm-app/{ => gRPC}/applist.proto (100%) rename api/helm-app/{ => gRPC}/applist_grpc.pb.go (99%) rename api/helm-app/{ => service}/HelmAppService.go (89%) create mode 100644 pkg/appStore/deployment/adapter/Adapter.go delete mode 100644 pkg/appStore/deployment/common/AppStoreDeploymentGitService.go delete mode 100644 pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go create mode 100644 pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go create mode 100644 pkg/appStore/deployment/tool/bean/bean.go diff --git a/Wire.go b/Wire.go index 7c6e26c779..50715f0cb8 100644 --- a/Wire.go +++ b/Wire.go @@ -87,7 +87,6 @@ import ( "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appWorkflow" @@ -713,8 +712,6 @@ func InitializeApp() (*App, error) { delete2.NewDeleteServiceFullModeImpl, wire.Bind(new(delete2.DeleteServiceFullMode), new(*delete2.DeleteServiceFullModeImpl)), - appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl, - wire.Bind(new(appStoreDeploymentFullMode.AppStoreDeploymentFullModeService), new(*appStoreDeploymentFullMode.AppStoreDeploymentFullModeServiceImpl)), appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl, wire.Bind(new(appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdServiceImpl)), // util2.NewGoJsonSchemaCustomFormatChecker, diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index c6e1427c8d..94399e6a38 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -22,13 +22,13 @@ import ( "encoding/json" "errors" "fmt" + client "github.com/devtron-labs/devtron/api/helm-app/gRPC" "net/http" "strconv" "strings" "time" bean2 "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index cffb21ff55..ef8e9a28e6 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -22,6 +22,7 @@ import ( "encoding/json" "errors" "fmt" + service2 "github.com/devtron-labs/devtron/api/helm-app/service" "net/http" "strconv" "strings" @@ -67,7 +68,7 @@ type AppStoreDeploymentRestHandlerImpl struct { appStoreDeploymentService service.AppStoreDeploymentService appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService validator *validator.Validate - helmAppService client.HelmAppService + helmAppService service2.HelmAppService helmAppRestHandler client.HelmAppRestHandler argoUserService argo.ArgoUserService attributesService attributes.AttributesService @@ -75,7 +76,7 @@ type AppStoreDeploymentRestHandlerImpl struct { func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, appStoreDeploymentService service.AppStoreDeploymentService, - validator *validator.Validate, helmAppService client.HelmAppService, appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService, + validator *validator.Validate, helmAppService service2.HelmAppService, appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService, argoUserService argo.ArgoUserService, attributesService attributes.AttributesService) *AppStoreDeploymentRestHandlerImpl { return &AppStoreDeploymentRestHandlerImpl{ Logger: Logger, diff --git a/api/appStore/deployment/CommonDeploymentRestHandler.go b/api/appStore/deployment/CommonDeploymentRestHandler.go index d7bfac9fd8..0a4e527834 100644 --- a/api/appStore/deployment/CommonDeploymentRestHandler.go +++ b/api/appStore/deployment/CommonDeploymentRestHandler.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "fmt" + service2 "github.com/devtron-labs/devtron/api/helm-app/service" "net/http" "strconv" "time" @@ -31,7 +32,6 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -51,35 +51,33 @@ type CommonDeploymentRestHandler interface { } type CommonDeploymentRestHandlerImpl struct { - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - enforcerUtilHelm rbac.EnforcerUtilHelm - appStoreDeploymentService service.AppStoreDeploymentService - appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService - validator *validator.Validate - helmAppService client.HelmAppService - helmAppRestHandler client.HelmAppRestHandler - argoUserService argo.ArgoUserService + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer + enforcerUtil rbac.EnforcerUtil + enforcerUtilHelm rbac.EnforcerUtilHelm + appStoreDeploymentService service.AppStoreDeploymentService + validator *validator.Validate + helmAppService service2.HelmAppService + helmAppRestHandler client.HelmAppRestHandler + argoUserService argo.ArgoUserService } func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, appStoreDeploymentService service.AppStoreDeploymentService, - validator *validator.Validate, helmAppService client.HelmAppService, appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService, + validator *validator.Validate, helmAppService service2.HelmAppService, helmAppRestHandler client.HelmAppRestHandler, argoUserService argo.ArgoUserService) *CommonDeploymentRestHandlerImpl { return &CommonDeploymentRestHandlerImpl{ - Logger: Logger, - userAuthService: userAuthService, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - enforcerUtilHelm: enforcerUtilHelm, - appStoreDeploymentService: appStoreDeploymentService, - validator: validator, - helmAppService: helmAppService, - appStoreDeploymentServiceC: appStoreDeploymentServiceC, - helmAppRestHandler: helmAppRestHandler, - argoUserService: argoUserService, + Logger: Logger, + userAuthService: userAuthService, + enforcer: enforcer, + enforcerUtil: enforcerUtil, + enforcerUtilHelm: enforcerUtilHelm, + appStoreDeploymentService: appStoreDeploymentService, + validator: validator, + helmAppService: helmAppService, + helmAppRestHandler: helmAppRestHandler, + argoUserService: argoUserService, } } func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppId string, appId string) (string, *appStoreBean.InstallAppVersionDTO, error) { @@ -91,7 +89,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"} return appOfferingMode, installedAppDto, err } - installedAppDto, err = handler.appStoreDeploymentServiceC.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedAppDto, err = handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { err = &util.ApiError{HttpStatusCode: http.StatusInternalServerError, UserMessage: "unable to find app in database"} return appOfferingMode, installedAppDto, err @@ -117,7 +115,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid installed app id"} return appOfferingMode, installedAppDto, err } - installedAppDto, err = handler.appStoreDeploymentServiceC.GetInstalledAppByInstalledAppId(installedAppId) + installedAppDto, err = handler.appStoreDeploymentService.GetInstalledAppByInstalledAppId(installedAppId) if err != nil { err = &util.ApiError{HttpStatusCode: http.StatusInternalServerError, UserMessage: "unable to find app in database"} return appOfferingMode, installedAppDto, err diff --git a/api/bean/GitOpsConfig.go b/api/bean/GitOpsConfig.go index 4ff2d5bd92..1876c63fda 100644 --- a/api/bean/GitOpsConfig.go +++ b/api/bean/GitOpsConfig.go @@ -13,6 +13,7 @@ type GitOpsConfigDto struct { BitBucketWorkspaceId string `json:"bitBucketWorkspaceId"` BitBucketProjectKey string `json:"bitBucketProjectKey"` + // TODO refactoring: create different struct for internal fields GitRepoName string `json:"gitRepoName"` UserEmailId string `json:"userEmailId"` Description string `json:"description"` diff --git a/api/helm-app/HelmAppRestHandler.go b/api/helm-app/HelmAppRestHandler.go index 9259347308..45e504c08f 100644 --- a/api/helm-app/HelmAppRestHandler.go +++ b/api/helm-app/HelmAppRestHandler.go @@ -4,6 +4,9 @@ import ( "context" "encoding/json" "errors" + "github.com/devtron-labs/devtron/api/helm-app/bean" + service2 "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "net/http" "strconv" "strings" @@ -14,8 +17,6 @@ import ( openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/util" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -43,31 +44,32 @@ const HELM_APP_ACCESS_COUNTER = "HelmAppAccessCounter" const HELM_APP_UPDATE_COUNTER = "HelmAppUpdateCounter" type HelmAppRestHandlerImpl struct { - logger *zap.SugaredLogger - helmAppService HelmAppService - enforcer casbin.Enforcer - clusterService cluster.ClusterService - enforcerUtil rbac.EnforcerUtilHelm - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - userAuthService user.UserService - attributesService attributes.AttributesService - serverEnvConfig *serverEnvConfig.ServerEnvConfig + logger *zap.SugaredLogger + helmAppService service2.HelmAppService + enforcer casbin.Enforcer + clusterService cluster.ClusterService + enforcerUtil rbac.EnforcerUtilHelm + appStoreDeploymentService service.AppStoreDeploymentService + userAuthService user.UserService + attributesService attributes.AttributesService + serverEnvConfig *serverEnvConfig.ServerEnvConfig } func NewHelmAppRestHandlerImpl(logger *zap.SugaredLogger, - helmAppService HelmAppService, enforcer casbin.Enforcer, - clusterService cluster.ClusterService, enforcerUtil rbac.EnforcerUtilHelm, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + helmAppService service2.HelmAppService, enforcer casbin.Enforcer, + clusterService cluster.ClusterService, enforcerUtil rbac.EnforcerUtilHelm, + appStoreDeploymentService service.AppStoreDeploymentService, userAuthService user.UserService, attributesService attributes.AttributesService, serverEnvConfig *serverEnvConfig.ServerEnvConfig) *HelmAppRestHandlerImpl { return &HelmAppRestHandlerImpl{ - logger: logger, - helmAppService: helmAppService, - enforcer: enforcer, - clusterService: clusterService, - enforcerUtil: enforcerUtil, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, - userAuthService: userAuthService, - attributesService: attributesService, - serverEnvConfig: serverEnvConfig, + logger: logger, + helmAppService: helmAppService, + enforcer: enforcer, + clusterService: clusterService, + enforcerUtil: enforcerUtil, + appStoreDeploymentService: appStoreDeploymentService, + userAuthService: userAuthService, + attributesService: attributesService, + serverEnvConfig: serverEnvConfig, } } @@ -118,15 +120,15 @@ func (handler *HelmAppRestHandlerImpl) GetApplicationDetail(w http.ResponseWrite return } - installedApp, err := handler.appStoreDeploymentCommonService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedApp, err := handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } - res := &AppDetailAndInstalledAppInfo{ + res := &bean.AppDetailAndInstalledAppInfo{ AppDetail: appdetail, - InstalledAppInfo: convertToInstalledAppInfo(installedApp), + InstalledAppInfo: bean.ConvertToInstalledAppInfo(installedApp), } common.WriteJsonResp(w, err, res, http.StatusOK) @@ -219,15 +221,15 @@ func (handler *HelmAppRestHandlerImpl) GetReleaseInfo(w http.ResponseWriter, r * common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } - - installedApp, err := handler.appStoreDeploymentCommonService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedApp, err := handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } - res := &ReleaseAndInstalledAppInfo{ + + res := &bean.ReleaseAndInstalledAppInfo{ ReleaseInfo: releaseInfo, - InstalledAppInfo: convertToInstalledAppInfo(installedApp), + InstalledAppInfo: bean.ConvertToInstalledAppInfo(installedApp), } common.WriteJsonResp(w, err, res, http.StatusOK) @@ -306,7 +308,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter, // validate if the devtron-operator helm release, block that for deletion if appIdentifier.ReleaseName == handler.serverEnvConfig.DevtronHelmReleaseName && appIdentifier.Namespace == handler.serverEnvConfig.DevtronHelmReleaseNamespace && - appIdentifier.ClusterId == DEFAULT_CLUSTER_ID { + appIdentifier.ClusterId == bean.DEFAULT_CLUSTER_ID { common.WriteJsonResp(w, errors.New("cannot delete this default helm app"), nil, http.StatusForbidden) return } @@ -323,7 +325,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter, } func (handler *HelmAppRestHandlerImpl) UpdateApplication(w http.ResponseWriter, r *http.Request) { - request := &UpdateApplicationRequestDto{} + request := &bean.UpdateApplicationRequestDto{} decoder := json.NewDecoder(r.Body) err := decoder.Decode(request) if err != nil { @@ -346,7 +348,7 @@ func (handler *HelmAppRestHandlerImpl) UpdateApplication(w http.ResponseWriter, return } //RBAC enforcer Ends - request.SourceAppType = SOURCE_EXTERNAL_HELM_APP + request.SourceAppType = bean.SOURCE_EXTERNAL_HELM_APP // update application externally res, err := handler.helmAppService.UpdateApplication(r.Context(), appIdentifier, request) if err != nil { @@ -422,57 +424,3 @@ func (handler *HelmAppRestHandlerImpl) SaveHelmAppDetailsViewedTelemetryData(w h common.WriteJsonResp(w, err, nil, http.StatusOK) } - -func convertToInstalledAppInfo(installedApp *appStoreBean.InstallAppVersionDTO) *InstalledAppInfo { - if installedApp == nil { - return nil - } - - chartInfo := installedApp.InstallAppVersionChartDTO - - return &InstalledAppInfo{ - AppId: installedApp.AppId, - EnvironmentName: installedApp.EnvironmentName, - AppOfferingMode: installedApp.AppOfferingMode, - InstalledAppId: installedApp.InstalledAppId, - InstalledAppVersionId: installedApp.InstalledAppVersionId, - AppStoreChartId: chartInfo.AppStoreChartId, - ClusterId: installedApp.ClusterId, - EnvironmentId: installedApp.EnvironmentId, - AppStoreChartRepoName: chartInfo.InstallAppVersionChartRepoDTO.RepoName, - AppStoreChartName: chartInfo.ChartName, - TeamId: installedApp.TeamId, - TeamName: installedApp.TeamName, - } -} - -type AppDetailAndInstalledAppInfo struct { - InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - AppDetail *AppDetail `json:"appDetail"` -} - -type ReleaseAndInstalledAppInfo struct { - InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - ReleaseInfo *ReleaseInfo `json:"releaseInfo"` -} - -type DeploymentHistoryAndInstalledAppInfo struct { - InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - DeploymentHistory []*HelmAppDeploymentDetail `json:"deploymentHistory"` -} - -type InstalledAppInfo struct { - AppId int `json:"appId"` - InstalledAppId int `json:"installedAppId"` - InstalledAppVersionId int `json:"installedAppVersionId"` - AppStoreChartId int `json:"appStoreChartId"` - EnvironmentName string `json:"environmentName"` - AppOfferingMode string `json:"appOfferingMode"` - ClusterId int `json:"clusterId"` - EnvironmentId int `json:"environmentId"` - AppStoreChartRepoName string `json:"appStoreChartRepoName"` - AppStoreChartName string `json:"appStoreChartName"` - TeamId int `json:"teamId"` - TeamName string `json:"teamName"` - DeploymentType string `json:"deploymentType"` -} diff --git a/api/helm-app/bean.go b/api/helm-app/bean.go deleted file mode 100644 index bd006b6e36..0000000000 --- a/api/helm-app/bean.go +++ /dev/null @@ -1,24 +0,0 @@ -package client - -import openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" - -const ( - DEFAULT_CLUSTER_ID = 1 - SOURCE_DEVTRON_APP SourceAppType = "devtron-app" - SOURCE_HELM_APP SourceAppType = "helm-app" - SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app" - SOURCE_UNKNOWN SourceAppType = "unknown" - ErrReleaseNotFound string = "release: not found" -) - -type SourceAppType string - -type UpdateApplicationRequestDto struct { - *openapi.UpdateReleaseRequest - SourceAppType SourceAppType `json:"-"` -} - -type UpdateApplicationWithChartInfoRequestDto struct { - *InstallReleaseRequest - SourceAppType SourceAppType `json:"-"` -} diff --git a/api/helm-app/bean/bean.go b/api/helm-app/bean/bean.go new file mode 100644 index 0000000000..f1222946e5 --- /dev/null +++ b/api/helm-app/bean/bean.go @@ -0,0 +1,82 @@ +package bean + +import ( + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" + "github.com/devtron-labs/devtron/pkg/appStore/bean" +) + +const ( + DEFAULT_CLUSTER_ID = 1 + SOURCE_DEVTRON_APP SourceAppType = "devtron-app" + SOURCE_HELM_APP SourceAppType = "helm-app" + SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app" + SOURCE_UNKNOWN SourceAppType = "unknown" + ErrReleaseNotFound string = "release: not found" +) + +type SourceAppType string + +type UpdateApplicationRequestDto struct { + *openapi.UpdateReleaseRequest + SourceAppType SourceAppType `json:"-"` +} + +type UpdateApplicationWithChartInfoRequestDto struct { + *gRPC.InstallReleaseRequest + SourceAppType SourceAppType `json:"-"` +} + +func ConvertToInstalledAppInfo(installedApp *appStoreBean.InstallAppVersionDTO) *InstalledAppInfo { + if installedApp == nil { + return nil + } + + chartInfo := installedApp.InstallAppVersionChartDTO + + return &InstalledAppInfo{ + AppId: installedApp.AppId, + EnvironmentName: installedApp.EnvironmentName, + AppOfferingMode: installedApp.AppOfferingMode, + InstalledAppId: installedApp.InstalledAppId, + InstalledAppVersionId: installedApp.InstalledAppVersionId, + AppStoreChartId: chartInfo.AppStoreChartId, + ClusterId: installedApp.ClusterId, + EnvironmentId: installedApp.EnvironmentId, + AppStoreChartRepoName: chartInfo.InstallAppVersionChartRepoDTO.RepoName, + AppStoreChartName: chartInfo.ChartName, + TeamId: installedApp.TeamId, + TeamName: installedApp.TeamName, + } +} + +type AppDetailAndInstalledAppInfo struct { + InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` + AppDetail *gRPC.AppDetail `json:"appDetail"` +} + +type ReleaseAndInstalledAppInfo struct { + InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` + ReleaseInfo *gRPC.ReleaseInfo `json:"releaseInfo"` +} + +type DeploymentHistoryAndInstalledAppInfo struct { + InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` + DeploymentHistory []*gRPC.HelmAppDeploymentDetail `json:"deploymentHistory"` +} + +type InstalledAppInfo struct { + AppId int `json:"appId"` + InstalledAppId int `json:"installedAppId"` + InstalledAppVersionId int `json:"installedAppVersionId"` + AppStoreChartId int `json:"appStoreChartId"` + EnvironmentName string `json:"environmentName"` + AppOfferingMode string `json:"appOfferingMode"` + ClusterId int `json:"clusterId"` + EnvironmentId int `json:"environmentId"` + AppStoreChartRepoName string `json:"appStoreChartRepoName"` + AppStoreChartName string `json:"appStoreChartName"` + TeamId int `json:"teamId"` + TeamName string `json:"teamName"` + DeploymentType string `json:"deploymentType"` +} diff --git a/api/helm-app/applicationClient.go b/api/helm-app/gRPC/applicationClient.go similarity index 96% rename from api/helm-app/applicationClient.go rename to api/helm-app/gRPC/applicationClient.go index 884f088f1b..7f540df584 100644 --- a/api/helm-app/applicationClient.go +++ b/api/helm-app/gRPC/applicationClient.go @@ -1,11 +1,9 @@ -package client +package gRPC import ( "context" "fmt" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.uber.org/zap" "google.golang.org/grpc" @@ -158,13 +156,6 @@ func (impl *HelmAppClientImpl) GetDeploymentHistory(ctx context.Context, in *App } history, err := applicationClient.GetDeploymentHistory(ctx, in) if err != nil { - if util.GetGRPCErrorDetailedMessage(err) == ErrReleaseNotFound { - err = &util.ApiError{ - Code: constants.HelmReleaseNotFound, - InternalMessage: ErrReleaseNotFound, - UserMessage: fmt.Sprintf("no release found with release name '%s'", in.ReleaseName), - } - } return nil, err } return history, nil diff --git a/api/helm-app/applist.pb.go b/api/helm-app/gRPC/applist.pb.go similarity index 99% rename from api/helm-app/applist.pb.go rename to api/helm-app/gRPC/applist.pb.go index c3f9f1f7c1..918a92a433 100644 --- a/api/helm-app/applist.pb.go +++ b/api/helm-app/gRPC/applist.pb.go @@ -4,7 +4,7 @@ // protoc v3.9.1 // source: api/helm-app/applist.proto -package client +package gRPC import ( timestamp "github.com/golang/protobuf/ptypes/timestamp" diff --git a/api/helm-app/applist.proto b/api/helm-app/gRPC/applist.proto similarity index 100% rename from api/helm-app/applist.proto rename to api/helm-app/gRPC/applist.proto diff --git a/api/helm-app/applist_grpc.pb.go b/api/helm-app/gRPC/applist_grpc.pb.go similarity index 99% rename from api/helm-app/applist_grpc.pb.go rename to api/helm-app/gRPC/applist_grpc.pb.go index 4cc1bfa04f..8367a07b69 100644 --- a/api/helm-app/applist_grpc.pb.go +++ b/api/helm-app/gRPC/applist_grpc.pb.go @@ -4,7 +4,7 @@ // - protoc v3.9.1 // source: api/helm-app/applist.proto -package client +package gRPC import ( context "context" diff --git a/api/helm-app/mocks/HelmAppClient.go b/api/helm-app/mocks/HelmAppClient.go index 155cff8d8b..ac80fdd6a9 100644 --- a/api/helm-app/mocks/HelmAppClient.go +++ b/api/helm-app/mocks/HelmAppClient.go @@ -4,9 +4,7 @@ package mocks import ( context "context" - - client "github.com/devtron-labs/devtron/api/helm-app" - + "github.com/devtron-labs/devtron/api/helm-app/gRPC" mock "github.com/stretchr/testify/mock" ) @@ -16,23 +14,23 @@ type HelmAppClient struct { } // DeleteApplication provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error) { +func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *gRPC.ReleaseIdentifier) (*gRPC.UninstallReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.UninstallReleaseResponse + var r0 *gRPC.UninstallReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) (*gRPC.UninstallReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) *client.UninstallReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) *gRPC.UninstallReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.UninstallReleaseResponse) + r0 = ret.Get(0).(*gRPC.UninstallReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.ReleaseIdentifier) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ReleaseIdentifier) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -42,23 +40,23 @@ func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *client.Relea } // GetAppDetail provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *client.AppDetailRequest) (*client.AppDetail, error) { +func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.AppDetail, error) { ret := _m.Called(ctx, in) - var r0 *client.AppDetail + var r0 *gRPC.AppDetail var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.AppDetail, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.AppDetail, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.AppDetail); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.AppDetail); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.AppDetail) + r0 = ret.Get(0).(*gRPC.AppDetail) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -68,23 +66,23 @@ func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *client.AppDetailR } // GetAppStatus provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *client.AppDetailRequest) (*client.AppStatus, error) { +func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.AppStatus, error) { ret := _m.Called(ctx, in) - var r0 *client.AppStatus + var r0 *gRPC.AppStatus var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.AppStatus, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.AppStatus, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.AppStatus); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.AppStatus); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.AppStatus) + r0 = ret.Get(0).(*gRPC.AppStatus) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -94,23 +92,23 @@ func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *client.AppDetailR } // GetDeploymentDetail provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error) { +func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *gRPC.DeploymentDetailRequest) (*gRPC.DeploymentDetailResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.DeploymentDetailResponse + var r0 *gRPC.DeploymentDetailResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.DeploymentDetailRequest) (*gRPC.DeploymentDetailResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.DeploymentDetailRequest) *client.DeploymentDetailResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.DeploymentDetailRequest) *gRPC.DeploymentDetailResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.DeploymentDetailResponse) + r0 = ret.Get(0).(*gRPC.DeploymentDetailResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.DeploymentDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.DeploymentDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -120,23 +118,23 @@ func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *client.Dep } // GetDeploymentHistory provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error) { +func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.HelmAppDeploymentHistory, error) { ret := _m.Called(ctx, in) - var r0 *client.HelmAppDeploymentHistory + var r0 *gRPC.HelmAppDeploymentHistory var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.HelmAppDeploymentHistory, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.HelmAppDeploymentHistory); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.HelmAppDeploymentHistory); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.HelmAppDeploymentHistory) + r0 = ret.Get(0).(*gRPC.HelmAppDeploymentHistory) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -146,23 +144,23 @@ func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *client.Ap } // GetDesiredManifest provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *client.ObjectRequest) (*client.DesiredManifestResponse, error) { +func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *gRPC.ObjectRequest) (*gRPC.DesiredManifestResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.DesiredManifestResponse + var r0 *gRPC.DesiredManifestResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.ObjectRequest) (*client.DesiredManifestResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ObjectRequest) (*gRPC.DesiredManifestResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.ObjectRequest) *client.DesiredManifestResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ObjectRequest) *gRPC.DesiredManifestResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.DesiredManifestResponse) + r0 = ret.Get(0).(*gRPC.DesiredManifestResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.ObjectRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ObjectRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -172,23 +170,23 @@ func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *client.Obje } // GetNotes provides a mock function with given fields: ctx, request -func (_m *HelmAppClient) GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (*client.ChartNotesResponse, error) { +func (_m *HelmAppClient) GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (*gRPC.ChartNotesResponse, error) { ret := _m.Called(ctx, request) - var r0 *client.ChartNotesResponse + var r0 *gRPC.ChartNotesResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.ChartNotesResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.ChartNotesResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.ChartNotesResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.ChartNotesResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.ChartNotesResponse) + r0 = ret.Get(0).(*gRPC.ChartNotesResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -198,23 +196,23 @@ func (_m *HelmAppClient) GetNotes(ctx context.Context, request *client.InstallRe } // GetValuesYaml provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *client.AppDetailRequest) (*client.ReleaseInfo, error) { +func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.ReleaseInfo, error) { ret := _m.Called(ctx, in) - var r0 *client.ReleaseInfo + var r0 *gRPC.ReleaseInfo var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.ReleaseInfo, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.ReleaseInfo, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.ReleaseInfo); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.ReleaseInfo); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.ReleaseInfo) + r0 = ret.Get(0).(*gRPC.ReleaseInfo) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -224,23 +222,23 @@ func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *client.AppDetail } // Hibernate provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) Hibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { +func (_m *HelmAppClient) Hibernate(ctx context.Context, in *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.HibernateResponse + var r0 *gRPC.HibernateResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) (*client.HibernateResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) *client.HibernateResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) *gRPC.HibernateResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.HibernateResponse) + r0 = ret.Get(0).(*gRPC.HibernateResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.HibernateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HibernateRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -250,23 +248,23 @@ func (_m *HelmAppClient) Hibernate(ctx context.Context, in *client.HibernateRequ } // InstallRelease provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) { +func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.InstallReleaseResponse + var r0 *gRPC.InstallReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.InstallReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.InstallReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.InstallReleaseResponse) + r0 = ret.Get(0).(*gRPC.InstallReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -276,23 +274,23 @@ func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *client.InstallR } // InstallReleaseWithCustomChart provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error) { +func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in *gRPC.HelmInstallCustomRequest) (*gRPC.HelmInstallCustomResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.HelmInstallCustomResponse + var r0 *gRPC.HelmInstallCustomResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HelmInstallCustomRequest) (*gRPC.HelmInstallCustomResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.HelmInstallCustomRequest) *client.HelmInstallCustomResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HelmInstallCustomRequest) *gRPC.HelmInstallCustomResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.HelmInstallCustomResponse) + r0 = ret.Get(0).(*gRPC.HelmInstallCustomResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.HelmInstallCustomRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HelmInstallCustomRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -302,23 +300,23 @@ func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in * } // IsReleaseInstalled provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *client.ReleaseIdentifier) (*client.BooleanResponse, error) { +func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *gRPC.ReleaseIdentifier) (*gRPC.BooleanResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.BooleanResponse + var r0 *gRPC.BooleanResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) (*client.BooleanResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) (*gRPC.BooleanResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) *client.BooleanResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) *gRPC.BooleanResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.BooleanResponse) + r0 = ret.Get(0).(*gRPC.BooleanResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.ReleaseIdentifier) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ReleaseIdentifier) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -328,23 +326,23 @@ func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *client.Rele } // ListApplication provides a mock function with given fields: ctx, req -func (_m *HelmAppClient) ListApplication(ctx context.Context, req *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error) { +func (_m *HelmAppClient) ListApplication(ctx context.Context, req *gRPC.AppListRequest) (gRPC.ApplicationService_ListApplicationsClient, error) { ret := _m.Called(ctx, req) - var r0 client.ApplicationService_ListApplicationsClient + var r0 gRPC.ApplicationService_ListApplicationsClient var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppListRequest) (gRPC.ApplicationService_ListApplicationsClient, error)); ok { return rf(ctx, req) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppListRequest) client.ApplicationService_ListApplicationsClient); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppListRequest) gRPC.ApplicationService_ListApplicationsClient); ok { r0 = rf(ctx, req) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(client.ApplicationService_ListApplicationsClient) + r0 = ret.Get(0).(gRPC.ApplicationService_ListApplicationsClient) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppListRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppListRequest) error); ok { r1 = rf(ctx, req) } else { r1 = ret.Error(1) @@ -354,23 +352,23 @@ func (_m *HelmAppClient) ListApplication(ctx context.Context, req *client.AppLis } // RollbackRelease provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *client.RollbackReleaseRequest) (*client.BooleanResponse, error) { +func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *gRPC.RollbackReleaseRequest) (*gRPC.BooleanResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.BooleanResponse + var r0 *gRPC.BooleanResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.RollbackReleaseRequest) (*client.BooleanResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.RollbackReleaseRequest) (*gRPC.BooleanResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.RollbackReleaseRequest) *client.BooleanResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.RollbackReleaseRequest) *gRPC.BooleanResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.BooleanResponse) + r0 = ret.Get(0).(*gRPC.BooleanResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.RollbackReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.RollbackReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -380,23 +378,23 @@ func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *client.Rollbac } // TemplateChart provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *client.InstallReleaseRequest) (*client.TemplateChartResponse, error) { +func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.TemplateChartResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.TemplateChartResponse + var r0 *gRPC.TemplateChartResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.TemplateChartResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.TemplateChartResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.TemplateChartResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.TemplateChartResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.TemplateChartResponse) + r0 = ret.Get(0).(*gRPC.TemplateChartResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -406,23 +404,23 @@ func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *client.InstallRe } // UnHibernate provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { +func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.HibernateResponse + var r0 *gRPC.HibernateResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) (*client.HibernateResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) *client.HibernateResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) *gRPC.HibernateResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.HibernateResponse) + r0 = ret.Get(0).(*gRPC.HibernateResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.HibernateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HibernateRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -432,23 +430,23 @@ func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *client.HibernateRe } // UpdateApplication provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error) { +func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *gRPC.UpgradeReleaseRequest) (*gRPC.UpgradeReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.UpgradeReleaseResponse + var r0 *gRPC.UpgradeReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.UpgradeReleaseRequest) (*gRPC.UpgradeReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.UpgradeReleaseRequest) *client.UpgradeReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.UpgradeReleaseRequest) *gRPC.UpgradeReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.UpgradeReleaseResponse) + r0 = ret.Get(0).(*gRPC.UpgradeReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.UpgradeReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.UpgradeReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -458,23 +456,23 @@ func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *client.Upgra } // UpdateApplicationWithChartInfo provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UpdateApplicationWithChartInfo(ctx context.Context, in *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error) { +func (_m *HelmAppClient) UpdateApplicationWithChartInfo(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.UpgradeReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *client.UpgradeReleaseResponse + var r0 *gRPC.UpgradeReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.UpgradeReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.UpgradeReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.UpgradeReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.UpgradeReleaseResponse) + r0 = ret.Get(0).(*gRPC.UpgradeReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) diff --git a/api/helm-app/mocks/HelmAppService.go b/api/helm-app/mocks/HelmAppService.go index 59dce9f450..895130dd23 100644 --- a/api/helm-app/mocks/HelmAppService.go +++ b/api/helm-app/mocks/HelmAppService.go @@ -4,8 +4,9 @@ package mocks import ( context "context" - - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/bean" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" http "net/http" @@ -88,19 +89,19 @@ func (_m *HelmAppService) EncodeAppId(appIdentifier *client.AppIdentifier) strin } // GetApplicationDetail provides a mock function with given fields: ctx, app -func (_m *HelmAppService) GetApplicationDetail(ctx context.Context, app *client.AppIdentifier) (*client.AppDetail, error) { +func (_m *HelmAppService) GetApplicationDetail(ctx context.Context, app *client.AppIdentifier) (*bean2.AppDetail, error) { ret := _m.Called(ctx, app) - var r0 *client.AppDetail + var r0 *bean2.AppDetail var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*client.AppDetail, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*bean2.AppDetail, error)); ok { return rf(ctx, app) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *client.AppDetail); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *bean2.AppDetail); ok { r0 = rf(ctx, app) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.AppDetail) + r0 = ret.Get(0).(*bean2.AppDetail) } } @@ -114,23 +115,23 @@ func (_m *HelmAppService) GetApplicationDetail(ctx context.Context, app *client. } // GetApplicationDetailWithFilter provides a mock function with given fields: ctx, app, resourceTreeFilter -func (_m *HelmAppService) GetApplicationDetailWithFilter(ctx context.Context, app *client.AppIdentifier, resourceTreeFilter *client.ResourceTreeFilter) (*client.AppDetail, error) { +func (_m *HelmAppService) GetApplicationDetailWithFilter(ctx context.Context, app *client.AppIdentifier, resourceTreeFilter *bean2.ResourceTreeFilter) (*bean2.AppDetail, error) { ret := _m.Called(ctx, app, resourceTreeFilter) - var r0 *client.AppDetail + var r0 *bean2.AppDetail var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.ResourceTreeFilter) (*client.AppDetail, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean2.ResourceTreeFilter) (*bean2.AppDetail, error)); ok { return rf(ctx, app, resourceTreeFilter) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.ResourceTreeFilter) *client.AppDetail); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean2.ResourceTreeFilter) *bean2.AppDetail); ok { r0 = rf(ctx, app, resourceTreeFilter) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.AppDetail) + r0 = ret.Get(0).(*bean2.AppDetail) } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *client.ResourceTreeFilter) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *bean2.ResourceTreeFilter) error); ok { r1 = rf(ctx, app, resourceTreeFilter) } else { r1 = ret.Error(1) @@ -164,19 +165,19 @@ func (_m *HelmAppService) GetApplicationStatus(ctx context.Context, app *client. } // GetClusterConf provides a mock function with given fields: clusterId -func (_m *HelmAppService) GetClusterConf(clusterId int) (*client.ClusterConfig, error) { +func (_m *HelmAppService) GetClusterConf(clusterId int) (*bean2.ClusterConfig, error) { ret := _m.Called(clusterId) - var r0 *client.ClusterConfig + var r0 *bean2.ClusterConfig var r1 error - if rf, ok := ret.Get(0).(func(int) (*client.ClusterConfig, error)); ok { + if rf, ok := ret.Get(0).(func(int) (*bean2.ClusterConfig, error)); ok { return rf(clusterId) } - if rf, ok := ret.Get(0).(func(int) *client.ClusterConfig); ok { + if rf, ok := ret.Get(0).(func(int) *bean2.ClusterConfig); ok { r0 = rf(clusterId) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.ClusterConfig) + r0 = ret.Get(0).(*bean2.ClusterConfig) } } @@ -216,19 +217,19 @@ func (_m *HelmAppService) GetDeploymentDetail(ctx context.Context, app *client.A } // GetDeploymentHistory provides a mock function with given fields: ctx, app -func (_m *HelmAppService) GetDeploymentHistory(ctx context.Context, app *client.AppIdentifier) (*client.HelmAppDeploymentHistory, error) { +func (_m *HelmAppService) GetDeploymentHistory(ctx context.Context, app *client.AppIdentifier) (*bean2.HelmAppDeploymentHistory, error) { ret := _m.Called(ctx, app) - var r0 *client.HelmAppDeploymentHistory + var r0 *bean2.HelmAppDeploymentHistory var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*client.HelmAppDeploymentHistory, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*bean2.HelmAppDeploymentHistory, error)); ok { return rf(ctx, app) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *client.HelmAppDeploymentHistory); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *bean2.HelmAppDeploymentHistory); ok { r0 = rf(ctx, app) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.HelmAppDeploymentHistory) + r0 = ret.Get(0).(*bean2.HelmAppDeploymentHistory) } } @@ -284,21 +285,21 @@ func (_m *HelmAppService) GetDevtronHelmAppIdentifier() *client.AppIdentifier { } // GetNotes provides a mock function with given fields: ctx, request -func (_m *HelmAppService) GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (string, error) { +func (_m *HelmAppService) GetNotes(ctx context.Context, request *bean2.InstallReleaseRequest) (string, error) { ret := _m.Called(ctx, request) var r0 string var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (string, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *bean2.InstallReleaseRequest) (string, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) string); ok { + if rf, ok := ret.Get(0).(func(context.Context, *bean2.InstallReleaseRequest) string); ok { r0 = rf(ctx, request) } else { r0 = ret.Get(0).(string) } - if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *bean2.InstallReleaseRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -308,11 +309,11 @@ func (_m *HelmAppService) GetNotes(ctx context.Context, request *client.InstallR } // GetRevisionHistoryMaxValue provides a mock function with given fields: appType -func (_m *HelmAppService) GetRevisionHistoryMaxValue(appType client.SourceAppType) int32 { +func (_m *HelmAppService) GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32 { ret := _m.Called(appType) var r0 int32 - if rf, ok := ret.Get(0).(func(client.SourceAppType) int32); ok { + if rf, ok := ret.Get(0).(func(bean.SourceAppType) int32); ok { r0 = rf(appType) } else { r0 = ret.Get(0).(int32) @@ -322,19 +323,19 @@ func (_m *HelmAppService) GetRevisionHistoryMaxValue(appType client.SourceAppTyp } // GetValuesYaml provides a mock function with given fields: ctx, app -func (_m *HelmAppService) GetValuesYaml(ctx context.Context, app *client.AppIdentifier) (*client.ReleaseInfo, error) { +func (_m *HelmAppService) GetValuesYaml(ctx context.Context, app *client.AppIdentifier) (*bean2.ReleaseInfo, error) { ret := _m.Called(ctx, app) - var r0 *client.ReleaseInfo + var r0 *bean2.ReleaseInfo var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*client.ReleaseInfo, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) (*bean2.ReleaseInfo, error)); ok { return rf(ctx, app) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *client.ReleaseInfo); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier) *bean2.ReleaseInfo); ok { r0 = rf(ctx, app) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.ReleaseInfo) + r0 = ret.Get(0).(*bean2.ReleaseInfo) } } @@ -374,23 +375,23 @@ func (_m *HelmAppService) HibernateApplication(ctx context.Context, app *client. } // InstallRelease provides a mock function with given fields: ctx, clusterId, installReleaseRequest -func (_m *HelmAppService) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) { +func (_m *HelmAppService) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *bean2.InstallReleaseRequest) (*bean2.InstallReleaseResponse, error) { ret := _m.Called(ctx, clusterId, installReleaseRequest) - var r0 *client.InstallReleaseResponse + var r0 *bean2.InstallReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int, *bean2.InstallReleaseRequest) (*bean2.InstallReleaseResponse, error)); ok { return rf(ctx, clusterId, installReleaseRequest) } - if rf, ok := ret.Get(0).(func(context.Context, int, *client.InstallReleaseRequest) *client.InstallReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, int, *bean2.InstallReleaseRequest) *bean2.InstallReleaseResponse); ok { r0 = rf(ctx, clusterId, installReleaseRequest) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*client.InstallReleaseResponse) + r0 = ret.Get(0).(*bean2.InstallReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, int, *client.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, int, *bean2.InstallReleaseRequest) error); ok { r1 = rf(ctx, clusterId, installReleaseRequest) } else { r1 = ret.Error(1) @@ -505,15 +506,15 @@ func (_m *HelmAppService) UnHibernateApplication(ctx context.Context, app *clien } // UpdateApplication provides a mock function with given fields: ctx, app, request -func (_m *HelmAppService) UpdateApplication(ctx context.Context, app *client.AppIdentifier, request *client.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) { +func (_m *HelmAppService) UpdateApplication(ctx context.Context, app *client.AppIdentifier, request *bean.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) { ret := _m.Called(ctx, app, request) var r0 *openapi.UpdateReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error)); ok { return rf(ctx, app, request) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.UpdateApplicationRequestDto) *openapi.UpdateReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean.UpdateApplicationRequestDto) *openapi.UpdateReleaseResponse); ok { r0 = rf(ctx, app, request) } else { if ret.Get(0) != nil { @@ -521,7 +522,7 @@ func (_m *HelmAppService) UpdateApplication(ctx context.Context, app *client.App } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *client.UpdateApplicationRequestDto) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *bean.UpdateApplicationRequestDto) error); ok { r1 = rf(ctx, app, request) } else { r1 = ret.Error(1) @@ -531,15 +532,15 @@ func (_m *HelmAppService) UpdateApplication(ctx context.Context, app *client.App } // UpdateApplicationWithChartInfo provides a mock function with given fields: ctx, clusterId, request -func (_m *HelmAppService) UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, request *client.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) { +func (_m *HelmAppService) UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, request *bean.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) { ret := _m.Called(ctx, clusterId, request) var r0 *openapi.UpdateReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, *client.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, int, *bean.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error)); ok { return rf(ctx, clusterId, request) } - if rf, ok := ret.Get(0).(func(context.Context, int, *client.UpdateApplicationWithChartInfoRequestDto) *openapi.UpdateReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, int, *bean.UpdateApplicationWithChartInfoRequestDto) *openapi.UpdateReleaseResponse); ok { r0 = rf(ctx, clusterId, request) } else { if ret.Get(0) != nil { @@ -547,7 +548,7 @@ func (_m *HelmAppService) UpdateApplicationWithChartInfo(ctx context.Context, cl } } - if rf, ok := ret.Get(1).(func(context.Context, int, *client.UpdateApplicationWithChartInfoRequestDto) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, int, *bean.UpdateApplicationWithChartInfoRequestDto) error); ok { r1 = rf(ctx, clusterId, request) } else { r1 = ret.Error(1) @@ -557,15 +558,15 @@ func (_m *HelmAppService) UpdateApplicationWithChartInfo(ctx context.Context, cl } // UpdateApplicationWithChartInfoWithExtraValues provides a mock function with given fields: ctx, appIdentifier, chartRepository, extraValues, extraValuesYamlUrl, useLatestChartVersion -func (_m *HelmAppService) UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *client.AppIdentifier, chartRepository *client.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { +func (_m *HelmAppService) UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *client.AppIdentifier, chartRepository *bean2.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { ret := _m.Called(ctx, appIdentifier, chartRepository, extraValues, extraValuesYamlUrl, useLatestChartVersion) var r0 *openapi.UpdateReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.ChartRepository, map[string]interface{}, string, bool) (*openapi.UpdateReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean2.ChartRepository, map[string]interface{}, string, bool) (*openapi.UpdateReleaseResponse, error)); ok { return rf(ctx, appIdentifier, chartRepository, extraValues, extraValuesYamlUrl, useLatestChartVersion) } - if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *client.ChartRepository, map[string]interface{}, string, bool) *openapi.UpdateReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppIdentifier, *bean2.ChartRepository, map[string]interface{}, string, bool) *openapi.UpdateReleaseResponse); ok { r0 = rf(ctx, appIdentifier, chartRepository, extraValues, extraValuesYamlUrl, useLatestChartVersion) } else { if ret.Get(0) != nil { @@ -573,7 +574,7 @@ func (_m *HelmAppService) UpdateApplicationWithChartInfoWithExtraValues(ctx cont } } - if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *client.ChartRepository, map[string]interface{}, string, bool) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppIdentifier, *bean2.ChartRepository, map[string]interface{}, string, bool) error); ok { r1 = rf(ctx, appIdentifier, chartRepository, extraValues, extraValuesYamlUrl, useLatestChartVersion) } else { r1 = ret.Error(1) @@ -583,11 +584,11 @@ func (_m *HelmAppService) UpdateApplicationWithChartInfoWithExtraValues(ctx cont } // ValidateOCIRegistry provides a mock function with given fields: ctx, OCIRegistryRequest -func (_m *HelmAppService) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *client.RegistryCredential) bool { +func (_m *HelmAppService) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *bean2.RegistryCredential) bool { ret := _m.Called(ctx, OCIRegistryRequest) var r0 bool - if rf, ok := ret.Get(0).(func(context.Context, *client.RegistryCredential) bool); ok { + if rf, ok := ret.Get(0).(func(context.Context, *bean2.RegistryCredential) bool); ok { r0 = rf(ctx, OCIRegistryRequest) } else { r0 = ret.Get(0).(bool) diff --git a/api/helm-app/HelmAppService.go b/api/helm-app/service/HelmAppService.go similarity index 89% rename from api/helm-app/HelmAppService.go rename to api/helm-app/service/HelmAppService.go index 8485431c26..797c28e374 100644 --- a/api/helm-app/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -1,11 +1,14 @@ -package client +package service import ( "context" "errors" "fmt" "github.com/devtron-labs/common-lib/utils/k8s" + "github.com/devtron-labs/devtron/api/helm-app/bean" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/models" + "github.com/devtron-labs/devtron/internal/constants" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/go-pg/pg" "google.golang.org/grpc/codes" @@ -43,37 +46,37 @@ import ( type HelmAppService interface { ListHelmApplications(ctx context.Context, clusterIds []int, w http.ResponseWriter, token string, helmAuth func(token string, object string) bool) - GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*AppDetail, error) - GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*AppStatus, error) - GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *ResourceTreeFilter) (*AppDetail, error) + GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*gRPC.AppDetail, error) + GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) + GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) HibernateApplication(ctx context.Context, app *AppIdentifier, hibernateRequest *openapi.HibernateRequest) ([]*openapi.HibernateStatus, error) UnHibernateApplication(ctx context.Context, app *AppIdentifier, hibernateRequest *openapi.HibernateRequest) ([]*openapi.HibernateStatus, error) DecodeAppId(appId string) (*AppIdentifier, error) EncodeAppId(appIdentifier *AppIdentifier) string - GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*HelmAppDeploymentHistory, error) - GetValuesYaml(ctx context.Context, app *AppIdentifier) (*ReleaseInfo, error) + GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*gRPC.HelmAppDeploymentHistory, error) + GetValuesYaml(ctx context.Context, app *AppIdentifier) (*gRPC.ReleaseInfo, error) GetDesiredManifest(ctx context.Context, app *AppIdentifier, resource *openapi.ResourceIdentifier) (*openapi.DesiredManifestResponse, error) DeleteApplication(ctx context.Context, app *AppIdentifier) (*openapi.UninstallReleaseResponse, error) DeleteDBLinkedHelmApplication(ctx context.Context, app *AppIdentifier, useId int32) (*openapi.UninstallReleaseResponse, error) - UpdateApplication(ctx context.Context, app *AppIdentifier, request *UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) + UpdateApplication(ctx context.Context, app *AppIdentifier, request *bean.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) GetDeploymentDetail(ctx context.Context, app *AppIdentifier, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *InstallReleaseRequest) (*InstallReleaseResponse, error) - UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, request *UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) + InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) + UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, request *bean.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) IsReleaseInstalled(ctx context.Context, app *AppIdentifier) (bool, error) RollbackRelease(ctx context.Context, app *AppIdentifier, version int32) (bool, error) - GetClusterConf(clusterId int) (*ClusterConfig, error) + GetClusterConf(clusterId int) (*gRPC.ClusterConfig, error) GetDevtronHelmAppIdentifier() *AppIdentifier - UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, chartRepository *ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) + UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, chartRepository *gRPC.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) TemplateChart(ctx context.Context, templateChartRequest *openapi2.TemplateChartRequest) (*openapi2.TemplateChartResponse, error) - GetNotes(ctx context.Context, request *InstallReleaseRequest) (string, error) - ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *RegistryCredential) bool - GetRevisionHistoryMaxValue(appType SourceAppType) int32 + GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (string, error) + ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *gRPC.RegistryCredential) bool + GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32 } type HelmAppServiceImpl struct { logger *zap.SugaredLogger clusterService cluster.ClusterService - helmAppClient HelmAppClient + helmAppClient gRPC.HelmAppClient pump connector.Pump enforcerUtil rbac.EnforcerUtilHelm serverDataStore *serverDataStore.ServerDataStore @@ -89,7 +92,7 @@ type HelmAppServiceImpl struct { } func NewHelmAppServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.ClusterService, - helmAppClient HelmAppClient, pump connector.Pump, enforcerUtil rbac.EnforcerUtilHelm, + helmAppClient gRPC.HelmAppClient, pump connector.Pump, enforcerUtil rbac.EnforcerUtilHelm, serverDataStore *serverDataStore.ServerDataStore, serverEnvConfig *serverEnvConfig.ServerEnvConfig, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentService cluster.EnvironmentService, pipelineRepository pipelineConfig.PipelineRepository, @@ -127,7 +130,7 @@ func GetHelmReleaseConfig() (*HelmReleaseConfig, error) { return cfg, err } -func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds []int) (ApplicationService_ListApplicationsClient, error) { +func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds []int) (gRPC.ApplicationService_ListApplicationsClient, error) { if len(clusterIds) == 0 { return nil, nil } @@ -138,9 +141,9 @@ func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &AppListRequest{} + req := &gRPC.AppListRequest{} for _, clusterDetail := range clusters { - config := &ClusterConfig{ + config := &gRPC.ClusterConfig{ ApiServerUrl: clusterDetail.ServerUrl, Token: clusterDetail.Config[k8s.BearerToken], ClusterId: int32(clusterDetail.Id), @@ -198,14 +201,14 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste return appStream.Recv() }, err, func(message interface{}) interface{} { - return impl.appListRespProtoTransformer(message.(*DeployedAppList), token, helmAuth, helmCdPipelines, installedHelmApps) + return impl.appListRespProtoTransformer(message.(*gRPC.DeployedAppList), token, helmAuth, helmCdPipelines, installedHelmApps) }) } -func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.HibernateRequest) *HibernateRequest { - req := &HibernateRequest{} +func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.HibernateRequest) *gRPC.HibernateRequest { + req := &gRPC.HibernateRequest{} for _, reqObject := range hibernateRequest.GetResources() { - obj := &ObjectIdentifier{ + obj := &gRPC.ObjectIdentifier{ Group: *reqObject.Group, Kind: *reqObject.Kind, Version: *reqObject.Version, @@ -216,7 +219,7 @@ func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.Hi } return req } -func (impl *HelmAppServiceImpl) hibernateResponseAdaptor(in []*HibernateStatus) []*openapi.HibernateStatus { +func (impl *HelmAppServiceImpl) hibernateResponseAdaptor(in []*gRPC.HibernateStatus) []*openapi.HibernateStatus { var resStatus []*openapi.HibernateStatus for _, status := range in { resObj := &openapi.HibernateStatus{ @@ -265,13 +268,13 @@ func (impl *HelmAppServiceImpl) UnHibernateApplication(ctx context.Context, app return response, nil } -func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*ClusterConfig, error) { +func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*gRPC.ClusterConfig, error) { cluster, err := impl.clusterService.FindById(clusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - config := &ClusterConfig{ + config := &gRPC.ClusterConfig{ ApiServerUrl: cluster.ServerUrl, Token: cluster.Config[k8s.BearerToken], ClusterId: int32(cluster.Id), @@ -286,25 +289,25 @@ func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*ClusterConfig, e return config, nil } -func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*AppDetail, error) { +func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*gRPC.AppDetail, error) { return impl.getApplicationDetail(ctx, app, nil) } -func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*AppStatus, error) { +func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) { return impl.getApplicationAndReleaseStatus(ctx, app) } -func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *ResourceTreeFilter) (*AppDetail, error) { +func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { return impl.getApplicationDetail(ctx, app, resourceTreeFilter) } -func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *AppIdentifier, resourceTreeFilter *ResourceTreeFilter) (*AppDetail, error) { +func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -334,13 +337,13 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *A return appdetail, err } -func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*AppStatus, error) { +func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -353,28 +356,35 @@ func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Conte return appStatus, err } -func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*HelmAppDeploymentHistory, error) { +func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*gRPC.HelmAppDeploymentHistory, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, } history, err := impl.helmAppClient.GetDeploymentHistory(ctx, req) + if util.GetGRPCErrorDetailedMessage(err) == bean.ErrReleaseNotFound { + err = &util.ApiError{ + Code: constants.HelmReleaseNotFound, + InternalMessage: bean.ErrReleaseNotFound, + UserMessage: fmt.Sprintf("no release found with release name '%s'", req.ReleaseName), + } + } return history, err } -func (impl *HelmAppServiceImpl) GetValuesYaml(ctx context.Context, app *AppIdentifier) (*ReleaseInfo, error) { +func (impl *HelmAppServiceImpl) GetValuesYaml(ctx context.Context, app *AppIdentifier) (*gRPC.ReleaseInfo, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -390,11 +400,11 @@ func (impl *HelmAppServiceImpl) GetDesiredManifest(ctx context.Context, app *App return nil, err } - req := &ObjectRequest{ + req := &gRPC.ObjectRequest{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, - ObjectIdentifier: &ObjectIdentifier{ + ObjectIdentifier: &gRPC.ObjectIdentifier{ Group: resource.GetGroup(), Kind: resource.GetKind(), Version: resource.GetVersion(), @@ -513,7 +523,7 @@ func (impl *HelmAppServiceImpl) DeleteApplication(ctx context.Context, app *AppI return nil, models.NamespaceNotExistError{Err: fmt.Errorf("namespace %s does not exist", app.Namespace)} } - req := &ReleaseIdentifier{ + req := &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -564,15 +574,15 @@ func (impl *HelmAppServiceImpl) checkIfNsExists(app *AppIdentifier) (bool, error return exists, nil } -func (impl *HelmAppServiceImpl) UpdateApplication(ctx context.Context, app *AppIdentifier, request *UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) { +func (impl *HelmAppServiceImpl) UpdateApplication(ctx context.Context, app *AppIdentifier, request *bean.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "clusterId", app.ClusterId, "err", err) return nil, err } - req := &UpgradeReleaseRequest{ - ReleaseIdentifier: &ReleaseIdentifier{ + req := &gRPC.UpgradeReleaseRequest{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -600,8 +610,8 @@ func (impl *HelmAppServiceImpl) GetDeploymentDetail(ctx context.Context, app *Ap return nil, err } - req := &DeploymentDetailRequest{ - ReleaseIdentifier: &ReleaseIdentifier{ + req := &gRPC.DeploymentDetailRequest{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -623,7 +633,7 @@ func (impl *HelmAppServiceImpl) GetDeploymentDetail(ctx context.Context, app *Ap return response, nil } -func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *InstallReleaseRequest) (*InstallReleaseResponse, error) { +func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) { config, err := impl.GetClusterConf(clusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "clusterId", clusterId, "err", err) @@ -642,7 +652,7 @@ func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId in } func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, - request *UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) { + request *bean.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) { config, err := impl.GetClusterConf(clusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "clusterId", clusterId, "err", err) @@ -671,7 +681,7 @@ func (impl *HelmAppServiceImpl) IsReleaseInstalled(ctx context.Context, app *App return false, err } - req := &ReleaseIdentifier{ + req := &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -693,8 +703,8 @@ func (impl *HelmAppServiceImpl) RollbackRelease(ctx context.Context, app *AppIde return false, err } - req := &RollbackReleaseRequest{ - ReleaseIdentifier: &ReleaseIdentifier{ + req := &gRPC.RollbackReleaseRequest{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -720,7 +730,7 @@ func (impl *HelmAppServiceImpl) GetDevtronHelmAppIdentifier() *AppIdentifier { } func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, - chartRepository *ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { + chartRepository *gRPC.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { // get release info releaseInfo, err := impl.GetValuesYaml(context.Background(), appIdentifier) @@ -794,9 +804,9 @@ func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ct // update in helm - updateReleaseRequest := &UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &InstallReleaseRequest{ - ReleaseIdentifier: &ReleaseIdentifier{ + updateReleaseRequest := &bean.UpdateApplicationWithChartInfoRequestDto{ + InstallReleaseRequest: &gRPC.InstallReleaseRequest{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ReleaseName: appIdentifier.ReleaseName, ReleaseNamespace: appIdentifier.Namespace, }, @@ -804,7 +814,7 @@ func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ct ValuesYaml: string(mergedValuesYamlByteArr), ChartRepository: chartRepository, }, - SourceAppType: SOURCE_UNKNOWN, + SourceAppType: bean.SOURCE_UNKNOWN, } if !useLatestChartVersion { updateReleaseRequest.ChartVersion = releaseInfo.DeployedAppDetail.ChartVersion @@ -865,8 +875,8 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart return nil, err } var IsOCIRepo bool - var registryCredential *RegistryCredential - var chartRepository *ChartRepository + var registryCredential *gRPC.RegistryCredential + var chartRepository *gRPC.ChartRepository dockerRegistryId := appStoreAppVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs := appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig @@ -882,7 +892,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart } } IsOCIRepo = true - registryCredential = &RegistryCredential{ + registryCredential = &gRPC.RegistryCredential{ RegistryUrl: appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreAppVersion.AppStore.DockerArtifactStore.Username, Password: appStoreAppVersion.AppStore.DockerArtifactStore.Password, @@ -894,7 +904,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &ChartRepository{ + chartRepository = &gRPC.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, @@ -902,13 +912,13 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart } } - installReleaseRequest := &InstallReleaseRequest{ + installReleaseRequest := &gRPC.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: *templateChartRequest.ValuesYaml, K8SVersion: k8sServerVersion.String(), ChartRepository: chartRepository, - ReleaseIdentifier: &ReleaseIdentifier{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ReleaseNamespace: *templateChartRequest.Namespace, ReleaseName: *templateChartRequest.ReleaseName, }, @@ -936,7 +946,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart return response, nil } -func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *InstallReleaseRequest) (string, error) { +func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (string, error) { var notesTxt string response, err := impl.helmAppClient.GetNotes(ctx, request) if err != nil { @@ -947,7 +957,7 @@ func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *InstallRe return notesTxt, err } -func (impl *HelmAppServiceImpl) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *RegistryCredential) bool { +func (impl *HelmAppServiceImpl) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *gRPC.RegistryCredential) bool { response, err := impl.helmAppClient.ValidateOCIRegistry(ctx, OCIRegistryRequest) if err != nil { impl.logger.Errorw("error in fetching chart", "err", err) @@ -985,7 +995,7 @@ func (impl *HelmAppServiceImpl) EncodeAppId(appIdentifier *AppIdentifier) string return fmt.Sprintf("%d|%s|%s", appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) } -func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *DeployedAppList, token string, helmAuth func(token string, object string) bool, helmCdPipelines []*pipelineConfig.Pipeline, installedHelmApps []*repository.InstalledApps) openapi.AppList { +func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *gRPC.DeployedAppList, token string, helmAuth func(token string, object string) bool, helmCdPipelines []*pipelineConfig.Pipeline, installedHelmApps []*repository.InstalledApps) openapi.AppList { applicationType := "HELM-APP" appList := openapi.AppList{ClusterIds: &[]int32{deployedApps.ClusterId}, ApplicationType: &applicationType} if deployedApps.Errored { @@ -1054,13 +1064,13 @@ func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *Deploy return appList } -func (impl *HelmAppServiceImpl) GetRevisionHistoryMaxValue(appType SourceAppType) int32 { +func (impl *HelmAppServiceImpl) GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32 { switch appType { - case SOURCE_DEVTRON_APP: + case bean.SOURCE_DEVTRON_APP: return int32(impl.helmReleaseConfig.RevisionHistoryLimitDevtronApp) - case SOURCE_HELM_APP: + case bean.SOURCE_HELM_APP: return int32(impl.helmReleaseConfig.RevisionHistoryLimitHelmApp) - case SOURCE_EXTERNAL_HELM_APP: + case bean.SOURCE_EXTERNAL_HELM_APP: return int32(impl.helmReleaseConfig.RevisionHistoryLimitExternalHelmApp) default: return 0 diff --git a/api/helm-app/wire_helmApp.go b/api/helm-app/wire_helmApp.go index 82c492f049..f7a453ee3b 100644 --- a/api/helm-app/wire_helmApp.go +++ b/api/helm-app/wire_helmApp.go @@ -1,21 +1,23 @@ package client import ( + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/util/rbac" "github.com/google/wire" ) var HelmAppWireSet = wire.NewSet( - NewHelmAppClientImpl, - wire.Bind(new(HelmAppClient), new(*HelmAppClientImpl)), - GetHelmReleaseConfig, - NewHelmAppServiceImpl, - wire.Bind(new(HelmAppService), new(*HelmAppServiceImpl)), + gRPC.NewHelmAppClientImpl, + wire.Bind(new(gRPC.HelmAppClient), new(*gRPC.HelmAppClientImpl)), + service.GetHelmReleaseConfig, + service.NewHelmAppServiceImpl, + wire.Bind(new(service.HelmAppService), new(*service.HelmAppServiceImpl)), NewHelmAppRestHandlerImpl, wire.Bind(new(HelmAppRestHandler), new(*HelmAppRestHandlerImpl)), NewHelmAppRouterImpl, wire.Bind(new(HelmAppRouter), new(*HelmAppRouterImpl)), - GetConfig, + gRPC.GetConfig, rbac.NewEnforcerUtilHelmImpl, wire.Bind(new(rbac.EnforcerUtilHelm), new(*rbac.EnforcerUtilHelmImpl)), ) diff --git a/api/k8s/application/k8sApplicationRestHandler.go b/api/k8s/application/k8sApplicationRestHandler.go index 0fa90296ab..b0af48bea4 100644 --- a/api/k8s/application/k8sApplicationRestHandler.go +++ b/api/k8s/application/k8sApplicationRestHandler.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + client "github.com/devtron-labs/devtron/api/helm-app/service" "net/http" "strconv" "strings" @@ -14,7 +15,6 @@ import ( "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/connector" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/restHandler/common" util2 "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" diff --git a/api/restHandler/AppListingRestHandler.go b/api/restHandler/AppListingRestHandler.go index 870f54bae6..6c20e37b98 100644 --- a/api/restHandler/AppListingRestHandler.go +++ b/api/restHandler/AppListingRestHandler.go @@ -21,6 +21,8 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "net/http" "strconv" "strings" @@ -33,7 +35,6 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s/health" k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/cron" @@ -90,16 +91,17 @@ type AppListingRestHandler interface { } type AppListingRestHandlerImpl struct { - application application.ServiceClient - appListingService app.AppListingService - teamService team.TeamService - enforcer casbin.Enforcer - pipeline pipeline.PipelineBuilder - logger *zap.SugaredLogger - enforcerUtil rbac.EnforcerUtil - deploymentGroupService deploymentGroup.DeploymentGroupService - userService user.UserService - helmAppClient client.HelmAppClient + application application.ServiceClient + appListingService app.AppListingService + teamService team.TeamService + enforcer casbin.Enforcer + pipeline pipeline.PipelineBuilder + logger *zap.SugaredLogger + enforcerUtil rbac.EnforcerUtil + deploymentGroupService deploymentGroup.DeploymentGroupService + userService user.UserService + // TODO fix me next + helmAppClient gRPC.HelmAppClient // TODO refactoring: use HelmAppService clusterService cluster.ClusterService helmAppService client.HelmAppService argoUserService argo.ArgoUserService @@ -137,7 +139,7 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient, pipeline pipeline.PipelineBuilder, logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil, deploymentGroupService deploymentGroup.DeploymentGroupService, userService user.UserService, - helmAppClient client.HelmAppClient, clusterService cluster.ClusterService, helmAppService client.HelmAppService, + helmAppClient gRPC.HelmAppClient, clusterService cluster.ClusterService, helmAppService client.HelmAppService, argoUserService argo.ArgoUserService, k8sCommonService k8s.K8sCommonService, installedAppService service1.InstalledAppService, cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, pipelineRepository pipelineConfig.PipelineRepository, @@ -1578,7 +1580,7 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter if err != nil { handler.logger.Errorw("error in fetching cluster detail", "err", err) } - req := &client.AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: cdPipeline.Environment.Namespace, ReleaseName: cdPipeline.DeploymentAppName, diff --git a/api/restHandler/AppRestHandler.go b/api/restHandler/AppRestHandler.go index ed0b6ab4e0..c787fd4f66 100644 --- a/api/restHandler/AppRestHandler.go +++ b/api/restHandler/AppRestHandler.go @@ -19,11 +19,11 @@ package restHandler import ( "encoding/json" + client "github.com/devtron-labs/devtron/api/helm-app/service" "net/http" "strconv" "strings" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/app" diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index 7bb093ac6c..3c36e51f77 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -5,12 +5,12 @@ import ( "encoding/base64" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" "net/http" "time" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/internal/sql/repository" repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" "github.com/devtron-labs/devtron/pkg/attributes" @@ -53,7 +53,7 @@ type TelemetryEventClientImpl struct { moduleRepository moduleRepo.ModuleRepository serverDataStore *serverDataStore.ServerDataStore userAuditService user2.UserAuditService - helmAppClient client.HelmAppClient + helmAppClient gRPC.HelmAppClient InstalledAppRepository repository2.InstalledAppRepository userAttributesRepository repository.UserAttributesRepository } @@ -70,7 +70,7 @@ type TelemetryEventClient interface { func NewTelemetryEventClientImpl(logger *zap.SugaredLogger, client *http.Client, clusterService cluster.ClusterService, K8sUtil *k8s.K8sUtil, aCDAuthConfig *util3.ACDAuthConfig, userService user2.UserService, attributeRepo repository.AttributesRepository, ssoLoginService sso.SSOLoginService, - PosthogClient *PosthogClient, moduleRepository moduleRepo.ModuleRepository, serverDataStore *serverDataStore.ServerDataStore, userAuditService user2.UserAuditService, helmAppClient client.HelmAppClient, InstalledAppRepository repository2.InstalledAppRepository) (*TelemetryEventClientImpl, error) { + PosthogClient *PosthogClient, moduleRepository moduleRepo.ModuleRepository, serverDataStore *serverDataStore.ServerDataStore, userAuditService user2.UserAuditService, helmAppClient gRPC.HelmAppClient, InstalledAppRepository repository2.InstalledAppRepository) (*TelemetryEventClientImpl, error) { cron := cron.New( cron.WithChain()) cron.Start() @@ -219,8 +219,8 @@ func (impl *TelemetryEventClientImpl) SummaryDetailsForTelemetry() (cluster []cl ExternalHelmAppClusterCount = make(map[int32]int) for _, clusterDetail := range clusters { - req := &client.AppListRequest{} - config := &client.ClusterConfig{ + req := &gRPC.AppListRequest{} + config := &gRPC.ClusterConfig{ ApiServerUrl: clusterDetail.ServerUrl, Token: clusterDetail.Config[k8s.BearerToken], ClusterId: int32(clusterDetail.Id), diff --git a/client/telemetry/TelemetryEventClientExtended.go b/client/telemetry/TelemetryEventClientExtended.go index c719e12513..e427edb0df 100644 --- a/client/telemetry/TelemetryEventClientExtended.go +++ b/client/telemetry/TelemetryEventClientExtended.go @@ -2,11 +2,11 @@ package telemetry import ( "encoding/json" + client "github.com/devtron-labs/devtron/api/helm-app/gRPC" "net/http" "time" util2 "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index f304d374d9..819b9b7363 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -24,6 +24,8 @@ import ( "github.com/devtron-labs/devtron/api/dashboardEvent" externalLink2 "github.com/devtron-labs/devtron/api/externalLink" client2 "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/service" application2 "github.com/devtron-labs/devtron/api/k8s/application" capacity2 "github.com/devtron-labs/devtron/api/k8s/capacity" module2 "github.com/devtron-labs/devtron/api/module" @@ -45,16 +47,16 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" - repository8 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + repository7 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - service3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + service2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - "github.com/devtron-labs/devtron/pkg/appStore/discover/service" + service3 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" - service2 "github.com/devtron-labs/devtron/pkg/appStore/values/service" + service4 "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authentication" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" @@ -77,7 +79,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository8 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -185,22 +187,22 @@ func InitializeApp() (*App, error) { } chartRepositoryServiceImpl := chartRepo.NewChartRepositoryServiceImpl(sugaredLogger, chartRepoRepositoryImpl, k8sUtil, clusterServiceImpl, acdAuthConfig, httpClient, serverEnvConfigServerEnvConfig) installedAppRepositoryImpl := repository4.NewInstalledAppRepositoryImpl(sugaredLogger, db) - helmClientConfig, err := client2.GetConfig() + helmClientConfig, err := gRPC.GetConfig() if err != nil { return nil, err } - helmAppClientImpl := client2.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) + helmAppClientImpl := gRPC.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) pumpImpl := connector.NewPumpImpl(sugaredLogger) appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) enforcerUtilHelmImpl := rbac.NewEnforcerUtilHelmImpl(sugaredLogger, clusterRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, installedAppRepositoryImpl) serverDataStoreServerDataStore := serverDataStore.InitServerDataStore() appStoreApplicationVersionRepositoryImpl := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) pipelineRepositoryImpl := pipelineConfig.NewPipelineRepositoryImpl(db, sugaredLogger) - helmReleaseConfig, err := client2.GetHelmReleaseConfig() + helmReleaseConfig, err := service.GetHelmReleaseConfig() if err != nil { return nil, err } - helmAppServiceImpl := client2.NewHelmAppServiceImpl(sugaredLogger, clusterServiceImpl, helmAppClientImpl, pumpImpl, enforcerUtilHelmImpl, serverDataStoreServerDataStore, serverEnvConfigServerEnvConfig, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, appRepositoryImpl, clusterRepositoryImpl, k8sUtil, helmReleaseConfig) + helmAppServiceImpl := service.NewHelmAppServiceImpl(sugaredLogger, clusterServiceImpl, helmAppClientImpl, pumpImpl, enforcerUtilHelmImpl, serverDataStoreServerDataStore, serverEnvConfigServerEnvConfig, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, appRepositoryImpl, clusterRepositoryImpl, k8sUtil, helmReleaseConfig) dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) dockerRegistryIpsConfigRepositoryImpl := repository5.NewDockerRegistryIpsConfigRepositoryImpl(db) ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) @@ -231,10 +233,18 @@ func InitializeApp() (*App, error) { return nil, err } dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) + chartGroupDeploymentRepositoryImpl := repository7.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) + installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - gitCliUtil := util.NewGitCliUtil(sugaredLogger) - gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) + deploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() + if err != nil { + return nil, err + } + acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } @@ -243,15 +253,20 @@ func InitializeApp() (*App, error) { return nil, err } gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) + gitCliUtil := util.NewGitCliUtil(sugaredLogger) + gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) + if err != nil { + return nil, err + } gitOpsRemoteOperationServiceImpl := remote.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) - helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) + helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sUtil, clusterServiceImpl) environmentRestHandlerImpl := cluster2.NewEnvironmentRestHandlerImpl(environmentServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceImpl, k8sUtil, k8sCommonServiceImpl) environmentRouterImpl := cluster2.NewEnvironmentRouterImpl(environmentRestHandlerImpl) - k8sResourceHistoryRepositoryImpl := repository7.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryRepositoryImpl := repository8.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) ephemeralContainerServiceImpl := cluster.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) @@ -266,26 +281,13 @@ func InitializeApp() (*App, error) { k8sApplicationRouterImpl := application2.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) chartRepositoryRestHandlerImpl := chartRepo2.NewChartRepositoryRestHandlerImpl(sugaredLogger, userServiceImpl, chartRepositoryServiceImpl, enforcerImpl, validate, deleteServiceImpl, attributesServiceImpl) chartRepositoryRouterImpl := chartRepo2.NewChartRepositoryRouterImpl(chartRepositoryRestHandlerImpl) - appStoreServiceImpl := service.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) + appStoreServiceImpl := service3.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) appStoreRestHandlerImpl := appStoreDiscover.NewAppStoreRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreServiceImpl, enforcerImpl) appStoreDiscoverRouterImpl := appStoreDiscover.NewAppStoreDiscoverRouterImpl(appStoreRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) - appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) + appStoreValuesServiceImpl := service4.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) - chartGroupDeploymentRepositoryImpl := repository8.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) - installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) - deploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() - if err != nil { - return nil, err - } - acdConfig, err := argocdServer.GetACDDeploymentConfig() - if err != nil { - return nil, err - } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) @@ -304,7 +306,7 @@ func InitializeApp() (*App, error) { } dashboardTelemetryRestHandlerImpl := dashboardEvent.NewDashboardTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImpl) dashboardTelemetryRouterImpl := dashboardEvent.NewDashboardTelemetryRouterImpl(dashboardTelemetryRestHandlerImpl) - commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppRestHandlerImpl, helmUserServiceImpl) + commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, helmUserServiceImpl) commonDeploymentRouterImpl := appStoreDeployment.NewCommonDeploymentRouterImpl(commonDeploymentRestHandlerImpl) externalLinkMonitoringToolRepositoryImpl := externalLink.NewExternalLinkMonitoringToolRepositoryImpl(db) externalLinkIdentifierMappingRepositoryImpl := externalLink.NewExternalLinkIdentifierMappingRepositoryImpl(db) diff --git a/internal/util/ChartService.go b/internal/util/ChartService.go index f904ed4490..84aa11e0dc 100644 --- a/internal/util/ChartService.go +++ b/internal/util/ChartService.go @@ -21,6 +21,7 @@ import ( "compress/gzip" "context" "fmt" + util2 "github.com/devtron-labs/devtron/pkg/appStore/util" "io/ioutil" "math/rand" "os" @@ -41,7 +42,7 @@ import ( const ( PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd" PIPELINE_DEPLOYMENT_TYPE_HELM = "helm" - PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD = "manifest_download" + PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD = "manifest_download" // TODO refactoring: This const belongs to enterprise only ChartWorkingDirPath = "/tmp/charts/" ) @@ -67,6 +68,8 @@ type ChartTemplateService interface { LoadChartFromDir(dir string) (*chart.Chart, error) CreateZipFileForChart(chart *chart.Chart, outputChartPathDir string) ([]byte, error) PackageChart(tempReferenceTemplateDir string, chartMetaData *chart.Metadata) (*string, string, error) + // AddConfigFileToChart will override requirements.yaml file in chart + AddConfigFileToChart(config *ChartConfig, dir string, clonedDir string) error } type ChartTemplateServiceImpl struct { randSource rand.Source @@ -417,6 +420,28 @@ func (impl ChartTemplateServiceImpl) CreateZipFileForChart(chart *chart.Chart, o return chartBytesArr, nil } +func (impl ChartTemplateServiceImpl) AddConfigFileToChart(config *ChartConfig, dir string, clonedDir string) error { + filePath := filepath.Join(clonedDir, config.FileName) + file, err := os.Create(filePath) + if err != nil { + impl.logger.Errorw("error in creating file", "err", err, "fileName", config.FileName) + return err + } + defer file.Close() + _, err = file.Write([]byte(config.FileContent)) + if err != nil { + impl.logger.Errorw("error in writing file content", "err", err, "fileName", config.FileName) + return err + } + destinationFilePath := filepath.Join(dir, config.FileName) + err = util2.MoveFileToDestination(filePath, destinationFilePath) + if err != nil { + impl.logger.Errorw("error in moving file from source to destination", "err", err) + return err + } + return nil +} + func IsHelmApp(deploymentAppType string) bool { return deploymentAppType == PIPELINE_DEPLOYMENT_TYPE_HELM } @@ -425,6 +450,7 @@ func IsAcdApp(deploymentAppType string) bool { return deploymentAppType == PIPELINE_DEPLOYMENT_TYPE_ACD } +// TODO refactoring: This feature belongs to enterprise only func IsManifestDownload(deploymentAppType string) bool { return deploymentAppType == PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD } diff --git a/pkg/app/integrationTest/AppService_test.go b/pkg/app/integrationTest/AppService_test.go index 03ed6b6423..de06a34394 100644 --- a/pkg/app/integrationTest/AppService_test.go +++ b/pkg/app/integrationTest/AppService_test.go @@ -4,6 +4,8 @@ import ( "encoding/csv" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "log" "os" "strconv" @@ -12,7 +14,6 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - client "github.com/devtron-labs/devtron/api/helm-app" client1 "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" @@ -130,11 +131,11 @@ func InitAppService() *app2.AppServiceImpl { moduleActionAuditLogRepository := module.NewModuleActionAuditLogRepositoryImpl(dbConnection) clusterRepository := repository1.NewClusterRepositoryImpl(dbConnection, logger) clusterService := cluster.NewClusterServiceImplExtended(clusterRepository, nil, nil, logger, nil, nil, nil, nil, nil, nil, nil, nil) - helmClientConfig, err := client.GetConfig() + helmClientConfig, err := gRPC.GetConfig() if err != nil { log.Fatal("error in getting server helm client config, AppService_test", "err", err) } - helmAppClient := client.NewHelmAppClientImpl(logger, helmClientConfig) + helmAppClient := gRPC.NewHelmAppClientImpl(logger, helmClientConfig) helmAppService := client.NewHelmAppServiceImpl(logger, clusterService, helmAppClient, nil, nil, nil, serverEnvConfig, nil, nil, nil, nil, nil, nil, nil, nil) moduleService := module.NewModuleServiceImpl(logger, serverEnvConfig, moduleRepositoryImpl, moduleActionAuditLogRepository, helmAppService, nil, nil, nil, nil, nil, nil, nil) eventClient := client1.NewEventRESTClientImpl(logger, httpClient, eventClientConfig, pubSubClient, ciPipelineRepositoryImpl, diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index c8954dffb8..86456bcfb9 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -351,15 +351,6 @@ func (a AppstoreDeploymentStatus) String() string { "HELM_SUCCESS"}[a] } -type PushChartToGitRequestDTO struct { - AppName string - EnvName string - ChartAppStoreName string - RepoURL string - TempChartRefDir string - UserId int32 -} - type HelmReleaseStatusConfig struct { InstallAppVersionHistoryId int Message string diff --git a/pkg/appStore/deployment/adapter/Adapter.go b/pkg/appStore/deployment/adapter/Adapter.go new file mode 100644 index 0000000000..32cfe7f161 --- /dev/null +++ b/pkg/appStore/deployment/adapter/Adapter.go @@ -0,0 +1,26 @@ +package adapter + +import ( + "github.com/devtron-labs/devtron/internal/util" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote/bean" + "k8s.io/helm/pkg/proto/hapi/chart" +) + +func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, repoURl string, tempRefChart string) *bean.PushChartToGitRequestDTO { + return &bean.PushChartToGitRequestDTO{ + AppName: installAppRequestDTO.AppName, + EnvName: installAppRequestDTO.Environment.Name, + ChartAppStoreName: installAppRequestDTO.AppStoreName, + RepoURL: repoURl, + TempChartRefDir: tempRefChart, + UserId: installAppRequestDTO.UserId, + } +} + +func ParseChartCreateRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, chartPath string) *util.ChartCreateRequest { + return &util.ChartCreateRequest{ChartMetaData: &chart.Metadata{ + Name: installAppRequestDTO.AppName, + Version: "1.0.1", + }, ChartPath: chartPath} +} diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 59554f7d86..5000cb125e 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -19,147 +19,40 @@ package appStoreDeploymentCommon import ( "encoding/json" - "fmt" - "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - util2 "github.com/devtron-labs/devtron/pkg/appStore/util" - repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" - commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" - "github.com/go-pg/pg" "go.uber.org/zap" "k8s.io/helm/pkg/chartutil" - "k8s.io/helm/pkg/proto/hapi/chart" - "os" - "path" - "path/filepath" "sigs.k8s.io/yaml" ) type AppStoreDeploymentCommonService interface { - // move to DB service - GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) - GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) - - // common for all gitops? - CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) - - // keep here only - GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) - GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) + // GetValuesString will return values string from the given valuesOverrideYaml GetValuesString(chartName, valuesOverrideYaml string) (string, error) + // GetRequirementsString will return requirement dependencies for the given appStoreVersionId GetRequirementsString(appStoreVersionId int) (string, error) - - // rethink - GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *AppStoreManifestResponse, err error) - - // gitops service - ParseGitRepoErrorResponse(err error) (bool, error) - CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) - GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) - GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) + // CreateChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml + CreateChartProxyAndGetPath(chartCreateRequest *util.ChartCreateRequest) (*util.ChartCreateResponse, error) } type AppStoreDeploymentCommonServiceImpl struct { logger *zap.SugaredLogger - installedAppRepository repository.InstalledAppRepository appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository2.EnvironmentRepository chartTemplateService util.ChartTemplateService - gitFactory *util.GitFactory - gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } func NewAppStoreDeploymentCommonServiceImpl( logger *zap.SugaredLogger, - installedAppRepository repository.InstalledAppRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository repository2.EnvironmentRepository, - chartTemplateService util.ChartTemplateService, - gitFactory *util.GitFactory, - gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentCommonServiceImpl { + chartTemplateService util.ChartTemplateService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ logger: logger, - installedAppRepository: installedAppRepository, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, chartTemplateService: chartTemplateService, - gitFactory: gitFactory, - gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, - } -} - -// TODO: move this from here - -func ParseChartCreateRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, chartPath string) *util.ChartCreateRequest { - return &util.ChartCreateRequest{ChartMetaData: &chart.Metadata{ - Name: installAppRequestDTO.AppName, - Version: "1.0.1", - }, ChartPath: chartPath} -} - -func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, repoURl string, tempRefChart string) *appStoreBean.PushChartToGitRequestDTO { - return &appStoreBean.PushChartToGitRequestDTO{ - AppName: installAppRequestDTO.AppName, - EnvName: installAppRequestDTO.Environment.Name, - ChartAppStoreName: installAppRequestDTO.AppStoreName, - RepoURL: repoURl, - TempChartRefDir: tempRefChart, - UserId: installAppRequestDTO.UserId, } } -type AppStoreManifestResponse struct { - ChartResponse *util.ChartCreateResponse - ValuesConfig *util.ChartConfig - RequirementsConfig *util.ChartConfig -} - -type AppStoreGitOpsResponse struct { - ChartGitAttribute *commonBean.ChartGitAttribute - GitHash string -} - -func (impl AppStoreDeploymentCommonServiceImpl) GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) { - installedApp, err := impl.installedAppRepository.GetInstalledApplicationByClusterIdAndNamespaceAndAppName(clusterId, namespace, appName) - if err != nil { - if err == pg.ErrNoRows { - impl.logger.Warnw("no installed apps found", "clusterId", clusterId) - return nil, nil - } else { - impl.logger.Errorw("error while fetching installed apps", "clusterId", clusterId, "error", err) - return nil, err - } - } - - if installedApp.Id > 0 { - installedAppVersion, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedApp.Id, installedApp.EnvironmentId) - if err != nil { - return nil, err - } - return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil - } - - return nil, nil -} - -func (impl AppStoreDeploymentCommonServiceImpl) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) { - installedAppVersion, err := impl.installedAppRepository.GetActiveInstalledAppVersionByInstalledAppId(installedAppId) - if err != nil { - return nil, err - } - installedApp := &installedAppVersion.InstalledApp - return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil -} - func (impl AppStoreDeploymentCommonServiceImpl) GetValuesString(chartName, valuesOverrideYaml string) (string, error) { ValuesOverrideByte, err := yaml.YAMLToJSON([]byte(valuesOverrideYaml)) @@ -213,153 +106,17 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetRequirementsString(appStoreVe return string(requirementDependenciesByte), nil } -func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - - argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name - gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) - userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) - YamlConfig := &util.ChartConfig{ - FileName: filename, - FileContent: fileString, - ChartName: installAppVersionRequest.AppName, - ChartLocation: argocdAppName, - ChartRepoName: gitOpsRepoName, - ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), - UserEmailId: userEmailId, - UserName: userName, - } - return YamlConfig, nil -} - -func (impl AppStoreDeploymentCommonServiceImpl) GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) { - - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, nil, err - } - values, err := impl.GetValuesString(appStoreAppVersion.AppStore.Name, installAppVersionRequest.ValuesOverrideYaml) - if err != nil { - impl.logger.Errorw("error in getting values fot installedAppVersionRequest", "err", err) - return nil, nil, err - } - dependency, err := impl.GetRequirementsString(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("error in getting dependency array fot installedAppVersionRequest", "err", err) - return nil, nil, err - } - valuesConfig, err := impl.GetGitCommitConfig(installAppVersionRequest, values, appStoreBean.VALUES_YAML_FILE) - if err != nil { - impl.logger.Errorw("error in creating values config for git", "err", err) - return nil, nil, err - } - RequirementConfig, err := impl.GetGitCommitConfig(installAppVersionRequest, dependency, appStoreBean.REQUIREMENTS_YAML_FILE) - if err != nil { - impl.logger.Errorw("error in creating dependency config for git", "err", err) - return nil, nil, err - } - return valuesConfig, RequirementConfig, nil -} - -func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *AppStoreManifestResponse, err error) { - - manifestResponse = &AppStoreManifestResponse{} - - ChartCreateResponse, err := impl.CreateChartProxyAndGetPath(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("Error in building chart while generating manifest", "err", err) - return manifestResponse, err - } - valuesConfig, dependencyConfig, err := impl.GetValuesAndRequirementGitConfig(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in fetching values and requirements.yaml config while generating manifest", "err", err) - return manifestResponse, err - } - - manifestResponse.ChartResponse = ChartCreateResponse - manifestResponse.ValuesConfig = valuesConfig - manifestResponse.RequirementsConfig = dependencyConfig - - return manifestResponse, nil -} - -// CreateGitOpsRepo creates a gitOps repo with readme -func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { - if len(installAppVersionRequest.GitOpsRepoName) == 0 { - //here gitops repo will be the app name, to breaking the mono repo structure - gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) - installAppVersionRequest.GitOpsRepoName = gitOpsRepoName - } - bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() - if err != nil { - impl.logger.Errorw("error in getting bitbucket metadata", "err", err) - return "", false, err - } - //getting user name & emailId for commit author data - gitRepoRequest := &bean.GitOpsConfigDto{ - GitRepoName: installAppVersionRequest.GitOpsRepoName, - Description: "helm chart for " + installAppVersionRequest.GitOpsRepoName, - BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, - BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, - } - repoUrl, isNew, err := impl.gitOpsRemoteOperationService.CreateRepository(gitRepoRequest, installAppVersionRequest.UserId) - if err != nil { - impl.logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) - return "", false, err - } - return repoUrl, isNew, err -} - -// AddConfigFileToChart will override requirements.yaml file in chart -func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *util.ChartConfig, dir string, clonedDir string) error { - filePath := filepath.Join(clonedDir, config.FileName) - file, err := os.Create(filePath) - if err != nil { - impl.logger.Errorw("error in creating file", "err", err, "fileName", config.FileName) - return err - } - defer file.Close() - _, err = file.Write([]byte(config.FileContent)) - if err != nil { - impl.logger.Errorw("error in writing file content", "err", err, "fileName", config.FileName) - return err - } - destinationFilePath := filepath.Join(dir, config.FileName) - err = util2.MoveFileToDestination(filePath, destinationFilePath) - if err != nil { - impl.logger.Errorw("error in moving file from source to destination", "err", err) - return err - } - return nil -} - -// CreateChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml -func (impl AppStoreDeploymentCommonServiceImpl) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { - +func (impl AppStoreDeploymentCommonServiceImpl) CreateChartProxyAndGetPath(chartCreateRequest *util.ChartCreateRequest) (*util.ChartCreateResponse, error) { ChartCreateResponse := &util.ChartCreateResponse{} - template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) - valid, err := chartutil.IsChartDir(chartPath) + valid, err := chartutil.IsChartDir(chartCreateRequest.ChartPath) if err != nil || !valid { - impl.logger.Errorw("invalid base chart", "dir", chartPath, "err", err) + impl.logger.Errorw("invalid base chart", "dir", chartCreateRequest.ChartPath, "err", err) return ChartCreateResponse, err } - chartCreateRequest := ParseChartCreateRequest(installAppVersionRequest, chartPath) chartCreateResponse, err := impl.chartTemplateService.BuildChartProxyForHelmApps(chartCreateRequest) if err != nil { impl.logger.Errorw("Error in building chart proxy", "err", err) return chartCreateResponse, err } return chartCreateResponse, nil - } diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go b/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go deleted file mode 100644 index 9b9846f415..0000000000 --- a/pkg/appStore/deployment/common/AppStoreDeploymentGitService.go +++ /dev/null @@ -1,184 +0,0 @@ -package appStoreDeploymentCommon - -import ( - "fmt" - "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/appStore/bean" - commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/google/go-github/github" - "github.com/microsoft/azure-devops-go-api/azuredevops" - dirCopy "github.com/otiai10/copy" - "github.com/xanzy/go-gitlab" - "net/http" - "os" - "path/filepath" - "regexp" -) - -func (impl AppStoreDeploymentCommonServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { - //update values yaml in chart - noTargetFound := false - if err != nil { - if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) - noTargetFound = true - } - if err.Error() == util.BITBUCKET_REPO_NOT_FOUND_ERROR { - impl.logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) - noTargetFound = true - } - } - return noTargetFound, err -} - -// CreateGitOpsRepoAndPushChart is a wrapper for creating GitOps repo and pushing chart to created repo -func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { - repoURL, isNew, err := impl.CreateGitOpsRepo(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) - return nil, false, "", err - } - pushChartToGitRequest := ParseChartGitPushRequest(installAppVersionRequest, repoURL, builtChartPath) - chartGitAttribute, commitHash, err := impl.pushChartToGitOpsRepo(pushChartToGitRequest, requirementsConfig, valuesConfig) - if err != nil { - impl.logger.Errorw("error in pushing chart to git", "err", err) - return nil, false, "", err - } - return chartGitAttribute, isNew, commitHash, err -} - -func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestResponse *AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { - appStoreGitOpsResponse := &AppStoreGitOpsResponse{} - chartGitAttribute, isNew, githash, err := impl.CreateGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) - if err != nil { - impl.logger.Errorw("Error in pushing chart to git", "err", err) - return appStoreGitOpsResponse, err - } - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(installAppVersionRequest.AppName, "-") - clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName - - // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. - // step-2 commit dependencies and values in git - if !isNew { - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.RequirementsConfig) - if err != nil { - impl.logger.Errorw("error in committing dependency config to git", "err", err) - return appStoreGitOpsResponse, err - } - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return appStoreGitOpsResponse, err - } - - githash, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.ValuesConfig) - if err != nil { - impl.logger.Errorw("error in committing values config to git", "err", err) - return appStoreGitOpsResponse, err - } - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err) - return appStoreGitOpsResponse, err - } - } - appStoreGitOpsResponse.ChartGitAttribute = chartGitAttribute - appStoreGitOpsResponse.GitHash = githash - return appStoreGitOpsResponse, nil -} - -func (impl AppStoreDeploymentCommonServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*AppStoreGitOpsResponse, error) { - appStoreGitOpsResponse := &AppStoreGitOpsResponse{} - manifest, err := impl.GenerateManifest(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in performing manifest and git operations", "err", err) - return nil, err - } - gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in performing gitops operation", "err", err) - return nil, err - } - installAppVersionRequest.GitHash = gitOpsResponse.GitHash - appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute - return appStoreGitOpsResponse, nil -} - -// pushChartToGitOpsRepo pushes built chart to GitOps repo -func (impl AppStoreDeploymentCommonServiceImpl) pushChartToGitOpsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, string, error) { - space := regexp.MustCompile(`\s+`) - appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") - chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(PushChartToGitRequest.RepoURL, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) - return nil, "", err - } - } else { - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) - if err != nil { - return nil, "", err - } - } - acdAppName := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, PushChartToGitRequest.EnvName) - dir := filepath.Join(clonedDir, acdAppName) - err := os.MkdirAll(dir, os.ModePerm) - if err != nil { - impl.logger.Errorw("error in making dir", "err", err) - return nil, "", err - } - err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, "", err - } - err = impl.AddConfigFileToChart(requirementsConfig, dir, clonedDir) - if err != nil { - impl.logger.Errorw("error in adding requirements.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) - return nil, "", err - } - err = impl.AddConfigFileToChart(valuesConfig, dir, clonedDir) - if err != nil { - impl.logger.Errorw("error in adding values.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) - return nil, "", err - } - userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) - commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) - if err != nil { - impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) - return nil, "", err - } - err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) - if err != nil { - impl.logger.Errorw("error copying dir", "err", err) - return nil, "", err - } - commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) - if err != nil { - impl.logger.Errorw("error in pushing git", "err", err) - return nil, "", err - } - } - impl.logger.Debugw("template committed", "url", PushChartToGitRequest.RepoURL, "commit", commit) - defer impl.chartTemplateService.CleanDir(clonedDir) - return &commonBean.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err -} diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go deleted file mode 100644 index 87f3bbd0a4..0000000000 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package appStoreDeploymentFullMode - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "github.com/devtron-labs/common-lib/pubsub-lib" - "github.com/devtron-labs/common-lib/pubsub-lib/model" - commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" - "time" - - "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/pkg/app/status" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" - "github.com/devtron-labs/devtron/pkg/sql" - util2 "github.com/devtron-labs/devtron/pkg/util" - "github.com/devtron-labs/devtron/util/argo" - "github.com/go-pg/pg" - - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "go.uber.org/zap" -) - -const ( - DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT = "devtron" - CLUSTER_COMPONENT_DIR_PATH = "/cluster/component" -) - -// ACD operation and git operation -type AppStoreDeploymentFullModeService interface { - AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error - GetGitOpsRepoName(appName string, environmentName string) (string, error) -} - -type AppStoreDeploymentFullModeServiceImpl struct { - logger *zap.SugaredLogger - acdClient application2.ServiceClient - ArgoK8sClient argocdServer.ArgoK8sClient - aCDAuthConfig *util2.ACDAuthConfig - argoUserService argo.ArgoUserService - pipelineStatusTimelineService status.PipelineStatusTimelineService - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - argoClientWrapperService argocdServer.ArgoClientWrapperService - pubSubClient *pubsub_lib.PubSubClientServiceImpl - installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository - ACDConfig *argocdServer.ACDConfig - gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService -} - -func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, - acdClient application2.ServiceClient, - argoK8sClient argocdServer.ArgoK8sClient, aCDAuthConfig *util2.ACDAuthConfig, - argoUserService argo.ArgoUserService, pipelineStatusTimelineService status.PipelineStatusTimelineService, - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - argoClientWrapperService argocdServer.ArgoClientWrapperService, - pubSubClient *pubsub_lib.PubSubClientServiceImpl, - installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, - ACDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentFullModeServiceImpl { - appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ - logger: logger, - acdClient: acdClient, - ArgoK8sClient: argoK8sClient, - aCDAuthConfig: aCDAuthConfig, - argoUserService: argoUserService, - pipelineStatusTimelineService: pipelineStatusTimelineService, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, - argoClientWrapperService: argoClientWrapperService, - pubSubClient: pubSubClient, - installedAppRepositoryHistory: installedAppRepositoryHistory, - ACDConfig: ACDConfig, - gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, - } - err := appStoreDeploymentFullModeServiceImpl.subscribeHelmInstallStatus() - if err != nil { - return nil - } - return appStoreDeploymentFullModeServiceImpl -} - -func (impl AppStoreDeploymentFullModeServiceImpl) AppStoreDeployOperationACD(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) - defer cancel() - //STEP 4: registerInArgo - err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) - if err != nil { - impl.logger.Errorw("error in argo registry", "err", err) - return nil, err - } - //STEP 5: createInArgo - err = impl.createInArgo(chartGitAttr, ctx, *installAppVersionRequest.Environment, installAppVersionRequest.ACDAppName) - if err != nil { - impl.logger.Errorw("error in create in argo", "err", err) - return nil, err - } - //STEP 6: Force Sync ACD - works like trigger deployment - //impl.SyncACD(installAppVersionRequest.ACDAppName, ctx) - - //STEP 7: normal refresh ACD - update for step 6 to avoid delay - syncTime := time.Now() - err = impl.argoClientWrapperService.SyncArgoCDApplicationIfNeededAndRefresh(ctx, installAppVersionRequest.ACDAppName) - if err != nil { - impl.logger.Errorw("error in getting the argo application with normal refresh", "err", err) - return nil, err - } - if !impl.ACDConfig.ArgoCDAutoSyncEnabled { - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_COMPLETED, - StatusDetail: "argocd sync completed.", - StatusTime: syncTime, - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if err != nil { - impl.logger.Errorw("error in creating timeline for argocd sync", "err", err, "timeline", timeline) - } - } - - return installAppVersionRequest, nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, ctx context.Context, envModel repository5.Environment, argocdAppName string) error { - appNamespace := envModel.Namespace - if appNamespace == "" { - appNamespace = "default" - } - appreq := &argocdServer.AppTemplate{ - ApplicationName: argocdAppName, - Namespace: impl.aCDAuthConfig.ACDConfigMapNamespace, - TargetNamespace: appNamespace, - TargetServer: envModel.Cluster.ServerUrl, - Project: "default", - ValuesFile: fmt.Sprintf("values.yaml"), - RepoPath: chartGitAttribute.ChartLocation, - RepoUrl: chartGitAttribute.RepoUrl, - AutoSyncEnabled: impl.ACDConfig.ArgoCDAutoSyncEnabled, - } - _, err := impl.ArgoK8sClient.CreateAcdApp(appreq, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) - //create - if err != nil { - impl.logger.Errorw("error in creating argo cd app ", "err", err) - return err - } - return nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) GetGitOpsRepoName(appName string, environmentName string) (string, error) { - gitOpsRepoName := "" - //this method should only call in case of argo-integration and gitops configured - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - return "", err - } - ctx := context.Background() - ctx = context.WithValue(ctx, "token", acdToken) - acdAppName := fmt.Sprintf("%s-%s", appName, environmentName) - application, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) - if err != nil { - impl.logger.Errorw("no argo app exists", "acdAppName", acdAppName, "err", err) - return "", err - } - if application != nil { - gitOpsRepoUrl := application.Spec.Source.RepoURL - gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) - } - return gitOpsRepoName, nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) UpdateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - - valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(installAppVersionRequest.AppStoreName, installAppVersionRequest.ValuesOverrideYaml) - if err != nil { - impl.logger.Errorw("error in getting values string", "err", err) - return nil, err - } - - valuesGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE) - if err != nil { - impl.logger.Errorw("error in getting git commit config", "err", err) - } - - commitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) - if err != nil { - impl.logger.Errorw("error in git commit", "err", err) - return installAppVersionRequest, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) - } - //update timeline status for git commit state - installAppVersionRequest.GitHash = commitHash - return installAppVersionRequest, nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) UpdateRequirementYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { - - requirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(appStoreAppVersion.Id) - if err != nil { - impl.logger.Errorw("error in getting requirements string", "err", err) - return err - } - - requirementsGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, requirementsString, appStoreBean.REQUIREMENTS_YAML_FILE) - if err != nil { - impl.logger.Errorw("error in getting git commit config", "err", err) - return err - } - - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) - if err != nil { - impl.logger.Errorw("error in values commit", "err", err) - return errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) - } - - return nil -} - -func (impl AppStoreDeploymentFullModeServiceImpl) subscribeHelmInstallStatus() error { - - callback := func(msg *model.PubSubMsg) { - - impl.logger.Debug("received helm install status event - HELM_INSTALL_STATUS", "data", msg.Data) - helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} - err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) - if err != nil { - impl.logger.Errorw("error in unmarshalling helm install status nats message", "err", err) - return - } - - installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(helmInstallNatsMessage.InstallAppVersionHistoryId) - if err != nil { - impl.logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) - return - } - if helmInstallNatsMessage.ErrorInInstallation { - installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed - } else { - installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - } - installedAppVersionHistory.HelmReleaseStatusConfig = msg.Data - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) - if err != nil { - impl.logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) - return - } - } - - err := impl.pubSubClient.Subscribe(pubsub_lib.HELM_CHART_INSTALL_STATUS_TOPIC, callback) - if err != nil { - impl.logger.Error(err) - return err - } - return nil -} diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go b/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go index dea7c70d0b..72c404e27d 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go @@ -178,3 +178,35 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(in } return true, nil } + +func (impl AppStoreDeploymentServiceImpl) GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) { + installedApp, err := impl.installedAppRepository.GetInstalledApplicationByClusterIdAndNamespaceAndAppName(clusterId, namespace, appName) + if err != nil { + if err == pg.ErrNoRows { + impl.logger.Warnw("no installed apps found", "clusterId", clusterId) + return nil, nil + } else { + impl.logger.Errorw("error while fetching installed apps", "clusterId", clusterId, "error", err) + return nil, err + } + } + + if installedApp.Id > 0 { + installedAppVersion, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedApp.Id, installedApp.EnvironmentId) + if err != nil { + return nil, err + } + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil + } + + return nil, nil +} + +func (impl AppStoreDeploymentServiceImpl) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) { + installedAppVersion, err := impl.installedAppRepository.GetActiveInstalledAppVersionByInstalledAppId(installedAppId) + if err != nil { + return nil, err + } + installedApp := &installedAppVersion.InstalledApp + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil +} diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index 1fbb14a37c..a515c55594 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -23,8 +23,10 @@ import ( "errors" "fmt" "github.com/caarlos0/env/v6" - client "github.com/devtron-labs/devtron/api/helm-app" + bean3 "github.com/devtron-labs/devtron/api/helm-app/bean" + bean4 "github.com/devtron-labs/devtron/api/helm-app/gRPC" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" + "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/internal/constants" @@ -39,6 +41,7 @@ import ( appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" + bean2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" @@ -64,10 +67,10 @@ type AppStoreDeploymentService interface { GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) DeleteInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) - LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, appIdentifier *client.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) + LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, appIdentifier *service.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) RollbackApplication(ctx context.Context, request *openapi2.RollbackReleaseRequest, installedApp *appStoreBean.InstallAppVersionDTO, userId int32) (bool, error) UpdateInstallAppVersionHistory(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*repository.InstalledAppVersionHistory, error) - GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.DeploymentHistoryAndInstalledAppInfo, error) + GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistoryId int) (*openapi.HelmAppDeploymentManifestDetail, error) UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) UpdateInstalledAppVersionHistoryWithGitHash(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) error @@ -76,6 +79,9 @@ type AppStoreDeploymentService interface { UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error + + GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) + GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) } type DeploymentServiceTypeConfig struct { @@ -101,7 +107,7 @@ type AppStoreDeploymentServiceImpl struct { appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService environmentService cluster.EnvironmentService clusterService cluster.ClusterService - helmAppService client.HelmAppService + helmAppService service.HelmAppService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository gitOpsRepository repository2.GitOpsConfigRepository @@ -116,7 +122,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService, appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, - clusterService cluster.ClusterService, helmAppService client.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + clusterService cluster.ClusterService, helmAppService service.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, @@ -181,19 +187,18 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) } - manifest, err := impl.appStoreDeploymentCommonService.GenerateManifest(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in performing manifest and git operations", "err", err) - return nil, err - } - - if installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD { + if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) } - var gitOpsResponse *appStoreDeploymentCommon.AppStoreGitOpsResponse + var gitOpsResponse *bean2.AppStoreGitOpsResponse if installedAppDeploymentAction.PerformGitOps { - gitOpsResponse, err = impl.appStoreDeploymentCommonService.GitOpsOperations(manifest, installAppVersionRequest) + manifest, err := impl.appStoreDeploymentArgoCdService.GenerateManifest(installAppVersionRequest) + if err != nil { + impl.logger.Errorw("error in performing manifest and git operations", "err", err) + return nil, err + } + gitOpsResponse, err = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) if err != nil { impl.logger.Errorw("error in doing gitops operation", "err", err) if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { @@ -455,9 +460,7 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context } if installAppVersionRequest.AcdPartialDelete == true { - if util2.IsBaseStack() || util2.IsHelmApp(app.AppOfferingMode) || util.IsHelmApp(model.DeploymentAppType) { - err = impl.appStoreDeploymentHelmService.DeleteDeploymentApp(ctx, app.AppName, environment.Name, installAppVersionRequest) - } else { + if !util2.IsBaseStack() && !util2.IsHelmApp(app.AppOfferingMode) && !util.IsHelmApp(model.DeploymentAppType) { if !installAppVersionRequest.InstalledAppDeleteResponse.ClusterReachable { impl.logger.Errorw("cluster connection error", "err", environment.Cluster.ErrorInConnecting) if !installAppVersionRequest.NonCascadeDelete { @@ -554,7 +557,7 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context } func (impl AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, - appIdentifier *client.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) { + appIdentifier *service.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) { impl.logger.Infow("Linking helm application to chart store", "appId", request.GetAppId()) @@ -732,20 +735,20 @@ func (impl AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(instal // STEP-2 update APP with chart info chartRepoInfo := appStoreAppVersion.AppStore.ChartRepo - updateReleaseRequest := &client.UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &client.InstallReleaseRequest{ + updateReleaseRequest := &bean3.UpdateApplicationWithChartInfoRequestDto{ + InstallReleaseRequest: &bean4.InstallReleaseRequest{ ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, - ReleaseIdentifier: &client.ReleaseIdentifier{ + ReleaseIdentifier: &bean4.ReleaseIdentifier{ ReleaseNamespace: installAppVersionRequest.Namespace, ReleaseName: installAppVersionRequest.AppName, }, }, - SourceAppType: client.SOURCE_HELM_APP, + SourceAppType: bean3.SOURCE_HELM_APP, } if chartRepoInfo != nil { - updateReleaseRequest.ChartRepository = &client.ChartRepository{ + updateReleaseRequest.ChartRepository = &bean4.ChartRepository{ Name: chartRepoInfo.Name, Url: chartRepoInfo.Url, Username: chartRepoInfo.UserName, @@ -829,8 +832,8 @@ func (impl AppStoreDeploymentServiceImpl) updateInstalledAppVersionHistoryWithSy } return nil } -func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.DeploymentHistoryAndInstalledAppInfo, error) { - result := &client.DeploymentHistoryAndInstalledAppInfo{} +func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) { + result := &bean3.DeploymentHistoryAndInstalledAppInfo{} var err error if util2.IsHelmApp(installedApp.AppOfferingMode) { deploymentHistory, err := impl.appStoreDeploymentHelmService.GetDeploymentHistory(ctx, installedApp) @@ -849,7 +852,7 @@ func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Conte } if installedApp.InstalledAppId > 0 { - result.InstalledAppInfo = &client.InstalledAppInfo{ + result.InstalledAppInfo = &bean3.InstalledAppInfo{ AppId: installedApp.AppId, EnvironmentName: installedApp.EnvironmentName, AppOfferingMode: installedApp.AppOfferingMode, @@ -1012,6 +1015,8 @@ func (impl *AppStoreDeploymentServiceImpl) MarkInstalledAppVersionModelInActive( } func (impl *AppStoreDeploymentServiceImpl) CreateInstalledAppVersion(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*repository.InstalledAppVersions, error) { + // TODO fix me next + // TODO refactoring: move this to adapter installedAppVersion := &repository.InstalledAppVersions{ InstalledAppId: installAppVersionRequest.InstalledAppId, AppStoreApplicationVersionId: installAppVersionRequest.AppStoreVersion, @@ -1040,7 +1045,7 @@ func (impl *AppStoreDeploymentServiceImpl) CheckIfMonoRepoMigrationRequired(inst gitOpsRepoName := installedApp.GitOpsRepoName if len(gitOpsRepoName) == 0 { if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) + gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) if err != nil { return false } @@ -1116,6 +1121,8 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } installedAppVersion.Id = installedAppVersion.Id } else { + // TODO fix me next + // TODO refactoring: move this to adapter installedAppVersion.ValuesYaml = installAppVersionRequest.ValuesOverrideYaml installedAppVersion.UpdatedOn = time.Now() installedAppVersion.UpdatedBy = installAppVersionRequest.UserId @@ -1139,6 +1146,8 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex installAppVersionRequest.Environment = &installedApp.Environment installAppVersionHistoryStatus := pipelineConfig.WorkflowInProgress + // TODO fix me next + // TODO refactoring: move this to adapter installedAppVersionHistory := &repository.InstalledAppVersionHistory{ InstalledAppVersionId: installedAppVersion.Id, ValuesYamlRaw: installAppVersionRequest.ValuesOverrideYaml, @@ -1159,26 +1168,25 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex installAppVersionRequest.InstalledAppVersionHistoryId = installedAppVersionHistory.Id _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) - manifest, err := impl.appStoreDeploymentCommonService.GenerateManifest(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in generating manifest for helm apps", "err", err) - _ = impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowFailed) - return nil, err - } - if installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD { + if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) } // gitOps operation monoRepoMigrationRequired := false - gitOpsResponse := &appStoreDeploymentCommon.AppStoreGitOpsResponse{} + gitOpsResponse := &bean2.AppStoreGitOpsResponse{} if installedAppDeploymentAction.PerformGitOps { - + manifest, err := impl.appStoreDeploymentArgoCdService.GenerateManifest(installAppVersionRequest) + if err != nil { + impl.logger.Errorw("error in generating manifest for helm apps", "err", err) + _ = impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowFailed) + return nil, err + } // required if gitOps repo name is changed, gitOps repo name will change if env variable which we use as suffix changes gitOpsRepoName := installedApp.GitOpsRepoName if len(gitOpsRepoName) == 0 { if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) + gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) if err != nil { return nil, err } @@ -1201,10 +1209,10 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex var createRepoErr, requirementsCommitErr, valuesCommitErr error var gitHash string - + // TODO refactoring: move this logic to AppStoreDeploymentGitService.go if monoRepoMigrationRequired { // create new git repo if repo name changed - gitOpsResponse, createRepoErr = impl.appStoreDeploymentCommonService.GitOpsOperations(manifest, installAppVersionRequest) + gitOpsResponse, createRepoErr = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) gitHash = gitOpsResponse.GitHash } else if isChartChanged || isVersionChanged { @@ -1219,13 +1227,13 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex if valuesCommitErr != nil || requirementsCommitErr != nil { - noTargetFoundForValues, _ := impl.appStoreDeploymentCommonService.ParseGitRepoErrorResponse(valuesCommitErr) - noTargetFoundForRequirements, _ := impl.appStoreDeploymentCommonService.ParseGitRepoErrorResponse(requirementsCommitErr) + noTargetFoundForValues, _ := impl.appStoreDeploymentArgoCdService.ParseGitRepoErrorResponse(valuesCommitErr) + noTargetFoundForRequirements, _ := impl.appStoreDeploymentArgoCdService.ParseGitRepoErrorResponse(requirementsCommitErr) if noTargetFoundForRequirements || noTargetFoundForValues { //create repo again and try again - auto fix monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required - gitOpsResponse, createRepoErr = impl.appStoreDeploymentCommonService.GitOpsOperations(manifest, installAppVersionRequest) + gitOpsResponse, createRepoErr = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) gitHash = gitOpsResponse.GitHash } @@ -1234,6 +1242,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex if createRepoErr != nil || requirementsCommitErr != nil || valuesCommitErr != nil { impl.logger.Errorw("error in doing gitops operation", "err", err) _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) + // TODO refactoring: return proper err object return nil, err } diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go index e0589afb1b..81eae67783 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go @@ -173,9 +173,9 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl nil, InstalledAppVersionHistoryRepository, gitOpsRepository, - nil, &DeploymentServiceTypeConfig{IsInternalUse: internalUse}, nil, + nil, nil) return AppStoreDeploymentServiceImpl diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index d7334501f6..8f5ad9002f 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -20,9 +20,12 @@ package service import ( "bytes" "context" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" + appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + util2 "github.com/devtron-labs/devtron/pkg/util" /* #nosec */ "crypto/sha1" @@ -38,7 +41,6 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/common-lib/pubsub-lib/model" util4 "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/internal/middleware" @@ -49,8 +51,6 @@ import ( appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/values/service" @@ -60,7 +60,6 @@ import ( application3 "github.com/devtron-labs/devtron/pkg/k8s/application" "github.com/devtron-labs/devtron/pkg/sql" repository4 "github.com/devtron-labs/devtron/pkg/team" - util2 "github.com/devtron-labs/devtron/pkg/util" util3 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" @@ -69,7 +68,6 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" bean2 "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/bean" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" @@ -108,23 +106,20 @@ type InstalledAppServiceImpl struct { chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository envService cluster2.EnvironmentService aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository userService user.UserService appStoreDeploymentService AppStoreDeploymentService - appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository argoUserService argo.ArgoUserService - helmAppClient client.HelmAppClient + helmAppClient gRPC.HelmAppClient helmAppService client.HelmAppService appStatusService appStatus.AppStatusService K8sUtil *util4.K8sUtil pipelineStatusTimelineService status.PipelineStatusTimelineService - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService k8sCommonService k8s.K8sCommonService k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig - gitOpsConfigReadService config.GitOpsConfigReadService gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, @@ -137,17 +132,16 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, pubsubClient *pubsub.PubSubClientServiceImpl, chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository, envService cluster2.EnvironmentService, - aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, - appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, + userService user.UserService, aCDAuthConfig *util2.ACDAuthConfig, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, - argoUserService argo.ArgoUserService, helmAppClient client.HelmAppClient, helmAppService client.HelmAppService, + argoUserService argo.ArgoUserService, helmAppClient gRPC.HelmAppClient, helmAppService client.HelmAppService, appStatusService appStatus.AppStatusService, K8sUtil *util4.K8sUtil, pipelineStatusTimelineService status.PipelineStatusTimelineService, - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, - acdConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) (*InstalledAppServiceImpl, error) { + acdConfig *argocdServer.ACDConfig, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService, + appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -161,10 +155,8 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, chartGroupDeploymentRepository: chartGroupDeploymentRepository, envService: envService, aCDAuthConfig: aCDAuthConfig, - gitOpsRepository: gitOpsRepository, userService: userService, appStoreDeploymentService: appStoreDeploymentService, - appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, installedAppRepositoryHistory: installedAppRepositoryHistory, argoUserService: argoUserService, helmAppClient: helmAppClient, @@ -172,19 +164,59 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, appStatusService: appStatusService, K8sUtil: K8sUtil, pipelineStatusTimelineService: pipelineStatusTimelineService, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, k8sCommonService: k8sCommonService, k8sApplicationService: k8sApplicationService, acdConfig: acdConfig, - gitOpsConfigReadService: gitOpsConfigReadService, gitOpsRemoteOperationService: gitOpsRemoteOperationService, + appStoreDeploymentArgoCdService: appStoreDeploymentArgoCdService, } err := impl.subscribe() if err != nil { return nil, err } + err = impl.subscribeHelmInstallStatus() + if err != nil { + return nil, err + } return impl, nil } +func (impl InstalledAppServiceImpl) subscribeHelmInstallStatus() error { + + callback := func(msg *model.PubSubMsg) { + + impl.logger.Debug("received helm install status event - HELM_INSTALL_STATUS", "data", msg.Data) + helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} + err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) + if err != nil { + impl.logger.Errorw("error in unmarshalling helm install status nats message", "err", err) + return + } + + installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(helmInstallNatsMessage.InstallAppVersionHistoryId) + if err != nil { + impl.logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) + return + } + if helmInstallNatsMessage.ErrorInInstallation { + installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed + } else { + installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded + } + installedAppVersionHistory.HelmReleaseStatusConfig = msg.Data + _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) + if err != nil { + impl.logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) + return + } + } + + err := impl.pubsubClient.Subscribe(pubsub.HELM_CHART_INSTALL_STATUS_TOPIC, callback) + if err != nil { + impl.logger.Error(err) + return err + } + return nil +} func (impl InstalledAppServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) { applicationType := "DEVTRON-CHART-STORE" @@ -363,7 +395,7 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion installedAppVersion.Status == appStoreBean.GIT_ERROR { //step 2 git operation pull push //TODO: save git Timeline here - appStoreGitOpsResponse, err := impl.appStoreDeploymentCommonService.GenerateManifestAndPerformGitOperations(installedAppVersion) + appStoreGitOpsResponse, err := impl.appStoreDeploymentArgoCdService.GenerateManifestAndPerformGitOperations(installedAppVersion) if err != nil { impl.logger.Errorw(" error", "err", err) _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_ERROR) @@ -465,7 +497,7 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion installedAppVersion.Status == appStoreBean.GIT_SUCCESS || installedAppVersion.Status == appStoreBean.ACD_ERROR { //step 3 acd operation register, sync - _, err := impl.appStoreDeploymentFullModeService.AppStoreDeployOperationACD(installedAppVersion, chartGitAttr, ctx, nil) + _, err := impl.appStoreDeploymentArgoCdService.InstallApp(installedAppVersion, chartGitAttr, ctx, nil) if err != nil { impl.logger.Errorw("error", "chartGitAttr", chartGitAttr, "err", err) _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_ERROR) @@ -963,9 +995,9 @@ func (impl InstalledAppServiceImpl) GetInstalledAppVersionHistoryValues(installe return values, err } -func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *client.ReleaseStatus { +func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *gRPC.ReleaseStatus { //release status is sent in resource tree call and is shown on UI as helm config apply status - releaseStatus := &client.ReleaseStatus{} + releaseStatus := &gRPC.ReleaseStatus{} if len(helmReleaseInstallStatus) > 0 { helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) @@ -995,6 +1027,7 @@ func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus return releaseStatus } +// TODO fix me next func (impl InstalledAppServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId int, envId int) error { apiError := &util.ApiError{} installedApp, err := impl.installedAppRepository.GetGitOpsInstalledAppsWhereArgoAppDeletedIsTrue(installedAppId, envId) @@ -1004,6 +1037,7 @@ func (impl InstalledAppServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoAppIsDel apiError.InternalMessage = "error in fetching partially deleted argoCd apps from installed app repo" return apiError } + // TODO refactoring: move the below logic to AppStoreDeploymentArgoCdService.go acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() if err != nil { impl.logger.Errorw("error in getting acd token", "err", err) diff --git a/pkg/appStore/deployment/service/Notes.go b/pkg/appStore/deployment/service/Notes.go index 33595afc25..cd008184eb 100644 --- a/pkg/appStore/deployment/service/Notes.go +++ b/pkg/appStore/deployment/service/Notes.go @@ -3,7 +3,7 @@ package service import ( "context" "fmt" - "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/internal/util" "github.com/go-pg/pg" "regexp" @@ -78,18 +78,18 @@ func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, return notes, appName, err } - installReleaseRequest := &client.InstallReleaseRequest{ + installReleaseRequest := &gRPC.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: installedAppVerison.ValuesYaml, K8SVersion: k8sServerVersion.String(), - ChartRepository: &client.ChartRepository{ + ChartRepository: &gRPC.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, Password: appStoreAppVersion.AppStore.ChartRepo.Password, }, - ReleaseIdentifier: &client.ReleaseIdentifier{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ReleaseNamespace: installedAppVerison.InstalledApp.Environment.Namespace, ReleaseName: installedAppVerison.InstalledApp.App.AppName, }, diff --git a/pkg/appStore/deployment/service/ResourceTree.go b/pkg/appStore/deployment/service/ResourceTree.go index e826bacb55..3d0e36b617 100644 --- a/pkg/appStore/deployment/service/ResourceTree.go +++ b/pkg/appStore/deployment/service/ResourceTree.go @@ -8,7 +8,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/api/helm-app" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/appStatus" @@ -35,7 +35,7 @@ func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn h if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) } - req := &client.AppDetailRequest{ + req := &bean2.AppDetailRequest{ ClusterConfig: config, Namespace: installedApp.Environment.Namespace, ReleaseName: installedApp.App.AppName, diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go index 6b4361ae7d..839d6e78ff 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go @@ -5,14 +5,19 @@ import ( "encoding/json" "errors" "fmt" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" + repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + util2 "github.com/devtron-labs/devtron/pkg/util" "strings" "time" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" @@ -24,7 +29,6 @@ import ( appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository2 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -40,23 +44,47 @@ import ( // creating duplicates because cannot use type AppStoreDeploymentArgoCdService interface { - //InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) + // ArgoCd Services --------------------------------- + + // InstallApp will register git repo in Argo, create and sync the Argo App and finally update deployment status InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + // DeleteInstalledApp will delete entry from appStatus.AppStatusDto table and from repository.ChartGroupDeployment table (if exists) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error + // RollbackRelease will rollback to a previous deployment for the given installedAppVersionHistoryId; returns - valuesYamlStr, success, error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) - GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) + // GetDeploymentHistory will return gRPC.HelmAppDeploymentHistory for the given installedAppDto.InstalledAppId + GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) + // GetDeploymentHistoryInfo will return openapi.HelmAppDeploymentManifestDetail for the given appStoreBean.InstallAppVersionDTO GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - GetGitOpsRepoName(appName string, environmentName string) (string, error) + // GetAcdAppGitOpsRepoName will return the Git Repo used in the ACD app object + GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) + // DeleteDeploymentApp will delete the app object from ACD DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error - UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error + + // Deployment Status Services ---------------------- + + // UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus updates failed status in pipelineConfig.PipelineStatusTimeline table + UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error + + // Git Operation Services -------------------------- + + // ParseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) + ParseGitRepoErrorResponse(err error) (bool, error) + // GitOpsOperations performs git operations specific to helm app deployments + GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) + // GenerateManifest returns bean.AppStoreManifestResponse required in GitOps + GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) + // GenerateManifestAndPerformGitOperations is a wrapper function for both GenerateManifest and GitOpsOperations + GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) } type AppStoreDeploymentArgoCdServiceImpl struct { Logger *zap.SugaredLogger - appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService acdClient application2.ServiceClient + argoK8sClient argocdServer.ArgoK8sClient + aCDAuthConfig *util2.ACDAuthConfig chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository installedAppRepository repository.InstalledAppRepository installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository @@ -71,22 +99,36 @@ type AppStoreDeploymentArgoCdServiceImpl struct { argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsConfigReadService config.GitOpsConfigReadService + environmentRepository repository5.EnvironmentRepository } -func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, - acdClient application2.ServiceClient, chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, - installedAppRepository repository.InstalledAppRepository, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, - argoUserService argo.ArgoUserService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - helmAppService client.HelmAppService, appStatusService appStatus.AppStatusService, - pipelineStatusTimelineService status.PipelineStatusTimelineService, userService user.UserService, +func NewAppStoreDeploymentArgoCdServiceImpl( + logger *zap.SugaredLogger, + acdClient application2.ServiceClient, + argoK8sClient argocdServer.ArgoK8sClient, + aCDAuthConfig *util2.ACDAuthConfig, + chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, + installedAppRepository repository.InstalledAppRepository, + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, + argoUserService argo.ArgoUserService, + appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + helmAppService client.HelmAppService, + appStatusService appStatus.AppStatusService, + pipelineStatusTimelineService status.PipelineStatusTimelineService, + userService user.UserService, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentArgoCdServiceImpl { + argoClientWrapperService argocdServer.ArgoClientWrapperService, + acdConfig *argocdServer.ACDConfig, + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService, + gitOpsConfigReadService config.GitOpsConfigReadService, + environmentRepository repository5.EnvironmentRepository) *AppStoreDeploymentArgoCdServiceImpl { return &AppStoreDeploymentArgoCdServiceImpl{ Logger: logger, - appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, acdClient: acdClient, + argoK8sClient: argoK8sClient, + aCDAuthConfig: aCDAuthConfig, chartGroupDeploymentRepository: chartGroupDeploymentRepository, installedAppRepository: installedAppRepository, installedAppRepositoryHistory: installedAppRepositoryHistory, @@ -101,6 +143,8 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD argoClientWrapperService: argoClientWrapperService, acdConfig: acdConfig, gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOpsConfigReadService: gitOpsConfigReadService, + environmentRepository: environmentRepository, } } @@ -177,31 +221,52 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) SaveTimelineForACDHelmApps(insta } func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { + ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) + defer cancel() + //STEP 4: registerInArgo + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) + if err != nil { + impl.Logger.Errorw("error in argo registry", "err", err) + return nil, err + } + //STEP 5: createInArgo + err = impl.createInArgo(chartGitAttr, *installAppVersionRequest.Environment, installAppVersionRequest.ACDAppName) + if err != nil { + impl.Logger.Errorw("error in create in argo", "err", err) + return nil, err + } + //STEP 6: Force Sync ACD - works like trigger deployment + //impl.SyncACD(installAppVersionRequest.ACDAppName, ctx) - installAppVersionRequest, err := impl.appStoreDeploymentFullModeService.AppStoreDeployOperationACD(installAppVersionRequest, chartGitAttr, ctx, tx) + //STEP 7: normal refresh ACD - update for step 6 to avoid delay + syncTime := time.Now() + err = impl.argoClientWrapperService.SyncArgoCDApplicationIfNeededAndRefresh(ctx, installAppVersionRequest.ACDAppName) if err != nil { - impl.Logger.Errorw(" error", "err", err) - return installAppVersionRequest, err + impl.Logger.Errorw("error in getting the argo application with normal refresh", "err", err) + return nil, err } + if !impl.acdConfig.ArgoCDAutoSyncEnabled { + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, + Status: pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_COMPLETED, + StatusDetail: "argocd sync completed.", + StatusTime: syncTime, + AuditLog: sql.AuditLog{ + CreatedBy: installAppVersionRequest.UserId, + CreatedOn: time.Now(), + UpdatedBy: installAppVersionRequest.UserId, + UpdatedOn: time.Now(), + }, + } + err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) + if err != nil { + impl.Logger.Errorw("error in creating timeline for argocd sync", "err", err, "timeline", timeline) + } + } + return installAppVersionRequest, nil } -//func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { -// //step 2 git operation pull push -// installAppVersionRequest, chartGitAttr, err := impl.appStoreDeploymentFullModeService.AppStoreDeployOperationGIT(installAppVersionRequest) -// if err != nil { -// impl.Logger.Errorw(" error", "err", err) -// return installAppVersionRequest, err -// } -// //step 3 acd operation register, sync -// installAppVersionRequest, err = impl.appStoreDeploymentFullModeService.AppStoreDeployOperationACD(installAppVersionRequest, chartGitAttr, ctx) -// if err != nil { -// impl.Logger.Errorw(" error", "err", err) -// return installAppVersionRequest, err -// } -// return installAppVersionRequest, nil -//} - func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { err := impl.appStatusService.DeleteWithAppIdEnvId(dbTransaction, installedApps.AppId, installedApps.EnvironmentId) @@ -231,7 +296,6 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteInstalledApp(ctx context.C return nil } -// returns - valuesYamlStr, success, error func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistoryId int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) { //request version id for versionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(int(installedAppVersionHistoryId)) @@ -294,7 +358,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Cont } //If current version upgrade/degrade to another, update requirement dependencies if versionHistory.InstalledAppVersionId != activeInstalledAppVersion.Id { - err = impl.appStoreDeploymentFullModeService.UpdateRequirementYaml(installedApp, &installedAppVersion.AppStoreApplicationVersion) + err = impl.updateRequirementYamlInGit(installedApp, &installedAppVersion.AppStoreApplicationVersion) if err != nil { if errors.Is(err, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED)) { impl.Logger.Errorw("error", "err", err) @@ -312,7 +376,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Cont } } //Update Values config - installedApp, err = impl.appStoreDeploymentFullModeService.UpdateValuesYaml(installedApp, tx) + installedApp, err = impl.updateValuesYamlInGit(installedApp) if err != nil { impl.Logger.Errorw("error", "err", err) if errors.Is(err, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED)) { @@ -364,40 +428,9 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Cont return installedApp, true, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) deleteACD(acdAppName string, ctx context.Context, isNonCascade bool) error { - req := new(application.ApplicationDeleteRequest) - req.Name = &acdAppName - cascadeDelete := !isNonCascade - req.Cascade = &cascadeDelete - if ctx == nil { - impl.Logger.Errorw("err in delete ACD for AppStore, ctx is NULL", "acdAppName", acdAppName) - return fmt.Errorf("context is null") - } - if _, err := impl.acdClient.Delete(ctx, req); err != nil { - impl.Logger.Errorw("err in delete ACD for AppStore", "acdAppName", acdAppName, "err", err) - return err - } - return nil -} -func (impl AppStoreDeploymentArgoCdServiceImpl) getSourcesFromManifest(chartYaml string) ([]string, error) { - var b map[string]interface{} - var sources []string - err := json.Unmarshal([]byte(chartYaml), &b) - if err != nil { - impl.Logger.Errorw("error while unmarshal chart yaml", "error", err) - return sources, err - } - if b != nil && b["sources"] != nil { - slice := b["sources"].([]interface{}) - for _, item := range slice { - sources = append(sources, item.(string)) - } - } - return sources, nil -} -func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) { - result := &client.HelmAppDeploymentHistory{} - var history []*client.HelmAppDeploymentDetail +func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { + result := &gRPC.HelmAppDeploymentHistory{} + var history []*gRPC.HelmAppDeploymentDetail //TODO - response setup installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdMeta(installedAppDto.InstalledAppId) @@ -430,8 +463,8 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context if user != nil { emailId = user.EmailId } - history = append(history, &client.HelmAppDeploymentDetail{ - ChartMetadata: &client.ChartMetadata{ + history = append(history, &gRPC.HelmAppDeploymentDetail{ + ChartMetadata: &gRPC.ChartMetadata{ ChartName: installedAppVersionModel.AppStoreApplicationVersion.AppStore.Name, ChartVersion: installedAppVersionModel.AppStoreApplicationVersion.Version, Description: installedAppVersionModel.AppStoreApplicationVersion.Description, @@ -451,12 +484,13 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context } if len(history) == 0 { - history = make([]*client.HelmAppDeploymentDetail, 0) + history = make([]*gRPC.HelmAppDeploymentDetail, 0) } result.DeploymentHistory = history return result, err } +// TODO refactoring: use InstalledAppVersionHistoryId from appStoreBean.InstallAppVersionDTO instead of version int32 func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) { values := &openapi.HelmAppDeploymentManifestDetail{} _, span := otel.Tracer("orchestrator").Start(ctx, "installedAppRepositoryHistory.GetInstalledAppVersionHistory") @@ -496,63 +530,27 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistoryInfo(ctx con return values, err } -func (impl AppStoreDeploymentArgoCdServiceImpl) GetGitOpsRepoName(appName string, environmentName string) (string, error) { - return impl.appStoreDeploymentFullModeService.GetGitOpsRepoName(appName, environmentName) -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { - ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) - defer cancel() - //registerInArgo - err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) - if err != nil { - impl.Logger.Errorw("error in argo registry", "err", err) - return nil, err - } - // update acd app - patchReq := v1alpha1.Application{Spec: v1alpha1.ApplicationSpec{Source: &v1alpha1.ApplicationSource{Path: chartGitAttr.ChartLocation, RepoURL: chartGitAttr.RepoUrl, TargetRevision: "master"}}} - reqbyte, err := json.Marshal(patchReq) - if err != nil { - impl.Logger.Errorw("error in creating patch", "err", err) - } - reqString := string(reqbyte) - patchType := "merge" - _, err = impl.acdClient.Patch(ctx, &application.ApplicationPatchRequest{Patch: &reqString, Name: &installAppVersionRequest.ACDAppName, PatchType: &patchType}) - if err != nil { - impl.Logger.Errorw("error in creating argo app ", "name", installAppVersionRequest.ACDAppName, "patch", string(reqbyte), "err", err) - return nil, err - } - //impl.appStoreDeploymentFullModeService.SyncACD(installAppVersionRequest.ACDAppName, ctx) - return installAppVersionRequest, nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYaml(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.Logger.Errorw("fetching error", "err", err) - return nil, err - } - valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion.Name, installAppVersionRequest.ValuesOverrideYaml) +func (impl AppStoreDeploymentArgoCdServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { + gitOpsRepoName := "" + //this method should only call in case of argo-integration and gitops configured + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() if err != nil { - impl.Logger.Errorw("error in building requirements config for helm app", "err", err) - return nil, err + impl.Logger.Errorw("error in getting acd token", "err", err) + return "", err } - valuesGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE) + ctx := context.Background() + ctx = context.WithValue(ctx, "token", acdToken) + acdAppName := fmt.Sprintf("%s-%s", appName, environmentName) + acdApplication, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) if err != nil { - impl.Logger.Errorw("error in getting git config for helm app", "err", err) - return nil, err + impl.Logger.Errorw("no argo app exists", "acdAppName", acdAppName, "err", err) + return "", err } - gitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) - if err != nil { - impl.Logger.Errorw("error in git commit", "err", err) - _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) - return nil, err + if acdApplication != nil { + gitOpsRepoUrl := acdApplication.Spec.Source.RepoURL + gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) } - _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) - //update timeline status for git commit state - installAppVersionRequest.GitHash = gitHash - return installAppVersionRequest, nil + return gitOpsRepoName, nil } func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { @@ -581,3 +579,87 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteDeploymentApp(ctx context. } return nil } + +func (impl AppStoreDeploymentArgoCdServiceImpl) deleteACD(acdAppName string, ctx context.Context, isNonCascade bool) error { + req := new(application.ApplicationDeleteRequest) + req.Name = &acdAppName + cascadeDelete := !isNonCascade + req.Cascade = &cascadeDelete + if ctx == nil { + impl.Logger.Errorw("err in delete ACD for AppStore, ctx is NULL", "acdAppName", acdAppName) + return fmt.Errorf("context is null") + } + if _, err := impl.acdClient.Delete(ctx, req); err != nil { + impl.Logger.Errorw("err in delete ACD for AppStore", "acdAppName", acdAppName, "err", err) + return err + } + return nil +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) getSourcesFromManifest(chartYaml string) ([]string, error) { + var b map[string]interface{} + var sources []string + err := json.Unmarshal([]byte(chartYaml), &b) + if err != nil { + impl.Logger.Errorw("error while unmarshal chart yaml", "error", err) + return sources, err + } + if b != nil && b["sources"] != nil { + slice := b["sources"].([]interface{}) + for _, item := range slice { + sources = append(sources, item.(string)) + } + } + return sources, nil +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, envModel repository5.Environment, argocdAppName string) error { + appNamespace := envModel.Namespace + if appNamespace == "" { + appNamespace = "default" + } + appreq := &argocdServer.AppTemplate{ + ApplicationName: argocdAppName, + Namespace: impl.aCDAuthConfig.ACDConfigMapNamespace, + TargetNamespace: appNamespace, + TargetServer: envModel.Cluster.ServerUrl, + Project: "default", + ValuesFile: fmt.Sprintf("values.yaml"), + RepoPath: chartGitAttribute.ChartLocation, + RepoUrl: chartGitAttribute.RepoUrl, + AutoSyncEnabled: impl.acdConfig.ArgoCDAutoSyncEnabled, + } + _, err := impl.argoK8sClient.CreateAcdApp(appreq, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) + //create + if err != nil { + impl.Logger.Errorw("error in creating argo cd app ", "err", err) + return err + } + return nil +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { + ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) + defer cancel() + //registerInArgo + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) + if err != nil { + impl.Logger.Errorw("error in argo registry", "err", err) + return nil, err + } + // update acd app + patchReq := v1alpha1.Application{Spec: v1alpha1.ApplicationSpec{Source: &v1alpha1.ApplicationSource{Path: chartGitAttr.ChartLocation, RepoURL: chartGitAttr.RepoUrl, TargetRevision: "master"}}} + reqbyte, err := json.Marshal(patchReq) + if err != nil { + impl.Logger.Errorw("error in creating patch", "err", err) + } + reqString := string(reqbyte) + patchType := "merge" + _, err = impl.acdClient.Patch(ctx, &application.ApplicationPatchRequest{Patch: &reqString, Name: &installAppVersionRequest.ACDAppName, PatchType: &patchType}) + if err != nil { + impl.Logger.Errorw("error in creating argo app ", "name", installAppVersionRequest.ACDAppName, "patch", string(reqbyte), "err", err) + return nil, err + } + //impl.appStoreDeploymentFullModeService.SyncACD(installAppVersionRequest.ACDAppName, ctx) + return installAppVersionRequest, nil +} diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go new file mode 100644 index 0000000000..164d9a8ed4 --- /dev/null +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go @@ -0,0 +1,272 @@ +package appStoreDeploymentTool + +import ( + "errors" + "fmt" + bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/adapter" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" + appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/google/go-github/github" + "github.com/microsoft/azure-devops-go-api/azuredevops" + "github.com/xanzy/go-gitlab" + "net/http" + "path" + "regexp" +) + +func (impl AppStoreDeploymentArgoCdServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { + //update values yaml in chart + noTargetFound := false + if err != nil { + if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) + noTargetFound = true + } + if err.Error() == util.BITBUCKET_REPO_NOT_FOUND_ERROR { + impl.Logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) + noTargetFound = true + } + } + return noTargetFound, err +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { + appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} + manifest, err := impl.GenerateManifest(installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("error in performing manifest and git operations", "err", err) + return nil, err + } + gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("error in performing gitops operation", "err", err) + return nil, err + } + installAppVersionRequest.GitHash = gitOpsResponse.GitHash + appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute + return appStoreGitOpsResponse, nil +} + +// GitOpsOperations handles all git operations for Helm App +func (impl AppStoreDeploymentArgoCdServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { + appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} + chartGitAttribute, isNew, githash, err := impl.createGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) + if err != nil { + impl.Logger.Errorw("Error in pushing chart to git", "err", err) + return appStoreGitOpsResponse, err + } + space := regexp.MustCompile(`\s+`) + appStoreName := space.ReplaceAllString(installAppVersionRequest.AppName, "-") + + // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. + // step-2 commit dependencies and values in git + if !isNew { + githash, err = impl.gitOpsRemoteOperationService.CommitRequirementsAndValues(appStoreName, chartGitAttribute.RepoUrl, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) + if err != nil { + impl.Logger.Errorw("error in committing config to git", "err", err) + return appStoreGitOpsResponse, err + } + } + appStoreGitOpsResponse.ChartGitAttribute = chartGitAttribute + appStoreGitOpsResponse.GitHash = githash + return appStoreGitOpsResponse, nil +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { + + manifestResponse = &bean.AppStoreManifestResponse{} + + ChartCreateResponse, err := impl.createChartProxyAndGetPath(installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("Error in building chart while generating manifest", "err", err) + return manifestResponse, err + } + valuesConfig, dependencyConfig, err := impl.getValuesAndRequirementForGitConfig(installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("error in fetching values and requirements.yaml config while generating manifest", "err", err) + return manifestResponse, err + } + + manifestResponse.ChartResponse = ChartCreateResponse + manifestResponse.ValuesConfig = valuesConfig + manifestResponse.RequirementsConfig = dependencyConfig + + return manifestResponse, nil +} + +// createGitOpsRepoAndPushChart is a wrapper for creating GitOps repo and pushing chart to created repo +func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { + repoURL, isNew, err := impl.createGitOpsRepo(installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) + return nil, false, "", err + } + pushChartToGitRequest := adapter.ParseChartGitPushRequest(installAppVersionRequest, repoURL, builtChartPath) + chartGitAttribute, commitHash, err := impl.gitOpsRemoteOperationService.PushChartToGitOpsRepoForHelmApp(pushChartToGitRequest, requirementsConfig, valuesConfig) + if err != nil { + impl.Logger.Errorw("error in pushing chart to git", "err", err) + return nil, false, "", err + } + return chartGitAttribute, isNew, commitHash, err +} + +// createGitOpsRepo creates a gitOps repo with readme +func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { + if len(installAppVersionRequest.GitOpsRepoName) == 0 { + //here gitops repo will be the app name, to breaking the mono repo structure + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) + installAppVersionRequest.GitOpsRepoName = gitOpsRepoName + } + bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() + if err != nil { + impl.Logger.Errorw("error in getting bitbucket metadata", "err", err) + return "", false, err + } + //getting user name & emailId for commit author data + gitRepoRequest := &bean2.GitOpsConfigDto{ + GitRepoName: installAppVersionRequest.GitOpsRepoName, + Description: "helm chart for " + installAppVersionRequest.GitOpsRepoName, + BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, + BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, + } + repoUrl, isNew, err := impl.gitOpsRemoteOperationService.CreateRepository(gitRepoRequest, installAppVersionRequest.UserId) + if err != nil { + impl.Logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) + return "", false, err + } + return repoUrl, isNew, err +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { + valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(installAppVersionRequest.AppStoreName, installAppVersionRequest.ValuesOverrideYaml) + if err != nil { + impl.Logger.Errorw("error in getting values string", "err", err) + return nil, err + } + + valuesGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE) + if err != nil { + impl.Logger.Errorw("error in getting git commit config", "err", err) + } + + commitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) + if err != nil { + impl.Logger.Errorw("error in git commit", "err", err) + return installAppVersionRequest, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) + } + //update timeline status for git commit state + installAppVersionRequest.GitHash = commitHash + return installAppVersionRequest, nil +} + +func (impl AppStoreDeploymentArgoCdServiceImpl) updateRequirementYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { + requirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(appStoreAppVersion.Id) + if err != nil { + impl.Logger.Errorw("error in getting requirements string", "err", err) + return err + } + + requirementsGitConfig, err := impl.getGitCommitConfig(installAppVersionRequest, requirementsString, appStoreBean.REQUIREMENTS_YAML_FILE) + if err != nil { + impl.Logger.Errorw("error in getting git commit config", "err", err) + return err + } + + _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) + if err != nil { + impl.Logger.Errorw("error in values commit", "err", err) + return errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) + } + + return nil +} + +// createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml +func (impl AppStoreDeploymentArgoCdServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { + template := appStoreBean.CHART_PROXY_TEMPLATE + chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) + chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest, chartPath) + chartCreateResponse, err := impl.appStoreDeploymentCommonService.CreateChartProxyAndGetPath(chartCreateRequest) + if err != nil { + impl.Logger.Errorw("Error in building chart proxy", "err", err) + return chartCreateResponse, err + } + return chartCreateResponse, nil + +} + +// getGitCommitConfig will return util.ChartConfig (git commit config) for GitOps +func (impl AppStoreDeploymentArgoCdServiceImpl) getGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) { + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) + if err != nil { + impl.Logger.Errorw("fetching error", "err", err) + return nil, err + } + environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) + if err != nil { + impl.Logger.Errorw("fetching error", "err", err) + return nil, err + } + + argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name + gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) + YamlConfig := &util.ChartConfig{ + FileName: filename, + FileContent: fileString, + ChartName: installAppVersionRequest.AppName, + ChartLocation: argocdAppName, + ChartRepoName: gitOpsRepoName, + ReleaseMessage: fmt.Sprintf("release-%d-env-%d ", appStoreAppVersion.Id, environment.Id), + UserEmailId: userEmailId, + UserName: userName, + } + return YamlConfig, nil +} + +// getValuesAndRequirementForGitConfig will return chart values(*util.ChartConfig) and requirements(*util.ChartConfig) for git commit +func (impl AppStoreDeploymentArgoCdServiceImpl) getValuesAndRequirementForGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) { + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) + if err != nil { + impl.Logger.Errorw("fetching error", "err", err) + return nil, nil, err + } + values, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion.AppStore.Name, installAppVersionRequest.ValuesOverrideYaml) + if err != nil { + impl.Logger.Errorw("error in getting values fot installedAppVersionRequest", "err", err) + return nil, nil, err + } + dependency, err := impl.appStoreDeploymentCommonService.GetRequirementsString(installAppVersionRequest.AppStoreVersion) + if err != nil { + impl.Logger.Errorw("error in getting dependency array fot installedAppVersionRequest", "err", err) + return nil, nil, err + } + valuesConfig, err := impl.getGitCommitConfig(installAppVersionRequest, values, appStoreBean.VALUES_YAML_FILE) + if err != nil { + impl.Logger.Errorw("error in creating values config for git", "err", err) + return nil, nil, err + } + RequirementConfig, err := impl.getGitCommitConfig(installAppVersionRequest, dependency, appStoreBean.REQUIREMENTS_YAML_FILE) + if err != nil { + impl.Logger.Errorw("error in creating dependency config for git", "err", err) + return nil, nil, err + } + return valuesConfig, RequirementConfig, nil +} diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index e1384780ed..4f4d28c7a8 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -3,16 +3,17 @@ package appStoreDeploymentTool import ( "context" "errors" + bean2 "github.com/devtron-labs/devtron/api/helm-app/bean" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "time" - client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/go-pg/pg" @@ -25,7 +26,7 @@ type AppStoreDeploymentHelmService interface { InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) - GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) + GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error @@ -35,28 +36,24 @@ type AppStoreDeploymentHelmServiceImpl struct { Logger *zap.SugaredLogger helmAppService client.HelmAppService appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - helmAppClient client.HelmAppClient - installedAppRepository repository.InstalledAppRepository - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService - OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + // TODO fix me next + helmAppClient gRPC.HelmAppClient // TODO refactoring: use HelmAppService instead + installedAppRepository repository.InstalledAppRepository + OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository } func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - helmAppClient client.HelmAppClient, - installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentHelmServiceImpl { + helmAppClient gRPC.HelmAppClient, + installedAppRepository repository.InstalledAppRepository, + OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, helmAppClient: helmAppClient, installedAppRepository: installedAppRepository, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, OCIRegistryConfigRepository: OCIRegistryConfigRepository, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, } } @@ -77,8 +74,8 @@ func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionReques return installAppVersionRequest, err } var IsOCIRepo bool - var registryCredential *client.RegistryCredential - var chartRepository *client.ChartRepository + var registryCredential *gRPC.RegistryCredential + var chartRepository *gRPC.ChartRepository dockerRegistryId := appStoreAppVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs, err := impl.OCIRegistryConfigRepository.FindByDockerRegistryId(dockerRegistryId) @@ -94,7 +91,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionReques } } IsOCIRepo = true - registryCredential = &client.RegistryCredential{ + registryCredential = &gRPC.RegistryCredential{ RegistryUrl: appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreAppVersion.AppStore.DockerArtifactStore.Username, Password: appStoreAppVersion.AppStore.DockerArtifactStore.Password, @@ -106,19 +103,19 @@ func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionReques IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &client.ChartRepository{ + chartRepository = &gRPC.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, Password: appStoreAppVersion.AppStore.ChartRepo.Password, } } - installReleaseRequest := &client.InstallReleaseRequest{ + installReleaseRequest := &gRPC.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, ChartRepository: chartRepository, - ReleaseIdentifier: &client.ReleaseIdentifier{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ReleaseNamespace: installAppVersionRequest.Namespace, ReleaseName: installAppVersionRequest.AppName, }, @@ -198,23 +195,13 @@ func (impl AppStoreDeploymentHelmServiceImpl) RollbackRelease(ctx context.Contex return installedApp, success, nil } -func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client.HelmAppDeploymentHistory, error) { - helmAppIdeltifier := &client.AppIdentifier{ +func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { + helmAppIdentifier := &client.AppIdentifier{ ClusterId: installedApp.ClusterId, Namespace: installedApp.Namespace, ReleaseName: installedApp.AppName, } - config, err := impl.helmAppService.GetClusterConf(helmAppIdeltifier.ClusterId) - if err != nil { - impl.Logger.Errorw("error in fetching cluster detail", "err", err) - return nil, err - } - req := &client.AppDetailRequest{ - ClusterConfig: config, - Namespace: helmAppIdeltifier.Namespace, - ReleaseName: helmAppIdeltifier.ReleaseName, - } - history, err := impl.helmAppClient.GetDeploymentHistory(ctx, req) + history, err := impl.helmAppService.GetDeploymentHistory(ctx, helmAppIdentifier) return history, err } @@ -230,8 +217,8 @@ func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistoryInfo(ctx cont return nil, err } - req := &client.DeploymentDetailRequest{ - ReleaseIdentifier: &client.ReleaseIdentifier{ + req := &gRPC.DeploymentDetailRequest{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: helmAppIdeltifier.ReleaseName, ReleaseNamespace: helmAppIdeltifier.Namespace, @@ -254,36 +241,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistoryInfo(ctx cont return response, nil } -func (impl *AppStoreDeploymentHelmServiceImpl) GetGitOpsRepoName(appName string, environmentName string) (string, error) { - return "", errors.New("method GetGitOpsRepoName not implemented") -} - -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.Logger.Errorw("fetching error", "err", err) - return err - } - valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(appStoreAppVersion.Name, installAppVersionRequest.ValuesOverrideYaml) - if err != nil { - impl.Logger.Errorw("error in building requirements config for helm app", "err", err) - return err - } - valuesGitConfig, err := impl.appStoreDeploymentCommonService.GetGitCommitConfig(installAppVersionRequest, valuesString, appStoreBean.VALUES_YAML_FILE) - if err != nil { - impl.Logger.Errorw("error in getting git config for helm app", "err", err) - return err - } - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) - if err != nil { - impl.Logger.Errorw("error in committing config to git for helm app", "err", err) - return err - } - return nil -} - func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ctx context.Context, installedAppId int, appStoreApplicationVersionId int, valuesOverrideYaml string, installAppVersionHistoryId int) error { - installedApp, err := impl.installedAppRepository.GetInstalledApp(installedAppId) if err != nil { impl.Logger.Errorw("error in getting in installedApp", "installedAppId", installedAppId, "err", err) @@ -295,8 +253,8 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct return err } var IsOCIRepo bool - var registryCredential *client.RegistryCredential - var chartRepository *client.ChartRepository + var registryCredential *gRPC.RegistryCredential + var chartRepository *gRPC.ChartRepository dockerRegistryId := appStoreApplicationVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs, err := impl.OCIRegistryConfigRepository.FindByDockerRegistryId(dockerRegistryId) @@ -312,7 +270,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct } } IsOCIRepo = true - registryCredential = &client.RegistryCredential{ + registryCredential = &gRPC.RegistryCredential{ RegistryUrl: appStoreApplicationVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreApplicationVersion.AppStore.DockerArtifactStore.Username, Password: appStoreApplicationVersion.AppStore.DockerArtifactStore.Password, @@ -324,7 +282,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &client.ChartRepository{ + chartRepository = &gRPC.ChartRepository{ Name: appStoreApplicationVersion.AppStore.ChartRepo.Name, Url: appStoreApplicationVersion.AppStore.ChartRepo.Url, Username: appStoreApplicationVersion.AppStore.ChartRepo.UserName, @@ -332,10 +290,10 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct } } - updateReleaseRequest := &client.UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &client.InstallReleaseRequest{ + updateReleaseRequest := &bean2.UpdateApplicationWithChartInfoRequestDto{ + InstallReleaseRequest: &gRPC.InstallReleaseRequest{ ValuesYaml: valuesOverrideYaml, - ReleaseIdentifier: &client.ReleaseIdentifier{ + ReleaseIdentifier: &gRPC.ReleaseIdentifier{ ReleaseNamespace: installedApp.Environment.Namespace, ReleaseName: installedApp.App.AppName, }, @@ -346,7 +304,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct IsOCIRepo: IsOCIRepo, InstallAppVersionHistoryId: int32(installAppVersionHistoryId), }, - SourceAppType: client.SOURCE_HELM_APP, + SourceAppType: bean2.SOURCE_HELM_APP, } res, err := impl.helmAppService.UpdateApplicationWithChartInfo(ctx, installedApp.Environment.ClusterId, updateReleaseRequest) if err != nil { @@ -358,16 +316,21 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct } return nil } + +func (impl *AppStoreDeploymentHelmServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { + return "", errors.New("method GetGitOpsRepoName not implemented") +} + func (impl *AppStoreDeploymentHelmServiceImpl) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { - return nil + return errors.New("this is not implemented") } func (impl *AppStoreDeploymentHelmServiceImpl) SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error { - return nil + return errors.New("this is not implemented") } func (impl *AppStoreDeploymentHelmServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { - return nil + return errors.New("this is not implemented") } // TODO: Need to refactor this,refer below reason @@ -376,3 +339,23 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateInstalledAppAndPipelineStat func (impl *AppStoreDeploymentHelmServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { return errors.New("this is not implemented") } + +func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { + return errors.New("this is not implemented") +} + +func (impl *AppStoreDeploymentHelmServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { + return false, errors.New("this is not implemented") +} + +func (impl *AppStoreDeploymentHelmServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { + return nil, errors.New("this is not implemented") +} + +func (impl *AppStoreDeploymentHelmServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { + return nil, errors.New("this is not implemented") +} + +func (impl *AppStoreDeploymentHelmServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { + return nil, errors.New("this is not implemented") +} diff --git a/pkg/appStore/deployment/tool/bean/bean.go b/pkg/appStore/deployment/tool/bean/bean.go new file mode 100644 index 0000000000..9820820779 --- /dev/null +++ b/pkg/appStore/deployment/tool/bean/bean.go @@ -0,0 +1,17 @@ +package bean + +import ( + "github.com/devtron-labs/devtron/internal/util" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" +) + +type AppStoreManifestResponse struct { + ChartResponse *util.ChartCreateResponse + ValuesConfig *util.ChartConfig + RequirementsConfig *util.ChartConfig +} + +type AppStoreGitOpsResponse struct { + ChartGitAttribute *commonBean.ChartGitAttribute + GitHash string +} diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index 865b7fa171..a015279dec 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -9,8 +9,8 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository/app" diff --git a/pkg/clusterTerminalAccess/UserTerminalAccessService.go b/pkg/clusterTerminalAccess/UserTerminalAccessService.go index d19162d251..fc14c5db61 100644 --- a/pkg/clusterTerminalAccess/UserTerminalAccessService.go +++ b/pkg/clusterTerminalAccess/UserTerminalAccessService.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/caarlos0/env/v6" k8s2 "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository" utils1 "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess/clusterTerminalUtils" diff --git a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go index 18369cccf3..09b0cf01d8 100644 --- a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go +++ b/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go @@ -9,11 +9,9 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote/bean" dirCopy "github.com/otiai10/copy" "go.uber.org/zap" - "k8s.io/helm/pkg/proto/hapi/chart" "os" "path/filepath" "regexp" - "sigs.k8s.io/yaml" "time" ) @@ -23,12 +21,14 @@ type GitOpsRemoteOperationService interface { PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error - CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, - chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) GitPull(clonedDir string, repoUrl string, appStoreName string) error CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) + CommitRequirementsAndValues(appStoreName, repoUrl string, requirementsConfig *util.ChartConfig, + valuesConfig *util.ChartConfig) (gitHash string, err error) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) GetRepoUrlByRepoName(repoName string) (string, error) + PushChartToGitOpsRepoForHelmApp(PushChartToGitRequest *bean.PushChartToGitRequestDTO, + requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, string, error) } type GitOpsRemoteOperationServiceImpl struct { @@ -43,6 +43,7 @@ func NewGitOpsRemoteOperationServiceImpl(logger *zap.SugaredLogger, gitFactory * chartTemplateService util.ChartTemplateService) *GitOpsRemoteOperationServiceImpl { return &GitOpsRemoteOperationServiceImpl{ logger: logger, + gitFactory: gitFactory, gitOpsConfigReadService: gitOpsConfigReadService, chartTemplateService: chartTemplateService, } @@ -179,47 +180,6 @@ func (impl *GitOpsRemoteOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoNa return nil } -func (impl *GitOpsRemoteOperationServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, - chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) { - chartMetaData.ApiVersion = "v2" // ensure always v2 - dir := impl.chartTemplateService.GetDir() - chartDir := filepath.Join(util.ChartWorkingDirPath, dir) - impl.logger.Debugw("chart dir ", "chart", chartMetaData.Name, "dir", chartDir) - err := os.MkdirAll(chartDir, os.ModePerm) //hack for concurrency handling - if err != nil { - impl.logger.Errorw("err in creating dir", "dir", chartDir, "err", err) - return "", nil, err - } - defer impl.chartTemplateService.CleanDir(chartDir) - err = dirCopy.Copy(refChartLocation, chartDir) - - if err != nil { - impl.logger.Errorw("error in copying chart for app", "app", chartMetaData.Name, "error", err) - return "", nil, err - } - archivePath, valuesYaml, err := impl.chartTemplateService.PackageChart(chartDir, chartMetaData) - if err != nil { - impl.logger.Errorw("error in creating archive", "err", err) - return "", nil, err - } - - chartGitAttr, err := impl.createAndPushToGitChartProxy(chartMetaData.Name, chartDir, envName, chartProxyReq) - if err != nil { - impl.logger.Errorw("error in pushing chart to git ", "path", archivePath, "err", err) - return "", nil, err - } - if valuesYaml == "" { - valuesYaml = "{}" - } else { - valuesYamlByte, err := yaml.YAMLToJSON([]byte(valuesYaml)) - if err != nil { - return "", nil, err - } - valuesYaml = string(valuesYamlByte) - } - return valuesYaml, chartGitAttr, nil -} - func (impl *GitOpsRemoteOperationServiceImpl) createAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, chartProxyReq *bean.ChartProxyReqDto) (chartGitAttribute *commonBean.ChartGitAttribute, err error) { //baseTemplateName replace whitespace @@ -306,7 +266,10 @@ func (impl *GitOpsRemoteOperationServiceImpl) createAndPushToGitChartProxy(appSt } func (impl *GitOpsRemoteOperationServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error { - err := impl.gitFactory.GitService.Pull(clonedDir) //TODO check for local repo exists before clone + //TODO refactoring: remove invalid param appStoreName + //TODO check for local repo exists before clone + //TODO verify remote has repoUrl; or delete and clone + err := impl.gitFactory.GitService.Pull(clonedDir) if err != nil { impl.logger.Errorw("error in pulling git", "clonedDir", clonedDir, "err", err) _, err := impl.gitFactory.GitService.Clone(repoUrl, appStoreName) @@ -373,3 +336,96 @@ func (impl *GitOpsRemoteOperationServiceImpl) GetRepoUrlByRepoName(repoName stri } return repoUrl, nil } + +// TODO refactoring: Make a common method for both PushChartToGitRepo and PushChartToGitOpsRepoForHelmApp +// PushChartToGitOpsRepoForHelmApp pushes built chart to GitOps repo (Specific implementation for Helm Apps) +func (impl *GitOpsRemoteOperationServiceImpl) PushChartToGitOpsRepoForHelmApp(PushChartToGitRequest *bean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, string, error) { + space := regexp.MustCompile(`\s+`) + appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") + chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) + clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) + if _, err := os.Stat(clonedDir); os.IsNotExist(err) { + clonedDir, err = impl.gitFactory.GitService.Clone(PushChartToGitRequest.RepoURL, chartDir) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) + return nil, "", err + } + } else { + err = impl.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) + if err != nil { + return nil, "", err + } + } + acdAppName := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, PushChartToGitRequest.EnvName) + dir := filepath.Join(clonedDir, acdAppName) + err := os.MkdirAll(dir, os.ModePerm) + if err != nil { + impl.logger.Errorw("error in making dir", "err", err) + return nil, "", err + } + err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, "", err + } + err = impl.chartTemplateService.AddConfigFileToChart(requirementsConfig, dir, clonedDir) + if err != nil { + impl.logger.Errorw("error in adding requirements.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) + return nil, "", err + } + err = impl.chartTemplateService.AddConfigFileToChart(valuesConfig, dir, clonedDir) + if err != nil { + impl.logger.Errorw("error in adding values.yaml to chart", "err", err, "appName", PushChartToGitRequest.AppName) + return nil, "", err + } + userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) + commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + impl.logger.Warn("re-trying, taking pull and then push again") + err = impl.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) + return nil, "", err + } + err = dirCopy.Copy(PushChartToGitRequest.TempChartRefDir, dir) + if err != nil { + impl.logger.Errorw("error copying dir", "err", err) + return nil, "", err + } + commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + return nil, "", err + } + } + impl.logger.Debugw("template committed", "url", PushChartToGitRequest.RepoURL, "commit", commit) + defer impl.chartTemplateService.CleanDir(clonedDir) + return &commonBean.ChartGitAttribute{RepoUrl: PushChartToGitRequest.RepoURL, ChartLocation: acdAppName}, commit, err +} + +func (impl *GitOpsRemoteOperationServiceImpl) CommitRequirementsAndValues(appStoreName, repoUrl string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (gitHash string, err error) { + clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName + _, _, err = impl.CommitValues(requirementsConfig) + if err != nil { + impl.logger.Errorw("error in committing dependency config to git", "err", err) + return gitHash, err + } + err = impl.GitPull(clonedDir, repoUrl, appStoreName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err) + return gitHash, err + } + + gitHash, _, err = impl.CommitValues(valuesConfig) + if err != nil { + impl.logger.Errorw("error in committing values config to git", "err", err) + return gitHash, err + } + err = impl.GitPull(clonedDir, repoUrl, appStoreName) + if err != nil { + impl.logger.Errorw("error in git pull", "err", err) + return gitHash, err + } + return gitHash, nil +} diff --git a/pkg/deployment/gitOps/remote/bean/bean.go b/pkg/deployment/gitOps/remote/bean/bean.go index 361b0ec78c..7ac1fb0a15 100644 --- a/pkg/deployment/gitOps/remote/bean/bean.go +++ b/pkg/deployment/gitOps/remote/bean/bean.go @@ -5,3 +5,12 @@ type ChartProxyReqDto struct { AppName string `json:"appName,omitempty"` UserId int32 `json:"-"` } + +type PushChartToGitRequestDTO struct { + AppName string + EnvName string + ChartAppStoreName string + RepoURL string + TempChartRefDir string + UserId int32 +} diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index b35924856a..ba601ff6f6 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -4,7 +4,9 @@ import ( "context" "fmt" "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/bean" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/internal/sql/repository" appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" @@ -46,14 +48,14 @@ const ( Manifest RequestDataMode = 2 ) -var ChartRepository = &client.ChartRepository{ +var ChartRepository = &gRPC.ChartRepository{ Name: "repo", Url: "http://localhost:8080/", Username: "admin", Password: "password", } -var ReleaseIdentifier = &client.ReleaseIdentifier{ +var ReleaseIdentifier = &gRPC.ReleaseIdentifier{ ReleaseNamespace: "devtron-demo", ReleaseName: "release-name", } @@ -79,7 +81,7 @@ type DeploymentTemplateServiceImpl struct { chartRepository chartRepoRepository.ChartRepository chartTemplateServiceImpl util.ChartTemplateService K8sUtil *k8s.K8sUtil - helmAppClient client.HelmAppClient + helmAppClient gRPC.HelmAppClient propertiesConfigService pipeline.PropertiesConfigService deploymentTemplateHistoryService history.DeploymentTemplateHistoryService environmentRepository repository3.EnvironmentRepository @@ -95,7 +97,7 @@ func NewDeploymentTemplateServiceImpl(Logger *zap.SugaredLogger, chartService ch helmAppService client.HelmAppService, chartRepository chartRepoRepository.ChartRepository, chartTemplateServiceImpl util.ChartTemplateService, - helmAppClient client.HelmAppClient, + helmAppClient gRPC.HelmAppClient, K8sUtil *k8s.K8sUtil, propertiesConfigService pipeline.PropertiesConfigService, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, @@ -340,18 +342,18 @@ func (impl DeploymentTemplateServiceImpl) GenerateManifest(ctx context.Context, impl.Logger.Errorw("exception caught in getting k8sServerVersion", "err", err) return nil, err } - installReleaseRequest := &client.InstallReleaseRequest{ + installReleaseRequest := &gRPC.InstallReleaseRequest{ ChartName: template, ChartVersion: version, ValuesYaml: valuesYaml, K8SVersion: k8sServerVersion.String(), ChartRepository: ChartRepository, ReleaseIdentifier: ReleaseIdentifier, - ChartContent: &client.ChartContent{ + ChartContent: &gRPC.ChartContent{ Content: chartBytes, }, } - config, err := impl.helmAppService.GetClusterConf(client.DEFAULT_CLUSTER_ID) + config, err := impl.helmAppService.GetClusterConf(bean.DEFAULT_CLUSTER_ID) if err != nil { impl.Logger.Errorw("error in fetching cluster detail", "clusterId", 1, "err", err) return nil, err diff --git a/pkg/generateManifest/DeployementTemplateService_test.go b/pkg/generateManifest/DeployementTemplateService_test.go index 3552db8fce..f90fa58a70 100644 --- a/pkg/generateManifest/DeployementTemplateService_test.go +++ b/pkg/generateManifest/DeployementTemplateService_test.go @@ -6,7 +6,7 @@ import ( client2 "github.com/devtron-labs/authenticator/client" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/gRPC" mocks4 "github.com/devtron-labs/devtron/api/helm-app/mocks" "github.com/devtron-labs/devtron/internal/sql/repository" mocks3 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" diff --git a/pkg/k8s/K8sCommonService.go b/pkg/k8s/K8sCommonService.go index 6ff2385e6a..96a27ca3eb 100644 --- a/pkg/k8s/K8sCommonService.go +++ b/pkg/k8s/K8sCommonService.go @@ -7,7 +7,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/service" util2 "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/cluster" bean3 "github.com/devtron-labs/devtron/pkg/k8s/application/bean" @@ -163,7 +163,7 @@ func (impl *K8sCommonServiceImpl) FilterK8sResources(ctx context.Context, resour req := ResourceRequestBean{ AppId: appId, ClusterId: appDetail.ClusterId, - AppIdentifier: &client.AppIdentifier{ + AppIdentifier: &service.AppIdentifier{ ClusterId: appDetail.ClusterId, }, K8sRequest: &k8s.K8sRequestBean{ diff --git a/pkg/k8s/application/k8sApplicationService.go b/pkg/k8s/application/k8sApplicationService.go index 6186b99526..0f18a1f7a7 100644 --- a/pkg/k8s/application/k8sApplicationService.go +++ b/pkg/k8s/application/k8sApplicationService.go @@ -5,6 +5,8 @@ import ( "encoding/json" "errors" "fmt" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "io" "net/http" "strconv" @@ -16,7 +18,6 @@ import ( k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" yamlUtil "github.com/devtron-labs/common-lib/utils/yaml" "github.com/devtron-labs/devtron/api/connector" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/cluster" @@ -388,7 +389,7 @@ func (impl *K8sApplicationServiceImpl) ValidateResourceRequest(ctx context.Conte return impl.validateContainerNameIfReqd(valid, request, app), nil } -func (impl *K8sApplicationServiceImpl) validateContainerNameIfReqd(valid bool, request *k8s2.K8sRequestBean, app *client.AppDetail) bool { +func (impl *K8sApplicationServiceImpl) validateContainerNameIfReqd(valid bool, request *k8s2.K8sRequestBean, app *gRPC.AppDetail) bool { if !valid { requestContainerName := request.PodLogsRequest.ContainerName podName := request.ResourceIdentifier.Name diff --git a/pkg/k8s/application/k8sApplicationService_test.go b/pkg/k8s/application/k8sApplicationService_test.go index 12ce800ddf..6b68e2cbae 100644 --- a/pkg/k8s/application/k8sApplicationService_test.go +++ b/pkg/k8s/application/k8sApplicationService_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" k8s2 "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/k8s" diff --git a/pkg/k8s/application/mocks/K8sApplicationService.go b/pkg/k8s/application/mocks/K8sApplicationService.go index 638606d14d..434f01ffd4 100644 --- a/pkg/k8s/application/mocks/K8sApplicationService.go +++ b/pkg/k8s/application/mocks/K8sApplicationService.go @@ -5,7 +5,7 @@ package mocks import ( "github.com/devtron-labs/common-lib/utils/k8s" bean "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" k8s2 "github.com/devtron-labs/devtron/pkg/k8s" bean2 "github.com/devtron-labs/devtron/pkg/k8s/application/bean" diff --git a/pkg/k8s/bean.go b/pkg/k8s/bean.go index 23229ceaf4..d684e9076d 100644 --- a/pkg/k8s/bean.go +++ b/pkg/k8s/bean.go @@ -2,7 +2,7 @@ package k8s import ( "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/k8s/application/bean" ) diff --git a/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go b/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go index 10ab04489d..859a5f258b 100644 --- a/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go +++ b/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go @@ -3,7 +3,7 @@ package kubernetesResourceAuditLogs import ( "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/common-lib/utils/k8s" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/internal/sql/repository/app" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" diff --git a/pkg/module/ModuleCronService.go b/pkg/module/ModuleCronService.go index 09e55347b2..03bca9094a 100644 --- a/pkg/module/ModuleCronService.go +++ b/pkg/module/ModuleCronService.go @@ -21,7 +21,8 @@ import ( "context" "encoding/json" "fmt" - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleDataStore "github.com/devtron-labs/devtron/pkg/module/store" serverBean "github.com/devtron-labs/devtron/pkg/server/bean" @@ -158,7 +159,7 @@ func (impl *ModuleCronServiceImpl) handleModuleStatus(moduleNameInput string) { } -func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDetail *client.AppDetail) error { +func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDetail *gRPC.AppDetail) error { impl.logger.Infow("updating module resources status", "moduleId", moduleId) if appDetail == nil || appDetail.ResourceTreeResponse == nil { return nil @@ -233,7 +234,7 @@ func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDe return nil } -func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (*client.ResourceTreeFilter, error) { +func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (*gRPC.ResourceTreeFilter, error) { moduleMetaData, err := impl.moduleServiceHelper.GetModuleMetadata(moduleName) if err != nil { impl.logger.Errorw("Error in getting module metadata", "moduleName", moduleName, "err", err) @@ -254,13 +255,13 @@ func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (* return nil, err } - var resourceTreeFilter *client.ResourceTreeFilter + var resourceTreeFilter *gRPC.ResourceTreeFilter // handle global filter globalFilter := resourceFilterIfaceValue.GlobalFilter if globalFilter != nil { - resourceTreeFilter = &client.ResourceTreeFilter{ - GlobalFilter: &client.ResourceIdentifier{ + resourceTreeFilter = &gRPC.ResourceTreeFilter{ + GlobalFilter: &gRPC.ResourceIdentifier{ Labels: globalFilter.Labels, }, } @@ -268,21 +269,21 @@ func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (* } // otherwise handle gvk level - var resourceFilters []*client.ResourceFilter + var resourceFilters []*gRPC.ResourceFilter for _, gvkLevelFilters := range resourceFilterIfaceValue.GvkLevelFilters { gvk := gvkLevelFilters.Gvk - resourceFilters = append(resourceFilters, &client.ResourceFilter{ - Gvk: &client.Gvk{ + resourceFilters = append(resourceFilters, &gRPC.ResourceFilter{ + Gvk: &gRPC.Gvk{ Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind, }, - ResourceIdentifier: &client.ResourceIdentifier{ + ResourceIdentifier: &gRPC.ResourceIdentifier{ Labels: gvkLevelFilters.ResourceIdentifier.Labels, }, }) } - resourceTreeFilter = &client.ResourceTreeFilter{ + resourceTreeFilter = &gRPC.ResourceTreeFilter{ ResourceFilters: resourceFilters, } return resourceTreeFilter, nil diff --git a/pkg/module/ModuleService.go b/pkg/module/ModuleService.go index 9e677148fc..297888cfea 100644 --- a/pkg/module/ModuleService.go +++ b/pkg/module/ModuleService.go @@ -21,7 +21,8 @@ import ( "context" "errors" "github.com/caarlos0/env/v6" - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/internal/sql/repository/security" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleUtil "github.com/devtron-labs/devtron/pkg/module/util" @@ -395,7 +396,7 @@ func (impl ModuleServiceImpl) HandleModuleAction(userId int32, moduleName string // HELM_OPERATION Starts devtronHelmAppIdentifier := impl.helmAppService.GetDevtronHelmAppIdentifier() - chartRepository := &client.ChartRepository{ + chartRepository := &gRPC.ChartRepository{ Name: impl.serverEnvConfig.DevtronHelmRepoName, Url: impl.serverEnvConfig.DevtronHelmRepoUrl, } diff --git a/pkg/pipeline/AppDeploymentTypeChangeManager.go b/pkg/pipeline/AppDeploymentTypeChangeManager.go index 5f340c755f..fcc6e1563c 100644 --- a/pkg/pipeline/AppDeploymentTypeChangeManager.go +++ b/pkg/pipeline/AppDeploymentTypeChangeManager.go @@ -21,7 +21,7 @@ import ( "context" "fmt" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/service" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" @@ -62,7 +62,7 @@ type AppDeploymentTypeChangeManagerImpl struct { workflowDagExecutor WorkflowDagExecutor appService app2.AppService appStatusRepository appStatus.AppStatusRepository - helmAppService client.HelmAppService + helmAppService service.HelmAppService application application2.ServiceClient appArtifactManager AppArtifactManager @@ -77,7 +77,7 @@ func NewAppDeploymentTypeChangeManagerImpl( workflowDagExecutor WorkflowDagExecutor, appService app2.AppService, appStatusRepository appStatus.AppStatusRepository, - helmAppService client.HelmAppService, + helmAppService service.HelmAppService, application application2.ServiceClient, appArtifactManager AppArtifactManager, cdPipelineConfigService CdPipelineConfigService, @@ -628,7 +628,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) FetchDeletedApp(ctx context.Cont deploymentAppName := fmt.Sprintf("%s-%s", pipeline.App.AppName, pipeline.Environment.Name) var err error if pipeline.DeploymentAppType == string(bean.ArgoCd) { - appIdentifier := &client.AppIdentifier{ + appIdentifier := &service.AppIdentifier{ ClusterId: pipeline.Environment.ClusterId, ReleaseName: pipeline.DeploymentAppName, Namespace: pipeline.Environment.Namespace, @@ -720,7 +720,7 @@ func (impl *AppDeploymentTypeChangeManagerImpl) deleteHelmApp(ctx context.Contex } // create app identifier - appIdentifier := &client.AppIdentifier{ + appIdentifier := &service.AppIdentifier{ ClusterId: pipeline.Environment.ClusterId, ReleaseName: pipeline.DeploymentAppName, Namespace: pipeline.Environment.Namespace, diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 7737a2668d..df7c42b4ed 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -22,6 +22,7 @@ import ( "context" "errors" "fmt" + client "github.com/devtron-labs/devtron/api/helm-app/service" "os" "path/filepath" "strconv" @@ -34,7 +35,6 @@ import ( pubub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" client2 "github.com/devtron-labs/devtron/client/events" diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 98e9c35512..3cef327795 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -24,8 +24,8 @@ import ( "fmt" application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" bean2 "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app" models2 "github.com/devtron-labs/devtron/api/helm-app/models" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/models" diff --git a/pkg/pipeline/DockerRegistryConfig.go b/pkg/pipeline/DockerRegistryConfig.go index 2bc7a6c941..e327c62d3c 100644 --- a/pkg/pipeline/DockerRegistryConfig.go +++ b/pkg/pipeline/DockerRegistryConfig.go @@ -20,7 +20,8 @@ package pipeline import ( "context" "fmt" - client "github.com/devtron-labs/devtron/api/helm-app" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" @@ -863,7 +864,7 @@ func (impl DockerRegistryConfigImpl) ValidateRegistryCredentials(bean *types.Doc bean.RegistryType == repository.REGISTRYTYPE_OTHER { return true } - request := &client.RegistryCredential{ + request := &bean2.RegistryCredential{ RegistryUrl: bean.RegistryURL, Username: bean.Username, Password: bean.Password, diff --git a/pkg/pipeline/DockerRegistryConfig_test.go b/pkg/pipeline/DockerRegistryConfig_test.go index 139b810cb9..2a5e20e107 100644 --- a/pkg/pipeline/DockerRegistryConfig_test.go +++ b/pkg/pipeline/DockerRegistryConfig_test.go @@ -3,7 +3,7 @@ package pipeline import ( "context" "fmt" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/mocks" repository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/dockerRegistry" diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index f6fb6387ba..ffd655377c 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -22,6 +22,9 @@ import ( "encoding/json" errors3 "errors" "fmt" + bean5 "github.com/devtron-labs/devtron/api/helm-app/bean" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" @@ -39,7 +42,6 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" util5 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/common-lib/utils/k8s/health" - client2 "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" @@ -180,17 +182,18 @@ type WorkflowDagExecutorImpl struct { configMapRepository chartConfig.ConfigMapRepository configMapHistoryRepository repository3.ConfigMapHistoryRepository helmAppService client2.HelmAppService - helmAppClient client2.HelmAppClient - environmentConfigRepository chartConfig.EnvConfigOverrideRepository - mergeUtil *util.MergeUtil - acdClient application2.ServiceClient - argoClientWrapperService argocdServer.ArgoClientWrapperService - customTagService CustomTagService - ACDConfig *argocdServer.ACDConfig - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService - chartRefService chartRef.ChartRefService - gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + //TODO fix me next + helmAppClient gRPC.HelmAppClient //TODO refactoring: use helm app service instead + environmentConfigRepository chartConfig.EnvConfigOverrideRepository + mergeUtil *util.MergeUtil + acdClient application2.ServiceClient + argoClientWrapperService argocdServer.ArgoClientWrapperService + customTagService CustomTagService + ACDConfig *argocdServer.ACDConfig + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService + gitOpsConfigReadService config.GitOpsConfigReadService + gitOpsRemoteOperationService remote.GitOpsRemoteOperationService } const kedaAutoscaling = "kedaAutoscaling" @@ -281,7 +284,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi configMapRepository chartConfig.ConfigMapRepository, configMapHistoryRepository repository3.ConfigMapHistoryRepository, helmAppService client2.HelmAppService, - helmAppClient client2.HelmAppClient, + helmAppClient gRPC.HelmAppClient, environmentConfigRepository chartConfig.EnvConfigOverrideRepository, mergeUtil *util.MergeUtil, acdClient application2.ServiceClient, @@ -462,7 +465,7 @@ func (impl *WorkflowDagExecutorImpl) UpdateWorkflowRunnerStatusForDeployment(app if err != nil { impl.logger.Errorw("error in getting helm app release status", "appIdentifier", appIdentifier, "err", err) // Handle release not found errors - if skipReleaseNotFound && util.GetGRPCErrorDetailedMessage(err) != client2.ErrReleaseNotFound { + if skipReleaseNotFound && util.GetGRPCErrorDetailedMessage(err) != bean5.ErrReleaseNotFound { //skip this error and continue for next workflow status impl.logger.Warnw("found error, skipping helm apps status update for this trigger", "appIdentifier", appIdentifier, "err", err) return false @@ -3515,7 +3518,7 @@ func (impl *WorkflowDagExecutorImpl) createHelmAppForCdPipeline(overrideRequest releaseName := pipeline.DeploymentAppName cluster := envOverride.Environment.Cluster bearerToken := cluster.Config[util5.BearerToken] - clusterConfig := &client2.ClusterConfig{ + clusterConfig := &gRPC.ClusterConfig{ ClusterName: cluster.ClusterName, Token: bearerToken, ApiServerUrl: cluster.ServerUrl, @@ -3526,18 +3529,18 @@ func (impl *WorkflowDagExecutorImpl) createHelmAppForCdPipeline(overrideRequest clusterConfig.CertData = cluster.Config[util5.CertData] clusterConfig.CaData = cluster.Config[util5.CertificateAuthorityData] } - releaseIdentifier := &client2.ReleaseIdentifier{ + releaseIdentifier := &gRPC.ReleaseIdentifier{ ReleaseName: releaseName, ReleaseNamespace: envOverride.Namespace, ClusterConfig: clusterConfig, } if pipeline.DeploymentAppCreated { - req := &client2.UpgradeReleaseRequest{ + req := &gRPC.UpgradeReleaseRequest{ ReleaseIdentifier: releaseIdentifier, ValuesYaml: mergeAndSave, - HistoryMax: impl.helmAppService.GetRevisionHistoryMaxValue(client2.SOURCE_DEVTRON_APP), - ChartContent: &client2.ChartContent{Content: referenceChartByte}, + HistoryMax: impl.helmAppService.GetRevisionHistoryMaxValue(bean5.SOURCE_DEVTRON_APP), + ChartContent: &gRPC.ChartContent{Content: referenceChartByte}, } if impl.appService.IsDevtronAsyncInstallModeEnabled(bean2.Helm) { req.RunInCtx = true @@ -4245,11 +4248,11 @@ func (impl *WorkflowDagExecutorImpl) updatePipeline(pipeline *pipelineConfig.Pip } // helmInstallReleaseWithCustomChart performs helm install with custom chart -func (impl *WorkflowDagExecutorImpl) helmInstallReleaseWithCustomChart(ctx context.Context, releaseIdentifier *client2.ReleaseIdentifier, referenceChartByte []byte, valuesYaml string) (*client2.HelmInstallCustomResponse, error) { +func (impl *WorkflowDagExecutorImpl) helmInstallReleaseWithCustomChart(ctx context.Context, releaseIdentifier *gRPC.ReleaseIdentifier, referenceChartByte []byte, valuesYaml string) (*gRPC.HelmInstallCustomResponse, error) { - helmInstallRequest := client2.HelmInstallCustomRequest{ + helmInstallRequest := gRPC.HelmInstallCustomRequest{ ValuesYaml: valuesYaml, - ChartContent: &client2.ChartContent{Content: referenceChartByte}, + ChartContent: &gRPC.ChartContent{Content: referenceChartByte}, ReleaseIdentifier: releaseIdentifier, } if impl.appService.IsDevtronAsyncInstallModeEnabled(bean2.Helm) { diff --git a/pkg/server/ServerCacheService.go b/pkg/server/ServerCacheService.go index 8ac2b33449..27d67a85de 100644 --- a/pkg/server/ServerCacheService.go +++ b/pkg/server/ServerCacheService.go @@ -19,7 +19,7 @@ package server import ( "context" - client "github.com/devtron-labs/devtron/api/helm-app" + client "github.com/devtron-labs/devtron/api/helm-app/service" serverBean "github.com/devtron-labs/devtron/pkg/server/bean" serverEnvConfig "github.com/devtron-labs/devtron/pkg/server/config" serverDataStore "github.com/devtron-labs/devtron/pkg/server/store" diff --git a/pkg/server/ServerService.go b/pkg/server/ServerService.go index 731bce828a..75a19c99f6 100644 --- a/pkg/server/ServerService.go +++ b/pkg/server/ServerService.go @@ -20,7 +20,8 @@ package server import ( "context" "errors" - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleUtil "github.com/devtron-labs/devtron/pkg/module/util" serverBean "github.com/devtron-labs/devtron/pkg/server/bean" @@ -130,7 +131,7 @@ func (impl ServerServiceImpl) HandleServerAction(userId int32, serverActionReque // HELM_OPERATION Starts devtronHelmAppIdentifier := impl.helmAppService.GetDevtronHelmAppIdentifier() - chartRepository := &client.ChartRepository{ + chartRepository := &gRPC.ChartRepository{ Name: impl.serverEnvConfig.DevtronHelmRepoName, Url: impl.serverEnvConfig.DevtronHelmRepoUrl, } diff --git a/pkg/webhook/helm/WebhookHelmService.go b/pkg/webhook/helm/WebhookHelmService.go index f52f453cb0..1058bd728c 100644 --- a/pkg/webhook/helm/WebhookHelmService.go +++ b/pkg/webhook/helm/WebhookHelmService.go @@ -20,7 +20,9 @@ package webhookHelm import ( "context" "fmt" - client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/bean" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/chartRepo" @@ -119,15 +121,15 @@ func (impl WebhookHelmServiceImpl) CreateOrUpdateHelmApplication(ctx context.Con // STEP-6 install/update release chart := request.Chart chartRepo := request.Chart.Repo - installReleaseRequest := &client.InstallReleaseRequest{ - ReleaseIdentifier: &client.ReleaseIdentifier{ + installReleaseRequest := &bean2.InstallReleaseRequest{ + ReleaseIdentifier: &bean2.ReleaseIdentifier{ ReleaseName: appIdentifier.ReleaseName, ReleaseNamespace: appIdentifier.Namespace, }, ChartName: chart.ChartName, ChartVersion: chart.ChartVersion, ValuesYaml: request.ValuesOverrideYaml, - ChartRepository: &client.ChartRepository{ + ChartRepository: &bean2.ChartRepository{ Name: chartRepo.Name, Url: chartRepo.Identifier.Url, Username: chartRepo.Identifier.Username, @@ -135,9 +137,9 @@ func (impl WebhookHelmServiceImpl) CreateOrUpdateHelmApplication(ctx context.Con }, } if isInstalled { - updateReleaseRequest := &client.UpdateApplicationWithChartInfoRequestDto{ + updateReleaseRequest := &bean.UpdateApplicationWithChartInfoRequestDto{ InstallReleaseRequest: installReleaseRequest, - SourceAppType: client.SOURCE_HELM_APP, + SourceAppType: bean.SOURCE_HELM_APP, } res, err := impl.helmAppService.UpdateApplicationWithChartInfo(ctx, clusterId, updateReleaseRequest) if err != nil { diff --git a/wire_gen.go b/wire_gen.go index 990b564a79..4a2b07d4ff 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -28,6 +28,8 @@ import ( "github.com/devtron-labs/devtron/api/deployment" externalLink2 "github.com/devtron-labs/devtron/api/externalLink" client3 "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/service" application3 "github.com/devtron-labs/devtron/api/k8s/application" capacity2 "github.com/devtron-labs/devtron/api/k8s/capacity" module2 "github.com/devtron-labs/devtron/api/module" @@ -78,14 +80,13 @@ import ( repository15 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode" repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - service2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + service3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - service3 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" + service4 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" - "github.com/devtron-labs/devtron/pkg/appStore/values/service" + service2 "github.com/devtron-labs/devtron/pkg/appStore/values/service" appWorkflow2 "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authentication" @@ -233,11 +234,11 @@ func InitializeApp() (*App, error) { userRepositoryImpl := repository4.NewUserRepositoryImpl(db, sugaredLogger) roleGroupRepositoryImpl := repository4.NewRoleGroupRepositoryImpl(db, sugaredLogger) clusterServiceImplExtended := cluster2.NewClusterServiceImplExtended(clusterRepositoryImpl, environmentRepositoryImpl, grafanaClientImpl, sugaredLogger, installedAppRepositoryImpl, k8sUtil, serviceClientImpl, k8sInformerFactoryImpl, gitOpsConfigRepositoryImpl, userAuthRepositoryImpl, userRepositoryImpl, roleGroupRepositoryImpl) - helmClientConfig, err := client3.GetConfig() + helmClientConfig, err := gRPC.GetConfig() if err != nil { return nil, err } - helmAppClientImpl := client3.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) + helmAppClientImpl := gRPC.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) pumpImpl := connector.NewPumpImpl(sugaredLogger) teamRepositoryImpl := team.NewTeamRepositoryImpl(db) appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) @@ -268,11 +269,11 @@ func InitializeApp() (*App, error) { userServiceImpl := user.NewUserServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, sessionManager, userCommonServiceImpl, userAuditServiceImpl) userAuthServiceImpl := user.NewUserAuthServiceImpl(userAuthRepositoryImpl, sessionManager, loginService, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userServiceImpl) environmentServiceImpl := cluster2.NewEnvironmentServiceImpl(environmentRepositoryImpl, clusterServiceImplExtended, sugaredLogger, k8sUtil, k8sInformerFactoryImpl, userAuthServiceImpl, attributesRepositoryImpl) - helmReleaseConfig, err := client3.GetHelmReleaseConfig() + helmReleaseConfig, err := service.GetHelmReleaseConfig() if err != nil { return nil, err } - helmAppServiceImpl := client3.NewHelmAppServiceImpl(sugaredLogger, clusterServiceImplExtended, helmAppClientImpl, pumpImpl, enforcerUtilHelmImpl, serverDataStoreServerDataStore, serverEnvConfigServerEnvConfig, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, appRepositoryImpl, clusterRepositoryImpl, k8sUtil, helmReleaseConfig) + helmAppServiceImpl := service.NewHelmAppServiceImpl(sugaredLogger, clusterServiceImplExtended, helmAppClientImpl, pumpImpl, enforcerUtilHelmImpl, serverDataStoreServerDataStore, serverEnvConfigServerEnvConfig, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, appRepositoryImpl, clusterRepositoryImpl, k8sUtil, helmReleaseConfig) serverCacheServiceImpl := server.NewServerCacheServiceImpl(sugaredLogger, serverEnvConfigServerEnvConfig, serverDataStoreServerDataStore, helmAppServiceImpl) moduleEnvConfig, err := module.ParseModuleEnvConfig() if err != nil { @@ -530,22 +531,21 @@ func InitializeApp() (*App, error) { pipelineStatusTimelineRestHandlerImpl := restHandler.NewPipelineStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) pipelineConfigRouterImpl := router.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, appWorkflowRestHandlerImpl, webhookDataRestHandlerImpl, pipelineHistoryRestHandlerImpl, pipelineStatusTimelineRestHandlerImpl) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) - appStoreValuesServiceImpl := service.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) + appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) chartGroupDeploymentRepositoryImpl := repository15.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) acdAuthConfig, err := util3.GetACDAuthConfig() if err != nil { return nil, err } - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOpsRemoteOperationServiceImpl) - serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOpsRemoteOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) + serviceDeploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) k8sResourceHistoryRepositoryImpl := repository16.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -555,7 +555,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + installedAppServiceImpl, err := service3.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, userServiceImpl, acdAuthConfig, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sUtil, pipelineStatusTimelineServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsRemoteOperationServiceImpl, appStoreDeploymentArgoCdServiceImpl) if err != nil { return nil, err } @@ -642,7 +642,7 @@ func InitializeApp() (*App, error) { installedAppRestHandlerImpl := appStore.NewInstalledAppRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, installedAppServiceImpl, validate, clusterServiceImplExtended, applicationServiceClientImpl, appStoreDeploymentServiceImpl, helmAppClientImpl, argoUserServiceImpl, cdApplicationStatusUpdateHandlerImpl, installedAppRepositoryImpl, appCrudOperationServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) - appStoreServiceImpl := service3.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) + appStoreServiceImpl := service4.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) appStoreRestHandlerImpl := appStoreDiscover.NewAppStoreRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreServiceImpl, enforcerImpl) appStoreDiscoverRouterImpl := appStoreDiscover.NewAppStoreDiscoverRouterImpl(appStoreRestHandlerImpl) chartProviderRestHandlerImpl := chartProvider2.NewChartProviderRestHandlerImpl(sugaredLogger, userServiceImpl, validate, chartProviderServiceImpl, enforcerImpl) @@ -733,7 +733,7 @@ func InitializeApp() (*App, error) { appRouterImpl := router.NewAppRouterImpl(sugaredLogger, appRestHandlerImpl) coreAppRestHandlerImpl := restHandler.NewCoreAppRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, appCrudOperationServiceImpl, pipelineBuilderImpl, gitRegistryConfigImpl, chartServiceImpl, configMapServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, gitProviderRepositoryImpl, appWorkflowRepositoryImpl, environmentRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, teamServiceImpl, argoUserServiceImpl, pipelineStageServiceImpl, ciPipelineRepositoryImpl) coreAppRouterImpl := router.NewCoreAppRouterImpl(coreAppRestHandlerImpl) - helmAppRestHandlerImpl := client3.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImplExtended, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) + helmAppRestHandlerImpl := client3.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImplExtended, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client3.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sApplicationRestHandlerImpl := application3.NewK8sApplicationRestHandlerImpl(sugaredLogger, k8sApplicationServiceImpl, pumpImpl, terminalSessionHandlerImpl, enforcerImpl, enforcerUtilHelmImpl, enforcerUtilImpl, helmAppServiceImpl, userServiceImpl, k8sCommonServiceImpl, validate) k8sApplicationRouterImpl := application3.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) @@ -743,7 +743,7 @@ func InitializeApp() (*App, error) { deploymentConfigRouterImpl := deployment.NewDeploymentRouterImpl(deploymentConfigRestHandlerImpl) dashboardTelemetryRestHandlerImpl := dashboardEvent.NewDashboardTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImplExtended) dashboardTelemetryRouterImpl := dashboardEvent.NewDashboardTelemetryRouterImpl(dashboardTelemetryRestHandlerImpl) - commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppRestHandlerImpl, argoUserServiceImpl) + commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, argoUserServiceImpl) commonDeploymentRouterImpl := appStoreDeployment.NewCommonDeploymentRouterImpl(commonDeploymentRestHandlerImpl) externalLinkMonitoringToolRepositoryImpl := externalLink.NewExternalLinkMonitoringToolRepositoryImpl(db) externalLinkIdentifierMappingRepositoryImpl := externalLink.NewExternalLinkIdentifierMappingRepositoryImpl(db) From 869c6e4869afebc3603142ea3c11b8a7716747a6 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 11:42:05 +0530 Subject: [PATCH 30/83] minor cleanup --- pkg/chart/ChartService.go | 4 ---- pkg/pipeline/PropertiesConfig.go | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index 58222ac4e2..efecaa0ac6 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -145,10 +145,6 @@ func (impl ChartServiceImpl) PatchEnvOverrides(values json.RawMessage, oldChartT return PatchWinterSoldierConfig(values, newChartType) } -type AppMetricsEnabled struct { - AppMetrics bool `json:"app-metrics"` -} - func (impl ChartServiceImpl) Create(templateRequest TemplateRequest, ctx context.Context) (*TemplateRequest, error) { err := impl.chartRefService.CheckChartExists(templateRequest.ChartRefId) if err != nil { diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index c1620cdd09..40adfb2f7b 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -28,7 +28,6 @@ import ( repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" "time" - chartService "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -331,18 +330,6 @@ func (impl PropertiesConfigServiceImpl) UpdateEnvironmentProperties(appId int, p return propertiesRequest, err } -func (impl PropertiesConfigServiceImpl) buildAppMetricsJson() ([]byte, error) { - appMetricsEnabled := chartService.AppMetricsEnabled{ - AppMetrics: true, - } - appMetricsJson, err := json.Marshal(appMetricsEnabled) - if err != nil { - impl.logger.Error(err) - return nil, err - } - return appMetricsJson, nil -} - func (impl PropertiesConfigServiceImpl) CreateIfRequired(chart *chartRepoRepository.Chart, environmentId int, userId int32, manualReviewed bool, chartStatus models.ChartStatus, isOverride, isAppMetricsEnabled bool, namespace string, IsBasicViewLocked bool, CurrentViewEditor models.ChartsViewEditorType, tx *pg.Tx) (*chartConfig.EnvConfigOverride, bool, error) { env, err := impl.environmentRepository.FindById(environmentId) if err != nil { From d1116982f4c941d72a8fb59fdbf396b37b4d273b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 12:17:14 +0530 Subject: [PATCH 31/83] renamed remote package to git --- cmd/external-app/wire_gen.go | 4 ++-- internal/util/GitCliUtil.go | 2 +- pkg/app/AppService.go | 6 +++--- pkg/app/ManifestPushService.go | 6 +++--- .../common/AppStoreDeploymentCommonService.go | 6 +++--- .../fullMode/AppStoreDeploymentFullModeService.go | 6 +++--- .../deployment/service/AppStoreDeploymentService.go | 6 +++--- .../service/AppStoreDeploymentService_test.go | 4 ++-- .../deployment/service/InstalledAppService.go | 8 ++++---- .../tool/AppStoreDeploymentArgoCdService.go | 6 +++--- .../deployment/tool/AppStoreDeploymentHelmService.go | 6 +++--- .../{remote => git}/GitOpsRemoteOperationService.go | 4 ++-- pkg/deployment/gitOps/{remote => git}/bean/bean.go | 0 pkg/deployment/gitOps/wire_gitOps.go | 6 +++--- pkg/pipeline/DeploymentPipelineConfigService.go | 8 ++++---- pkg/pipeline/PipelineStageServiceIT_test.go | 12 ++++++------ pkg/pipeline/WorkflowDagExecutor.go | 8 ++++---- .../deployment-chart_1-0-0/app-values.yaml | 4 ++-- .../deployment-chart_1-1-0/app-values.yaml | 4 ++-- .../deployment-chart_4-18-0/app-values.yaml | 4 ++-- .../deployment-chart_4-19-0/app-values.yaml | 4 ++-- .../reference-chart_3-12-0/app-values.yaml | 4 ++-- .../reference-chart_3-13-0/app-values.yaml | 4 ++-- .../reference-chart_4-11-0/app-values.yaml | 4 ++-- .../reference-chart_4-12-0/app-values.yaml | 4 ++-- .../reference-chart_4-13-0/app-values.yaml | 4 ++-- .../reference-chart_4-14-0/app-values.yaml | 4 ++-- .../reference-chart_4-15-0/app-values.yaml | 4 ++-- .../reference-chart_4-16-0/app-values.yaml | 4 ++-- .../reference-chart_4-17-0/app-values.yaml | 4 ++-- .../reference-chart_4-18-0/app-values.yaml | 4 ++-- .../reference-chart_5-0-0/app-values.yaml | 4 ++-- .../statefulset-chart_4-18-0/app-values.yaml | 4 ++-- .../statefulset-chart_4-19-0/app-values.yaml | 4 ++-- .../statefulset-chart_5-0-0/app-values.yaml | 4 ++-- scripts/sql/49_plugin_integration.up.sql | 6 +++--- util/RequestUtil.go | 2 +- wire_gen.go | 10 +++++----- 38 files changed, 94 insertions(+), 94 deletions(-) rename pkg/deployment/gitOps/{remote => git}/GitOpsRemoteOperationService.go (99%) rename pkg/deployment/gitOps/{remote => git}/bean/bean.go (100%) diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 0ba02067c4..b41b6fff67 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -69,7 +69,7 @@ import ( "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/genericNotes" repository6 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" @@ -244,7 +244,7 @@ func InitializeApp() (*App, error) { return nil, err } gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) - gitOpsRemoteOperationServiceImpl := remote.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + gitOpsRemoteOperationServiceImpl := git.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) diff --git a/internal/util/GitCliUtil.go b/internal/util/GitCliUtil.go index 3996751b6b..54d9281a2a 100644 --- a/internal/util/GitCliUtil.go +++ b/internal/util/GitCliUtil.go @@ -137,7 +137,7 @@ func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string, } response, errMsg, err = impl.Fetch(rootDir, username, password) if err == nil && errMsg == "" { - impl.logger.Warn("git fetch completed, pulling master branch data from remote origin") + impl.logger.Warn("git fetch completed, pulling master branch data from git origin") response, errMsg, err = impl.ListBranch(rootDir, username, password) if err != nil { impl.logger.Errorw("error on git pull", "response", response, "errMsg", errMsg, "err", err) diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 94e74f31c4..173f503083 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -23,7 +23,7 @@ import ( "fmt" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" bean3 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" "io/ioutil" @@ -122,7 +122,7 @@ type AppServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } type AppService interface { @@ -177,7 +177,7 @@ func NewAppService( scopedVariableManager variables.ScopedVariableCMCSManager, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppServiceImpl { appServiceImpl := &AppServiceImpl{ environmentConfigRepository: environmentConfigRepository, mergeUtil: mergeUtil, diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 937023f39b..3e407dd935 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -9,7 +9,7 @@ import ( "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "go.opentelemetry.io/otel" "go.uber.org/zap" @@ -31,7 +31,7 @@ type GitOpsManifestPushServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, @@ -39,7 +39,7 @@ func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *GitOpsManifestPushServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, pipelineStatusTimelineService: pipelineStatusTimelineService, diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 08460991af..7cbcb99d44 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -29,7 +29,7 @@ import ( repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/go-pg/pg" "github.com/google/go-github/github" "github.com/microsoft/azure-devops-go-api/azuredevops" @@ -69,7 +69,7 @@ type AppStoreDeploymentCommonServiceImpl struct { chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewAppStoreDeploymentCommonServiceImpl( @@ -80,7 +80,7 @@ func NewAppStoreDeploymentCommonServiceImpl( chartTemplateService util.ChartTemplateService, gitFactory *util.GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentCommonServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index cfacb79ca7..42f241b82a 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -26,7 +26,7 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "time" "github.com/devtron-labs/devtron/client/argocdServer" @@ -73,7 +73,7 @@ type AppStoreDeploymentFullModeServiceImpl struct { installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository ACDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, @@ -86,7 +86,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, ACDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentFullModeServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ logger: logger, acdClient: acdClient, diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index c3221a7651..cc40832ae0 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -44,7 +44,7 @@ import ( cluster2 "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -108,7 +108,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, @@ -120,7 +120,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentServiceImpl { appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ logger: logger, diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go index 79a6fd1f9f..01aabf55f1 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go @@ -43,7 +43,7 @@ func TestAppStoreDeploymentService(t *testing.T) { InstalledAppId: 0, InstalledAppVersionId: 0, AppStoreVersion: 6304, - ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, remote access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", + ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, git access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", Readme: "", UserId: 6, ReferenceValueId: 6304, @@ -93,7 +93,7 @@ func TestAppStoreDeploymentService(t *testing.T) { InstalledAppId: 0, InstalledAppVersionId: 0, AppStoreVersion: 6304, - ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, remote access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", + ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, git access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", Readme: "", UserId: 6, ReferenceValueId: 6304, diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index bfdd857d1f..4f33452280 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -22,7 +22,7 @@ import ( "context" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" /* #nosec */ "crypto/sha1" @@ -124,7 +124,7 @@ type InstalledAppServiceImpl struct { k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, @@ -137,7 +137,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, pubsubClient *pubsub.PubSubClientServiceImpl, chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository, envService cluster2.EnvironmentService, - aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, + aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, @@ -147,7 +147,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, acdConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) (*InstalledAppServiceImpl, error) { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go index 41c2b080af..f5973894d5 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "net/http" "strings" "time" @@ -71,7 +71,7 @@ type AppStoreDeploymentArgoCdServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, @@ -83,7 +83,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentArgoCdServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentArgoCdServiceImpl { return &AppStoreDeploymentArgoCdServiceImpl{ Logger: logger, appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index e1384780ed..9b42f2bd9f 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -5,7 +5,7 @@ import ( "errors" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "time" client "github.com/devtron-labs/devtron/api/helm-app" @@ -39,7 +39,7 @@ type AppStoreDeploymentHelmServiceImpl struct { installedAppRepository repository.InstalledAppRepository appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, @@ -47,7 +47,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *AppStoreDeploymentHelmServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, diff --git a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go b/pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go similarity index 99% rename from pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go rename to pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go index 2501b94be4..375031ad60 100644 --- a/pkg/deployment/gitOps/remote/GitOpsRemoteOperationService.go +++ b/pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go @@ -1,4 +1,4 @@ -package remote +package git import ( "fmt" @@ -6,7 +6,7 @@ import ( "github.com/devtron-labs/devtron/internal/util" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" dirCopy "github.com/otiai10/copy" "go.uber.org/zap" "k8s.io/helm/pkg/proto/hapi/chart" diff --git a/pkg/deployment/gitOps/remote/bean/bean.go b/pkg/deployment/gitOps/git/bean/bean.go similarity index 100% rename from pkg/deployment/gitOps/remote/bean/bean.go rename to pkg/deployment/gitOps/git/bean/bean.go diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go index 7d5378d238..92a256a4e4 100644 --- a/pkg/deployment/gitOps/wire_gitOps.go +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -2,7 +2,7 @@ package gitOps import ( "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/google/wire" ) @@ -10,6 +10,6 @@ var GitOpsWireSet = wire.NewSet( config.NewGitOpsConfigReadServiceImpl, wire.Bind(new(config.GitOpsConfigReadService), new(*config.GitOpsConfigReadServiceImpl)), - remote.NewGitOpsRemoteOperationServiceImpl, - wire.Bind(new(remote.GitOpsRemoteOperationService), new(*remote.GitOpsRemoteOperationServiceImpl)), + git.NewGitOpsRemoteOperationServiceImpl, + wire.Bind(new(git.GitOpsRemoteOperationService), new(*git.GitOpsRemoteOperationServiceImpl)), ) diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 98e9c35512..273145d716 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -43,7 +43,7 @@ import ( repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -148,7 +148,7 @@ type CdPipelineConfigServiceImpl struct { argoClientWrapperService argocdServer.ArgoClientWrapperService deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -169,7 +169,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor argoClientWrapperService argocdServer.ArgoClientWrapperService, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *CdPipelineConfigServiceImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -1593,7 +1593,7 @@ func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, ch err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error while register git repo in argo", "err", err) - emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "remote repository is empty"} + emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "git repository is empty"} if strings.Contains(err.Error(), emptyRepoErrorMessage[0]) || strings.Contains(err.Error(), emptyRepoErrorMessage[1]) { // - found empty repository, create some file in repository err := impl.gitOpsRemoteOperationService.CreateReadmeInGitRepo(gitOpsRepoName, userId) diff --git a/pkg/pipeline/PipelineStageServiceIT_test.go b/pkg/pipeline/PipelineStageServiceIT_test.go index f6e8d803c5..532d509eb7 100644 --- a/pkg/pipeline/PipelineStageServiceIT_test.go +++ b/pkg/pipeline/PipelineStageServiceIT_test.go @@ -26,9 +26,9 @@ import ( "time" ) -const CiPipelineStageCreateReqJson = `{"appId":1,"appWorkflowId":0,"action":0,"ciPipeline":{"active":true,"ciMaterial":[{"gitMaterialId":1,"id":0,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"dockerArgs":{},"externalCiConfig":{},"id":0,"isExternal":false,"isManual":false,"name":"ci-1-xyze","linkedCount":0,"scanEnabled":false,"preBuildStage":{"id":0,"steps":[{"id":1,"index":1,"name":"Task 1","description":"chbsdkhbc","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"echo \"ifudsbvnv\"","conditionDetails":[],"inputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"jnsdvbdvbsd","defaultValue":"","variableType":"GLOBAL","refVariableStepIndex":0,"refVariableName":"WORKING_DIRECTORY","refVariableStage":""}],"outputVariables":null,"commandArgsMap":[{"command":"echo","args":["\"HOSTNAME\"","\"PORT\""]}],"portMap":[{"portOnLocal":8080,"portOnContainer":9090}],"mountCodeToContainer":true,"mountDirectoryFromHost":true,"mountCodeToContainerPath":"/sourcecode","mountPathMap":[{"filePathOnDisk":"./test","filePathOnContainer":"./test_container"}],"containerImagePath":"python:latest","isMountCustomScript":true,"storeScriptAt":"./directory/script"},"outputDirectoryPath":["./test1"]},{"id":2,"index":2,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","stepType":"REF_PLUGIN","directoryPath":"","pluginRefStepDetail":{"id":0,"pluginId":1,"conditionDetails":[{"id":0,"conditionOnVariable":"RelativePathToScript","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"svfsv"},{"id":0,"conditionOnVariable":"PrometheusApiKey","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"dfbeavafsv"}],"inputVariables":[{"id":1,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"allowEmptyValue":false,"defaultValue":"/./script.js","variableType":"NEW","variableStepIndexInPlugin":1,"value":"dethdt","refVariableName":"","refVariableStage":""},{"id":2,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"ghmfnbd","refVariableName":"","refVariableStage":""},{"id":3,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"afegs","refVariableName":"","refVariableStage":""},{"id":4,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"aef","refVariableName":"","refVariableStage":""},{"id":5,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"allowEmptyValue":false,"defaultValue":"LOG","variableType":"NEW","variableStepIndexInPlugin":1,"value":"fdgn","refVariableName":"","refVariableStage":""}]}},{"id":3,"index":3,"name":"Task 3","description":"sfdbvf","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \n#set -v ## uncomment this to debug the script \n","conditionDetails":[{"id":0,"conditionOnVariable":"Hello","conditionOperator":"==","conditionType":"PASS","conditionalValue":"aedfrwgwr"},{"id":0,"conditionOnVariable":"Hello","conditionOperator":"!=","conditionType":"PASS","conditionalValue":"tegegr"}],"inputVariables":[],"outputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"dsuihvsuvhbdv","defaultValue":"","variableType":"NEW","refVariableStepIndex":0,"refVariableName":""}],"commandArgsMap":[{"command":"","args":[]}],"portMap":[],"mountCodeToContainer":false,"mountDirectoryFromHost":false},"outputDirectoryPath":["./test2"]}]},"postBuildStage":{},"dockerConfigOverride":{}}}` -const CiPipelineStageUpdateReqJson = `{"appId":1,"appWorkflowId":3,"action":1,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":3,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unov","id":3,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":3,"preBuildStage":{"id":5,"type":"PRE_CI","steps":[{"id":9,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":1,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":44,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":45,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":46,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":47,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":48,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":10,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":null,"storeScriptAt":null,"mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[],"mountCodeToContainerPath":null,"mountPathMap":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":8,"name":"Task 1","description":"","index":2,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Hello from inside pre-build stage\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"postBuildStage":{},"isDockerConfigOverridden":false,"dockerConfigOverride":{}}}` -const CiPipelineStageDeleteReqJson = `{"appId":1,"appWorkflowId":8,"action":2,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":8,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unjn","id":8,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":8,"preBuildStage":{"id":7,"type":"PRE_CI","steps":[{"id":11,"name":"Task 1","description":"","index":1,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Prakash\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":12,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":2,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":49,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":50,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":51,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":52,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":53,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":13,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"","storeScriptAt":"","mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[]},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"isDockerConfigOverridden":false,"dockerConfigOverride":{},"postBuildStage":{}}}` +const CiPipelineStageCreateReqJson = `{"appId":1,"appWorkflowId":0,"action":0,"ciPipeline":{"active":true,"ciMaterial":[{"gitMaterialId":1,"id":0,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"dockerArgs":{},"externalCiConfig":{},"id":0,"isExternal":false,"isManual":false,"name":"ci-1-xyze","linkedCount":0,"scanEnabled":false,"preBuildStage":{"id":0,"steps":[{"id":1,"index":1,"name":"Task 1","description":"chbsdkhbc","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"echo \"ifudsbvnv\"","conditionDetails":[],"inputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"jnsdvbdvbsd","defaultValue":"","variableType":"GLOBAL","refVariableStepIndex":0,"refVariableName":"WORKING_DIRECTORY","refVariableStage":""}],"outputVariables":null,"commandArgsMap":[{"command":"echo","args":["\"HOSTNAME\"","\"PORT\""]}],"portMap":[{"portOnLocal":8080,"portOnContainer":9090}],"mountCodeToContainer":true,"mountDirectoryFromHost":true,"mountCodeToContainerPath":"/sourcecode","mountPathMap":[{"filePathOnDisk":"./test","filePathOnContainer":"./test_container"}],"containerImagePath":"python:latest","isMountCustomScript":true,"storeScriptAt":"./directory/script"},"outputDirectoryPath":["./test1"]},{"id":2,"index":2,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","stepType":"REF_PLUGIN","directoryPath":"","pluginRefStepDetail":{"id":0,"pluginId":1,"conditionDetails":[{"id":0,"conditionOnVariable":"RelativePathToScript","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"svfsv"},{"id":0,"conditionOnVariable":"PrometheusApiKey","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"dfbeavafsv"}],"inputVariables":[{"id":1,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"allowEmptyValue":false,"defaultValue":"/./script.js","variableType":"NEW","variableStepIndexInPlugin":1,"value":"dethdt","refVariableName":"","refVariableStage":""},{"id":2,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"ghmfnbd","refVariableName":"","refVariableStage":""},{"id":3,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"afegs","refVariableName":"","refVariableStage":""},{"id":4,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"aef","refVariableName":"","refVariableStage":""},{"id":5,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"allowEmptyValue":false,"defaultValue":"LOG","variableType":"NEW","variableStepIndexInPlugin":1,"value":"fdgn","refVariableName":"","refVariableStage":""}]}},{"id":3,"index":3,"name":"Task 3","description":"sfdbvf","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \n#set -v ## uncomment this to debug the script \n","conditionDetails":[{"id":0,"conditionOnVariable":"Hello","conditionOperator":"==","conditionType":"PASS","conditionalValue":"aedfrwgwr"},{"id":0,"conditionOnVariable":"Hello","conditionOperator":"!=","conditionType":"PASS","conditionalValue":"tegegr"}],"inputVariables":[],"outputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"dsuihvsuvhbdv","defaultValue":"","variableType":"NEW","refVariableStepIndex":0,"refVariableName":""}],"commandArgsMap":[{"command":"","args":[]}],"portMap":[],"mountCodeToContainer":false,"mountDirectoryFromHost":false},"outputDirectoryPath":["./test2"]}]},"postBuildStage":{},"dockerConfigOverride":{}}}` +const CiPipelineStageUpdateReqJson = `{"appId":1,"appWorkflowId":3,"action":1,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":3,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unov","id":3,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":3,"preBuildStage":{"id":5,"type":"PRE_CI","steps":[{"id":9,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":1,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":44,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":45,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":46,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":47,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":48,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":10,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":null,"storeScriptAt":null,"mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[],"mountCodeToContainerPath":null,"mountPathMap":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":8,"name":"Task 1","description":"","index":2,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Hello from inside pre-build stage\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"postBuildStage":{},"isDockerConfigOverridden":false,"dockerConfigOverride":{}}}` +const CiPipelineStageDeleteReqJson = `{"appId":1,"appWorkflowId":8,"action":2,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":8,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unjn","id":8,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":8,"preBuildStage":{"id":7,"type":"PRE_CI","steps":[{"id":11,"name":"Task 1","description":"","index":1,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Prakash\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":12,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":2,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":49,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":50,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":51,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":52,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":53,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":13,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"","storeScriptAt":"","mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[]},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"isDockerConfigOverridden":false,"dockerConfigOverride":{},"postBuildStage":{}}}` const ScopedVariablePayload = `{"variables":[{"definition":{"varName":"KAFKA","dataType":"primitive","varType":"public","description":"Enter any notes for additional details","shortDescription":"Some description for variables"},"attributeValue":[{"variableValue":{"value":"Global"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"NewVariable","dataType":"primitive","varType":"private","description":"New Notes","shortDescription":"New Descriotion"},"attributeValue":[{"variableValue":{"value":"gg"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"test-var-1","dataType":"primitive","varType":"public","description":"","shortDescription":""},"attributeValue":[{"variableValue":{"value":"test1"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"test-var-2","dataType":"primitive","varType":"public","description":"","shortDescription":""},"attributeValue":[{"variableValue":{"value":"test2"},"attributeType":"Global","attributeParams":null}]}]}` var ciPipelineId int @@ -143,7 +143,7 @@ var pipelineStageReq = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "remote write endpoint of prometheus account", + Description: "git write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", @@ -323,7 +323,7 @@ var pipelineStageReqUnresolved = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "remote write endpoint of prometheus account", + Description: "git write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", @@ -504,7 +504,7 @@ var pipelineStageReqResolved = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "remote write endpoint of prometheus account", + Description: "git write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index a5c8783ce1..9b1aead59a 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -23,7 +23,7 @@ import ( errors3 "errors" "fmt" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" bean5 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" @@ -193,7 +193,7 @@ type WorkflowDagExecutorImpl struct { deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOpsRemoteOperationService } const kedaAutoscaling = "kedaAutoscaling" @@ -268,7 +268,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi user user.UserService, groupRepository repository.DeploymentGroupRepository, envRepository repository2.EnvironmentRepository, - enforcerUtil rbac.EnforcerUtil, eventFactory client.EventFactory, + enforcerUtil rbac.EnforcerUtil, eventFactory client.EventFactory, eventClient client.EventClient, cvePolicyRepository security.CvePolicyRepository, scanResultRepository security.ImageScanResultRepository, appWorkflowRepository appWorkflow.AppWorkflowRepository, @@ -314,7 +314,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService remote.GitOpsRemoteOperationService) *WorkflowDagExecutorImpl { + gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml index 0dce06c558..a5bebb5c56 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml @@ -308,5 +308,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml index bbebc7acab..664b444031 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml @@ -449,5 +449,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml index ff562cb579..96bfcafec7 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml @@ -508,5 +508,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml index ce73c2af57..88daa46112 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml @@ -514,5 +514,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml index 85f565f40a..f524a92391 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml @@ -233,5 +233,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml index 85f565f40a..f524a92391 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml @@ -233,5 +233,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml index a9eca0e03a..2771ba40ed 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml @@ -276,5 +276,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml index a3022d7bb8..e9fdbd4d14 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml @@ -289,5 +289,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml index a3022d7bb8..e9fdbd4d14 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml @@ -289,5 +289,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml index d73eee8c80..87327b1d51 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml @@ -293,5 +293,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml index ff44a3679a..92eb571112 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml @@ -306,5 +306,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml index fe18509efd..a93d0fb412 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml @@ -308,5 +308,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml index a621f49a79..80ccc7cb32 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml @@ -360,5 +360,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml index f4c8cef663..8079c1e887 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml @@ -424,5 +424,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml index 0555153aee..fd93c244d8 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml @@ -423,5 +423,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml index f1d80a0ea3..1a8063c237 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml @@ -393,5 +393,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml index ad27515a44..f7edfb417e 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml @@ -397,5 +397,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml index 1b1912aa68..4a057c104f 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml @@ -384,5 +384,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.remote" -# - "bar.remote" +# - "foo.git" +# - "bar.git" diff --git a/scripts/sql/49_plugin_integration.up.sql b/scripts/sql/49_plugin_integration.up.sql index e52a73ccbe..2fd34bc5b9 100644 --- a/scripts/sql/49_plugin_integration.up.sql +++ b/scripts/sql/49_plugin_integration.up.sql @@ -307,11 +307,11 @@ then export GOCACHE=/usr/local/go/cache export PATH=$PATH:/usr/local/go/bin go install go.k6.io/xk6/cmd/xk6@latest - xk6 build --with github.com/grafana/xk6-output-prometheus-remote + xk6 build --with github.com/grafana/xk6-output-prometheus-git K6_PROMETHEUS_USER=$PrometheusUsername \ K6_PROMETHEUS_PASSWORD=$PrometheusApiKey \ K6_PROMETHEUS_REMOTE_URL=$PrometheusRemoteWriteEndpoint \ - ./k6 run $PathToScript -o output-prometheus-remote + ./k6 run $PathToScript -o output-prometheus-git elif [ $OutputType == "LOG" ] then docker pull grafana/k6 @@ -343,7 +343,7 @@ INSERT INTO "public"."plugin_step_variable" ("id", "plugin_step_id", "name", "fo ('1', '1','RelativePathToScript','STRING','checkout path + script path along with script name','t','f','INPUT','NEW','/./script.js','1','f','now()', '1', 'now()', '1'), ('2', '1','PrometheusUsername','STRING','username of prometheus account','t','t','INPUT','NEW',null, '1' ,'f','now()', '1', 'now()', '1'), ('3', '1','PrometheusApiKey','STRING','api key of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), -('4', '1','PrometheusRemoteWriteEndpoint','STRING','remote write endpoint of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), +('4', '1','PrometheusRemoteWriteEndpoint','STRING','git write endpoint of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), ('5', '1','OutputType','STRING','output type - LOG or PROMETHEUS','t','f','INPUT','NEW','LOG', '1','f','now()', '1', 'now()', '1'), ('6', '2','SonarqubeProjectKey','STRING','project key of grafana sonarqube account','t','t','INPUT','NEW',null, '1', 'f','now()', '1', 'now()', '1'), ('7', '2','SonarqubeApiKey','STRING','api key of sonarqube account','t','t','INPUT','NEW',null, '1', 'f','now()', '1', 'now()', '1'), diff --git a/util/RequestUtil.go b/util/RequestUtil.go index 3eb349bc3d..eb0b251ec9 100644 --- a/util/RequestUtil.go +++ b/util/RequestUtil.go @@ -24,7 +24,7 @@ import ( const xForwardedForHeaderName = "X-Forwarded-For" // GetClientIP gets a requests IP address by reading off the forwarded-for -// header (for proxies) and falls back to use the remote address. +// header (for proxies) and falls back to use the git address. func GetClientIP(r *http.Request) string { xForwardedFor := r.Header.Get(xForwardedForHeaderName) if len(xForwardedFor) > 0 { diff --git a/wire_gen.go b/wire_gen.go index 00bc3d66ab..bcea4e49e5 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -105,7 +105,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/remote" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" repository11 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" @@ -118,7 +118,7 @@ import ( "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/genericNotes" repository12 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" - "github.com/devtron-labs/devtron/pkg/git" + git2 "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" k8s2 "github.com/devtron-labs/devtron/pkg/k8s" application2 "github.com/devtron-labs/devtron/pkg/k8s/application" @@ -377,7 +377,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - gitOpsRemoteOperationServiceImpl := remote.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + gitOpsRemoteOperationServiceImpl := git.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) validate, err := util.IntValidator() if err != nil { @@ -574,7 +574,7 @@ func InitializeApp() (*App, error) { clusterRestHandlerImpl := cluster3.NewClusterRestHandlerImpl(clusterServiceImplExtended, genericNoteServiceImpl, clusterDescriptionServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceExtendedImpl, argoUserServiceImpl, environmentServiceImpl, clusterRbacServiceImpl) clusterRouterImpl := cluster3.NewClusterRouterImpl(clusterRestHandlerImpl) gitWebhookRepositoryImpl := repository.NewGitWebhookRepositoryImpl(db) - gitWebhookServiceImpl := git.NewGitWebhookServiceImpl(sugaredLogger, ciHandlerImpl, gitWebhookRepositoryImpl) + gitWebhookServiceImpl := git2.NewGitWebhookServiceImpl(sugaredLogger, ciHandlerImpl, gitWebhookRepositoryImpl) gitWebhookRestHandlerImpl := restHandler.NewGitWebhookRestHandlerImpl(sugaredLogger, gitWebhookServiceImpl) webhookServiceImpl := pipeline.NewWebhookServiceImpl(ciArtifactRepositoryImpl, sugaredLogger, ciPipelineRepositoryImpl, appServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl, ciWorkflowRepositoryImpl, workflowDagExecutorImpl, ciHandlerImpl, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, customTagServiceImpl) ciEventConfig, err := pubsub.GetCiEventConfig() @@ -729,7 +729,7 @@ func InitializeApp() (*App, error) { } bulkUpdateRestHandlerImpl := restHandler.NewBulkUpdateRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, bulkUpdateServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, argoUserServiceImpl) bulkUpdateRouterImpl := router.NewBulkUpdateRouterImpl(bulkUpdateRestHandlerImpl) - webhookSecretValidatorImpl := git.NewWebhookSecretValidatorImpl(sugaredLogger) + webhookSecretValidatorImpl := git2.NewWebhookSecretValidatorImpl(sugaredLogger) webhookEventHandlerImpl := restHandler.NewWebhookEventHandlerImpl(sugaredLogger, gitHostConfigImpl, eventRESTClientImpl, webhookSecretValidatorImpl, webhookEventDataConfigImpl) webhookListenerRouterImpl := router.NewWebhookListenerRouterImpl(webhookEventHandlerImpl) appRestHandlerImpl := restHandler.NewAppRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) From fcf03ac6f920105a1372d86486917e34bc2c79b1 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 12:21:26 +0530 Subject: [PATCH 32/83] renamed gitOpsRemoteOpService If and impl --- cmd/external-app/wire_gen.go | 8 ++--- pkg/app/AppService.go | 4 +-- pkg/app/ManifestPushService.go | 4 +-- .../common/AppStoreDeploymentCommonService.go | 4 +-- .../AppStoreDeploymentFullModeService.go | 4 +-- .../service/AppStoreDeploymentService.go | 4 +-- .../deployment/service/InstalledAppService.go | 4 +-- .../tool/AppStoreDeploymentArgoCdService.go | 4 +-- .../tool/AppStoreDeploymentHelmService.go | 4 +-- ...ationService.go => GitOperationService.go} | 29 ++++++++++--------- pkg/deployment/gitOps/wire_gitOps.go | 4 +-- .../DeploymentPipelineConfigService.go | 4 +-- pkg/pipeline/WorkflowDagExecutor.go | 4 +-- wire_gen.go | 22 +++++++------- 14 files changed, 52 insertions(+), 51 deletions(-) rename pkg/deployment/gitOps/git/{GitOpsRemoteOperationService.go => GitOperationService.go} (90%) diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index b41b6fff67..1f768a004f 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -244,8 +244,8 @@ func InitializeApp() (*App, error) { return nil, err } gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) - gitOpsRemoteOperationServiceImpl := git.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + gitOperationServiceImpl := git.NewGitOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentCommonServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) @@ -276,7 +276,7 @@ func InitializeApp() (*App, error) { appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) chartGroupDeploymentRepositoryImpl := repository8.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOperationServiceImpl) installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) deploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() if err != nil { @@ -286,7 +286,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 173f503083..34c10331e1 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -122,7 +122,7 @@ type AppServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } type AppService interface { @@ -177,7 +177,7 @@ func NewAppService( scopedVariableManager variables.ScopedVariableCMCSManager, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppServiceImpl { appServiceImpl := &AppServiceImpl{ environmentConfigRepository: environmentConfigRepository, mergeUtil: mergeUtil, diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 3e407dd935..a3cc646729 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -31,7 +31,7 @@ type GitOpsManifestPushServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, @@ -39,7 +39,7 @@ func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *GitOpsManifestPushServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, pipelineStatusTimelineService: pipelineStatusTimelineService, diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 7cbcb99d44..759ed4bd7a 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -69,7 +69,7 @@ type AppStoreDeploymentCommonServiceImpl struct { chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewAppStoreDeploymentCommonServiceImpl( @@ -80,7 +80,7 @@ func NewAppStoreDeploymentCommonServiceImpl( chartTemplateService util.ChartTemplateService, gitFactory *util.GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentCommonServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index 42f241b82a..e0a3e066f3 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -73,7 +73,7 @@ type AppStoreDeploymentFullModeServiceImpl struct { installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository ACDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, @@ -86,7 +86,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, ACDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentFullModeServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ logger: logger, acdClient: acdClient, diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index cc40832ae0..39b2d05519 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -108,7 +108,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, @@ -120,7 +120,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentServiceImpl { appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ logger: logger, diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 4f33452280..0bac817246 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -124,7 +124,7 @@ type InstalledAppServiceImpl struct { k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, @@ -147,7 +147,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, acdConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) (*InstalledAppServiceImpl, error) { + gitOpsRemoteOperationService git.GitOperationService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go index f5973894d5..a19fa6c975 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go @@ -71,7 +71,7 @@ type AppStoreDeploymentArgoCdServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, @@ -83,7 +83,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentArgoCdServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentArgoCdServiceImpl { return &AppStoreDeploymentArgoCdServiceImpl{ Logger: logger, appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index 9b42f2bd9f..d8dbfc167a 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -39,7 +39,7 @@ type AppStoreDeploymentHelmServiceImpl struct { installedAppRepository repository.InstalledAppRepository appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, @@ -47,7 +47,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *AppStoreDeploymentHelmServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, diff --git a/pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go similarity index 90% rename from pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go rename to pkg/deployment/gitOps/git/GitOperationService.go index 375031ad60..e434666a51 100644 --- a/pkg/deployment/gitOps/git/GitOpsRemoteOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -17,7 +17,7 @@ import ( "time" ) -type GitOpsRemoteOperationService interface { +type GitOperationService interface { CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, @@ -31,25 +31,26 @@ type GitOpsRemoteOperationService interface { GetRepoUrlByRepoName(repoName string) (string, error) } -type GitOpsRemoteOperationServiceImpl struct { +type GitOperationServiceImpl struct { logger *zap.SugaredLogger gitFactory *util.GitFactory gitOpsConfigReadService config.GitOpsConfigReadService chartTemplateService util.ChartTemplateService } -func NewGitOpsRemoteOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *util.GitFactory, +func NewGitOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *util.GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, - chartTemplateService util.ChartTemplateService) *GitOpsRemoteOperationServiceImpl { - return &GitOpsRemoteOperationServiceImpl{ + chartTemplateService util.ChartTemplateService) *GitOperationServiceImpl { + return &GitOperationServiceImpl{ logger: logger, + gitFactory: gitFactory, gitOpsConfigReadService: gitOpsConfigReadService, chartTemplateService: chartTemplateService, } } -func (impl *GitOpsRemoteOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, +func (impl *GitOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, baseTemplateName, version string, userId int32) (chartGitAttribute *commonBean.ChartGitAttribute, err error) { //baseTemplateName replace whitespace space := regexp.MustCompile(`\s+`) @@ -80,7 +81,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRe return &commonBean.ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join(baseTemplateName, version)}, nil } -func (impl *GitOpsRemoteOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, +func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) { chartDir := fmt.Sprintf("%s-%s", gitOpsRepoName, impl.chartTemplateService.GetDir()) clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) @@ -159,7 +160,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, return nil } -func (impl *GitOpsRemoteOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error { +func (impl *GitOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string, userId int32) error { userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) gitOpsConfig, err := impl.gitOpsConfigReadService.GetGitOpsConfigActive() if err != nil { @@ -179,7 +180,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoNa return nil } -func (impl *GitOpsRemoteOperationServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, +func (impl *GitOperationServiceImpl) CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) { chartMetaData.ApiVersion = "v2" // ensure always v2 dir := impl.chartTemplateService.GetDir() @@ -220,7 +221,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) CreateChartProxy(chartMetaData *ch return valuesYaml, chartGitAttr, nil } -func (impl *GitOpsRemoteOperationServiceImpl) createAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, +func (impl *GitOperationServiceImpl) createAndPushToGitChartProxy(appStoreName, tmpChartLocation string, envName string, chartProxyReq *bean.ChartProxyReqDto) (chartGitAttribute *commonBean.ChartGitAttribute, err error) { //baseTemplateName replace whitespace space := regexp.MustCompile(`\s+`) @@ -305,7 +306,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) createAndPushToGitChartProxy(appSt return &commonBean.ChartGitAttribute{RepoUrl: repoUrl, ChartLocation: filepath.Join("", acdAppName)}, nil } -func (impl *GitOpsRemoteOperationServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error { +func (impl *GitOperationServiceImpl) GitPull(clonedDir string, repoUrl string, appStoreName string) error { err := impl.gitFactory.GitService.Pull(clonedDir) //TODO check for local repo exists before clone if err != nil { impl.logger.Errorw("error in pulling git", "clonedDir", clonedDir, "err", err) @@ -319,7 +320,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) GitPull(clonedDir string, repoUrl return nil } -func (impl *GitOpsRemoteOperationServiceImpl) CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) { +func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) { bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { impl.logger.Errorw("error in getting bitbucket metadata", "err", err) @@ -337,7 +338,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) CommitValues(chartGitAttr *util.Ch return commitHash, commitTime, nil } -func (impl *GitOpsRemoteOperationServiceImpl) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) { +func (impl *GitOperationServiceImpl) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) { //getting user name & emailId for commit author data userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) if dto != nil { @@ -354,7 +355,7 @@ func (impl *GitOpsRemoteOperationServiceImpl) CreateRepository(dto *bean2.GitOps return repoUrl, isNew, nil } -func (impl *GitOpsRemoteOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (string, error) { +func (impl *GitOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (string, error) { repoUrl := "" bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go index 92a256a4e4..a0b7daa517 100644 --- a/pkg/deployment/gitOps/wire_gitOps.go +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -10,6 +10,6 @@ var GitOpsWireSet = wire.NewSet( config.NewGitOpsConfigReadServiceImpl, wire.Bind(new(config.GitOpsConfigReadService), new(*config.GitOpsConfigReadServiceImpl)), - git.NewGitOpsRemoteOperationServiceImpl, - wire.Bind(new(git.GitOpsRemoteOperationService), new(*git.GitOpsRemoteOperationServiceImpl)), + git.NewGitOperationServiceImpl, + wire.Bind(new(git.GitOperationService), new(*git.GitOperationServiceImpl)), ) diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 273145d716..72a15b312c 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -148,7 +148,7 @@ type CdPipelineConfigServiceImpl struct { argoClientWrapperService argocdServer.ArgoClientWrapperService deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -169,7 +169,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor argoClientWrapperService argocdServer.ArgoClientWrapperService, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *CdPipelineConfigServiceImpl { + gitOpsRemoteOperationService git.GitOperationService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 9b1aead59a..653e63ee65 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -193,7 +193,7 @@ type WorkflowDagExecutorImpl struct { deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOpsRemoteOperationService + gitOpsRemoteOperationService git.GitOperationService } const kedaAutoscaling = "kedaAutoscaling" @@ -314,7 +314,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOpsRemoteOperationService) *WorkflowDagExecutorImpl { + gitOpsRemoteOperationService git.GitOperationService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, diff --git a/wire_gen.go b/wire_gen.go index bcea4e49e5..4a8ed0becf 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -377,8 +377,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - gitOpsRemoteOperationServiceImpl := git.NewGitOpsRemoteOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + gitOperationServiceImpl := git.NewGitOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) validate, err := util.IntValidator() if err != nil { return nil, err @@ -437,7 +437,7 @@ func InitializeApp() (*App, error) { pipelineStrategyHistoryRepositoryImpl := repository8.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) manifestPushConfigRepositoryImpl := repository9.NewManifestPushConfigRepository(sugaredLogger, db) - gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) genericNoteRepositoryImpl := repository12.NewGenericNoteRepositoryImpl(db) @@ -452,7 +452,7 @@ func InitializeApp() (*App, error) { repositoryServiceClientImpl := repository13.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, mergeUtil, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, mergeUtil, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) @@ -493,7 +493,7 @@ func InitializeApp() (*App, error) { return nil, err } devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) @@ -538,16 +538,16 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) - appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, chartTemplateServiceImpl, gitFactory, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + appStoreDeploymentFullModeServiceImpl := appStoreDeploymentFullMode.NewAppStoreDeploymentFullModeServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, argoClientWrapperServiceImpl, pubSubClientServiceImpl, installedAppVersionHistoryRepositoryImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOpsRemoteOperationServiceImpl) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, appStoreDeploymentCommonServiceImpl, ociRegistryConfigRepositoryImpl, gitOperationServiceImpl) + appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, appStoreDeploymentFullModeServiceImpl, applicationServiceClientImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl) serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) k8sResourceHistoryRepositoryImpl := repository16.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -557,7 +557,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOpsRemoteOperationServiceImpl) + installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) if err != nil { return nil, err } From 9cb4432da827765deaaa92aebe8d97ae79917b1b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 13:21:35 +0530 Subject: [PATCH 33/83] migrated usages of gitService to gitOperationService --- pkg/app/AppService.go | 8 ++-- pkg/app/ManifestPushService.go | 12 ++--- .../common/AppStoreDeploymentCommonService.go | 45 +++++++++---------- .../AppStoreDeploymentFullModeService.go | 10 ++--- .../service/AppStoreDeploymentService.go | 12 ++--- .../deployment/service/InstalledAppService.go | 8 ++-- .../tool/AppStoreDeploymentArgoCdService.go | 8 ++-- .../tool/AppStoreDeploymentHelmService.go | 8 ++-- .../gitOps/git/GitOperationService.go | 35 +++++++++++++++ .../DeploymentPipelineConfigService.go | 8 ++-- pkg/pipeline/WorkflowDagExecutor.go | 6 +-- 11 files changed, 96 insertions(+), 64 deletions(-) diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 34c10331e1..62a158d4af 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -122,7 +122,7 @@ type AppServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } type AppService interface { @@ -177,7 +177,7 @@ func NewAppService( scopedVariableManager variables.ScopedVariableCMCSManager, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *AppServiceImpl { + gitOperationService git.GitOperationService) *AppServiceImpl { appServiceImpl := &AppServiceImpl{ environmentConfigRepository: environmentConfigRepository, mergeUtil: mergeUtil, @@ -207,7 +207,7 @@ func NewAppService( acdConfig: acdConfig, chartRefService: chartRefService, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } return appServiceImpl } @@ -917,7 +917,7 @@ func (impl *AppServiceImpl) CreateGitopsRepo(app *app.App, userId int32) (gitops return "", nil, err } gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(app.AppName) - chartGitAttr, err = impl.gitOpsRemoteOperationService.CreateGitRepositoryForApp(gitOpsRepoName, chart.ReferenceTemplate, chart.ChartVersion, userId) + chartGitAttr, err = impl.gitOperationService.CreateGitRepositoryForApp(gitOpsRepoName, chart.ReferenceTemplate, chart.ChartVersion, userId) if err != nil { impl.logger.Errorw("error in pushing chart to git ", "gitOpsRepoName", gitOpsRepoName, "err", err) return "", nil, err diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index a3cc646729..50a1cc0af5 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -31,7 +31,7 @@ type GitOpsManifestPushServiceImpl struct { acdConfig *argocdServer.ACDConfig chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, @@ -39,7 +39,7 @@ func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *GitOpsManifestPushServiceImpl { + gitOperationService git.GitOperationService) *GitOpsManifestPushServiceImpl { return &GitOpsManifestPushServiceImpl{ logger: logger, pipelineStatusTimelineService: pipelineStatusTimelineService, @@ -47,7 +47,7 @@ func NewGitOpsManifestPushServiceImpl(logger *zap.SugaredLogger, acdConfig: acdConfig, chartRefService: chartRefService, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } } @@ -108,7 +108,7 @@ func (impl *GitOpsManifestPushServiceImpl) PushChartToGitRepo(manifestPushTempla impl.logger.Errorw("err in getting chart info", "err", err) return err } - err = impl.gitOpsRemoteOperationService.PushChartToGitRepo(gitOpsRepoName, manifestPushTemplate.ChartReferenceTemplate, manifestPushTemplate.ChartVersion, manifestPushTemplate.BuiltChartPath, manifestPushTemplate.RepoUrl, manifestPushTemplate.UserId) + err = impl.gitOperationService.PushChartToGitRepo(gitOpsRepoName, manifestPushTemplate.ChartReferenceTemplate, manifestPushTemplate.ChartVersion, manifestPushTemplate.BuiltChartPath, manifestPushTemplate.RepoUrl, manifestPushTemplate.UserId) if err != nil { impl.logger.Errorw("error in pushing chart to git", "err", err) return err @@ -135,8 +135,8 @@ func (impl *GitOpsManifestPushServiceImpl) CommitValuesToGit(manifestPushTemplat UserEmailId: userEmailId, } - _, span = otel.Tracer("orchestrator").Start(ctx, "gitOpsRemoteOperationService.CommitValues") - commitHash, commitTime, err = impl.gitOpsRemoteOperationService.CommitValues(chartGitAttr) + _, span = otel.Tracer("orchestrator").Start(ctx, "gitOperationService.CommitValues") + commitHash, commitTime, err = impl.gitOperationService.CommitValues(chartGitAttr) span.End() if err != nil { impl.logger.Errorw("error in git commit", "err", err) diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 759ed4bd7a..ca443aeeef 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -69,7 +69,7 @@ type AppStoreDeploymentCommonServiceImpl struct { chartTemplateService util.ChartTemplateService gitFactory *util.GitFactory gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewAppStoreDeploymentCommonServiceImpl( @@ -80,7 +80,7 @@ func NewAppStoreDeploymentCommonServiceImpl( chartTemplateService util.ChartTemplateService, gitFactory *util.GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentCommonServiceImpl { + gitOperationService git.GitOperationService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -89,7 +89,7 @@ func NewAppStoreDeploymentCommonServiceImpl( chartTemplateService: chartTemplateService, gitFactory: gitFactory, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } } @@ -420,7 +420,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi BitBucketWorkspaceId: bitbucketMetadata.BitBucketWorkspaceId, BitBucketProjectKey: bitbucketMetadata.BitBucketProjectKey, } - repoUrl, isNew, err := impl.gitOpsRemoteOperationService.CreateRepository(gitRepoRequest, installAppVersionRequest.UserId) + repoUrl, isNew, err := impl.gitOperationService.CreateRepository(gitRepoRequest, installAppVersionRequest.UserId) if err != nil { impl.logger.Errorw("error in creating git project", "name", installAppVersionRequest.GitOpsRepoName, "err", err) return "", false, err @@ -433,22 +433,19 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT space := regexp.MustCompile(`\s+`) appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(PushChartToGitRequest.RepoURL, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) - return nil, "", err - } - } else { - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) - if err != nil { - return nil, "", err - } + clonedDir, err := impl.gitOperationService.GetClonedDir(chartDir, PushChartToGitRequest.RepoURL) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", PushChartToGitRequest.RepoURL, "err", err) + return nil, "", err + } + err = impl.gitOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, appStoreName) + if err != nil { + return nil, "", err } + acdAppName := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, PushChartToGitRequest.EnvName) dir := filepath.Join(clonedDir, acdAppName) - err := os.MkdirAll(dir, os.ModePerm) + err = os.MkdirAll(dir, os.ModePerm) if err != nil { impl.logger.Errorw("error in making dir", "err", err) return nil, "", err @@ -469,11 +466,11 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT return nil, "", err } userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(PushChartToGitRequest.UserId) - commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + commit, err := impl.gitOperationService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) if err != nil { impl.logger.Errorw("error in pushing git", "err", err) impl.logger.Warn("re-trying, taking pull and then push again") - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) + err = impl.gitOperationService.GitPull(clonedDir, PushChartToGitRequest.RepoURL, acdAppName) if err != nil { impl.logger.Errorw("error in git pull", "err", err, "appName", acdAppName) return nil, "", err @@ -483,7 +480,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT impl.logger.Errorw("error copying dir", "err", err) return nil, "", err } - commit, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) + commit, err = impl.gitOperationService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) if err != nil { impl.logger.Errorw("error in pushing git", "err", err) return nil, "", err @@ -547,23 +544,23 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. // step-2 commit dependencies and values in git if !isNew { - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.RequirementsConfig) + _, _, err = impl.gitOperationService.CommitValues(manifestResponse.RequirementsConfig) if err != nil { impl.logger.Errorw("error in committing dependency config to git", "err", err) return appStoreGitOpsResponse, err } - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + err = impl.gitOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) if err != nil { impl.logger.Errorw("error in git pull", "err", err) return appStoreGitOpsResponse, err } - githash, _, err = impl.gitOpsRemoteOperationService.CommitValues(manifestResponse.ValuesConfig) + githash, _, err = impl.gitOperationService.CommitValues(manifestResponse.ValuesConfig) if err != nil { impl.logger.Errorw("error in committing values config to git", "err", err) return appStoreGitOpsResponse, err } - err = impl.gitOpsRemoteOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) + err = impl.gitOperationService.GitPull(clonedDir, chartGitAttribute.RepoUrl, appStoreName) if err != nil { impl.logger.Errorw("error in git pull", "err", err) return appStoreGitOpsResponse, err diff --git a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go index e0a3e066f3..ad2242066f 100644 --- a/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go +++ b/pkg/appStore/deployment/fullMode/AppStoreDeploymentFullModeService.go @@ -73,7 +73,7 @@ type AppStoreDeploymentFullModeServiceImpl struct { installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository ACDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, @@ -86,7 +86,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository4.InstalledAppVersionHistoryRepository, ACDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentFullModeServiceImpl { + gitOperationService git.GitOperationService) *AppStoreDeploymentFullModeServiceImpl { appStoreDeploymentFullModeServiceImpl := &AppStoreDeploymentFullModeServiceImpl{ logger: logger, acdClient: acdClient, @@ -100,7 +100,7 @@ func NewAppStoreDeploymentFullModeServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory: installedAppRepositoryHistory, ACDConfig: ACDConfig, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } err := appStoreDeploymentFullModeServiceImpl.subscribeHelmInstallStatus() if err != nil { @@ -217,7 +217,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) UpdateValuesYaml(installAppVer impl.logger.Errorw("error in getting git commit config", "err", err) } - commitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) + commitHash, _, err := impl.gitOperationService.CommitValues(valuesGitConfig) if err != nil { impl.logger.Errorw("error in git commit", "err", err) return installAppVersionRequest, errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) @@ -241,7 +241,7 @@ func (impl AppStoreDeploymentFullModeServiceImpl) UpdateRequirementYaml(installA return err } - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(requirementsGitConfig) + _, _, err = impl.gitOperationService.CommitValues(requirementsGitConfig) if err != nil { impl.logger.Errorw("error in values commit", "err", err) return errors.New(pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED) diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index 39b2d05519..c8f4db9f2e 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -108,7 +108,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, @@ -120,7 +120,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentServiceImpl { + gitOperationService git.GitOperationService) *AppStoreDeploymentServiceImpl { appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ logger: logger, @@ -141,7 +141,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep deploymentTypeConfig: deploymentTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } return appStoreDeploymentServiceImpl } @@ -1475,12 +1475,12 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } else if isChartChanged || isVersionChanged { // update dependency if chart or chart version is changed - _, _, requirementsCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.RequirementsConfig) - gitHash, _, valuesCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.ValuesConfig) + _, _, requirementsCommitErr = impl.gitOperationService.CommitValues(manifest.RequirementsConfig) + gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) } else { // only values are changed in update, so commit values config - gitHash, _, valuesCommitErr = impl.gitOpsRemoteOperationService.CommitValues(manifest.ValuesConfig) + gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) } if valuesCommitErr != nil || requirementsCommitErr != nil { diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 0bac817246..5566598f01 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -124,7 +124,7 @@ type InstalledAppServiceImpl struct { k8sApplicationService application3.K8sApplicationService acdConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, @@ -147,7 +147,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, acdConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) (*InstalledAppServiceImpl, error) { + gitOperationService git.GitOperationService) (*InstalledAppServiceImpl, error) { impl := &InstalledAppServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -177,7 +177,7 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, k8sApplicationService: k8sApplicationService, acdConfig: acdConfig, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } err := impl.Subscribe() if err != nil { @@ -446,7 +446,7 @@ func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion return nil, err } - repoUrl, err := impl.gitOpsRemoteOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) + repoUrl, err := impl.gitOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) if err != nil { //will allow to continue to persist status on next operation impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go index a19fa6c975..501693cffd 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go @@ -71,7 +71,7 @@ type AppStoreDeploymentArgoCdServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository argoClientWrapperService argocdServer.ArgoClientWrapperService acdConfig *argocdServer.ACDConfig - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, @@ -83,7 +83,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, argoClientWrapperService argocdServer.ArgoClientWrapperService, acdConfig *argocdServer.ACDConfig, - gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentArgoCdServiceImpl { + gitOperationService git.GitOperationService) *AppStoreDeploymentArgoCdServiceImpl { return &AppStoreDeploymentArgoCdServiceImpl{ Logger: logger, appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, @@ -101,7 +101,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl(logger *zap.SugaredLogger, appStoreD appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, argoClientWrapperService: argoClientWrapperService, acdConfig: acdConfig, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } } @@ -544,7 +544,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYaml(installAppVersi impl.Logger.Errorw("error in getting git config for helm app", "err", err) return nil, err } - gitHash, _, err := impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) + gitHash, _, err := impl.gitOperationService.CommitValues(valuesGitConfig) if err != nil { impl.Logger.Errorw("error in git commit", "err", err) _ = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go index d8dbfc167a..e57416218c 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go @@ -39,7 +39,7 @@ type AppStoreDeploymentHelmServiceImpl struct { installedAppRepository repository.InstalledAppRepository appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, @@ -47,7 +47,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ helmAppClient client.HelmAppClient, installedAppRepository repository.InstalledAppRepository, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository, - gitOpsRemoteOperationService git.GitOperationService) *AppStoreDeploymentHelmServiceImpl { + gitOperationService git.GitOperationService) *AppStoreDeploymentHelmServiceImpl { return &AppStoreDeploymentHelmServiceImpl{ Logger: logger, helmAppService: helmAppService, @@ -56,7 +56,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ installedAppRepository: installedAppRepository, appStoreDeploymentCommonService: appStoreDeploymentCommonService, OCIRegistryConfigRepository: OCIRegistryConfigRepository, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } } @@ -274,7 +274,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installA impl.Logger.Errorw("error in getting git config for helm app", "err", err) return err } - _, _, err = impl.gitOpsRemoteOperationService.CommitValues(valuesGitConfig) + _, _, err = impl.gitOperationService.CommitValues(valuesGitConfig) if err != nil { impl.Logger.Errorw("error in committing config to git for helm app", "err", err) return err diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index e434666a51..08adb97933 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -26,9 +26,15 @@ type GitOperationService interface { CreateChartProxy(chartMetaData *chart.Metadata, refChartLocation string, envName string, chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) GitPull(clonedDir string, repoUrl string, appStoreName string) error + CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) + CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId string) (commitHash string, err error) + CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) GetRepoUrlByRepoName(repoName string) (string, error) + + GetClonedDir(chartDir, repoUrl string) (string, error) + CloneDir(repoUrl, chartDir string) (string, error) } type GitOperationServiceImpl struct { @@ -338,6 +344,15 @@ func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *util.ChartConfig return commitHash, commitTime, nil } +func (impl *GitOperationServiceImpl) CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId string) (commitHash string, err error) { + commitHash, err = impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId) + if err != nil { + impl.logger.Errorw("error in pushing git", "err", err) + return commitHash, err + } + return commitHash, nil +} + func (impl *GitOperationServiceImpl) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) { //getting user name & emailId for commit author data userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) @@ -374,3 +389,23 @@ func (impl *GitOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (stri } return repoUrl, nil } + +func (impl *GitOperationServiceImpl) GetClonedDir(chartDir, repoUrl string) (string, error) { + clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) + if _, err := os.Stat(clonedDir); os.IsNotExist(err) { + return impl.CloneDir(repoUrl, chartDir) + } else if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return "", err + } + return clonedDir, nil +} + +func (impl *GitOperationServiceImpl) CloneDir(repoUrl, chartDir string) (string, error) { + clonedDir, err := impl.gitFactory.GitService.Clone(repoUrl, chartDir) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return "", err + } + return clonedDir, nil +} diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 72a15b312c..c806a1942e 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -148,7 +148,7 @@ type CdPipelineConfigServiceImpl struct { argoClientWrapperService argocdServer.ArgoClientWrapperService deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -169,7 +169,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor argoClientWrapperService argocdServer.ArgoClientWrapperService, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *CdPipelineConfigServiceImpl { + gitOperationService git.GitOperationService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -203,7 +203,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor argoClientWrapperService: argoClientWrapperService, deployedAppMetricsService: deployedAppMetricsService, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } } @@ -1596,7 +1596,7 @@ func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, ch emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "git repository is empty"} if strings.Contains(err.Error(), emptyRepoErrorMessage[0]) || strings.Contains(err.Error(), emptyRepoErrorMessage[1]) { // - found empty repository, create some file in repository - err := impl.gitOpsRemoteOperationService.CreateReadmeInGitRepo(gitOpsRepoName, userId) + err := impl.gitOperationService.CreateReadmeInGitRepo(gitOpsRepoName, userId) if err != nil { impl.logger.Errorw("error in creating file in git repo", "err", err) return err diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 653e63ee65..b8e404af3b 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -193,7 +193,7 @@ type WorkflowDagExecutorImpl struct { deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService chartRefService chartRef.ChartRefService gitOpsConfigReadService config.GitOpsConfigReadService - gitOpsRemoteOperationService git.GitOperationService + gitOperationService git.GitOperationService } const kedaAutoscaling = "kedaAutoscaling" @@ -314,7 +314,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, - gitOpsRemoteOperationService git.GitOperationService) *WorkflowDagExecutorImpl { + gitOperationService git.GitOperationService) *WorkflowDagExecutorImpl { wde := &WorkflowDagExecutorImpl{logger: Logger, pipelineRepository: pipelineRepository, cdWorkflowRepository: cdWorkflowRepository, @@ -382,7 +382,7 @@ func NewWorkflowDagExecutorImpl(Logger *zap.SugaredLogger, pipelineRepository pi deployedAppMetricsService: deployedAppMetricsService, chartRefService: chartRefService, gitOpsConfigReadService: gitOpsConfigReadService, - gitOpsRemoteOperationService: gitOpsRemoteOperationService, + gitOperationService: gitOperationService, } config, err := types.GetCdConfig() if err != nil { From c1adf3234b52b1662eee3ca327bae65906be4363 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 13:29:43 +0530 Subject: [PATCH 34/83] shifted git service and all gitOps clients to pkg --- Wire.go | 5 ++-- cmd/external-app/wire.go | 5 ++-- cmd/external-app/wire_gen.go | 4 +-- internal/util/GitService_test.go | 9 +++--- pkg/app/ManifestPushService.go | 3 +- .../common/AppStoreDeploymentCommonService.go | 28 +++++++++---------- .../service/InstalledAppService_test.go | 3 +- .../deployment/gitOps/git}/GitCliUtil.go | 2 +- .../gitOps/git/GitOperationService.go | 8 +++--- .../deployment/gitOps/git}/GitService.go | 16 +++++------ .../deployment/gitOps/git}/GitServiceAzure.go | 4 +-- .../gitOps/git}/GitServiceBitbucket.go | 4 +-- .../gitOps/git}/GitServiceGithub.go | 4 +-- .../gitOps/git}/GitServiceGitlab.go | 2 +- pkg/gitops/GitOpsConfigService.go | 15 +++++----- wire_gen.go | 4 +-- 16 files changed, 60 insertions(+), 56 deletions(-) rename {internal/util => pkg/deployment/gitOps/git}/GitCliUtil.go (99%) rename {internal/util => pkg/deployment/gitOps/git}/GitService.go (96%) rename {internal/util => pkg/deployment/gitOps/git}/GitServiceAzure.go (99%) rename {internal/util => pkg/deployment/gitOps/git}/GitServiceBitbucket.go (99%) rename {internal/util => pkg/deployment/gitOps/git}/GitServiceGithub.go (99%) rename {internal/util => pkg/deployment/gitOps/git}/GitServiceGitlab.go (99%) diff --git a/Wire.go b/Wire.go index ef2877347b..d3b14ac7cb 100644 --- a/Wire.go +++ b/Wire.go @@ -100,6 +100,7 @@ import ( "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" deployment2 "github.com/devtron-labs/devtron/pkg/deployment" + git2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -345,7 +346,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), pipelineConfig.NewCiPipelineMaterialRepositoryImpl, wire.Bind(new(pipelineConfig.CiPipelineMaterialRepository), new(*pipelineConfig.CiPipelineMaterialRepositoryImpl)), - util.NewGitFactory, + git2.NewGitFactory, application.NewApplicationClientImpl, wire.Bind(new(application.ServiceClient), new(*application.ServiceClientImpl)), @@ -658,7 +659,7 @@ func InitializeApp() (*App, error) { scopedVariable.NewScopedVariableRestHandlerImpl, wire.Bind(new(scopedVariable.ScopedVariableRestHandler), new(*scopedVariable.ScopedVariableRestHandlerImpl)), - util.NewGitCliUtil, + git2.NewGitCliUtil, router.NewTelemetryRouterImpl, wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 01427bafe1..da0f16094b 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -44,6 +44,7 @@ import ( "github.com/devtron-labs/devtron/pkg/attributes" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/pipeline" @@ -178,8 +179,8 @@ func InitializeApp() (*App, error) { util.NewChartTemplateServiceImpl, wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - util.NewGitFactory, - util.NewGitCliUtil, + git.NewGitFactory, + git.NewGitCliUtil, security2.NewScanToolMetadataRepositoryImpl, wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 1f768a004f..dd3932c80d 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -234,8 +234,8 @@ func InitializeApp() (*App, error) { dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - gitCliUtil := util.NewGitCliUtil(sugaredLogger) - gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) + gitCliUtil := git.NewGitCliUtil(sugaredLogger) + gitFactory, err := git.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) if err != nil { return nil, err } diff --git a/internal/util/GitService_test.go b/internal/util/GitService_test.go index 6c23a4202d..10eee631a3 100644 --- a/internal/util/GitService_test.go +++ b/internal/util/GitService_test.go @@ -2,15 +2,16 @@ package util import ( "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "testing" ) -func getTestGithubClient() GitHubClient { +func getTestGithubClient() git.GitHubClient { logger, err := NewSugardLogger() - gitCliUtl := NewGitCliUtil(logger) - gitService := NewGitServiceImpl(&GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) + gitCliUtl := git.NewGitCliUtil(logger) + gitService := git.NewGitServiceImpl(&git.GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) - githubClient, err := NewGithubClient("", "", "test-org", logger, gitService, nil) + githubClient, err := git.NewGithubClient("", "", "test-org", logger, gitService, nil) if err != nil { panic(err) } diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 50a1cc0af5..6502a797d8 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" @@ -124,7 +123,7 @@ func (impl *GitOpsManifestPushServiceImpl) CommitValuesToGit(manifestPushTemplat //getting username & emailId for commit author data userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(manifestPushTemplate.UserId) span.End() - chartGitAttr := &util.ChartConfig{ + chartGitAttr := &git.ChartConfig{ FileName: fmt.Sprintf("_%d-values.yaml", manifestPushTemplate.TargetEnvironmentName), FileContent: string(manifestPushTemplate.MergedValues), ChartName: manifestPushTemplate.ChartName, diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index ca443aeeef..68146304c0 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -50,10 +50,10 @@ type AppStoreDeploymentCommonService interface { GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) ParseGitRepoErrorResponse(err error) (bool, error) - GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) + GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*git.ChartConfig, *git.ChartConfig, error) CreateChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) - CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) - GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) + CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) + GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*git.ChartConfig, error) GetValuesString(chartName, valuesOverrideYaml string) (string, error) GetRequirementsString(appStoreVersionId int) (string, error) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *AppStoreManifestResponse, err error) @@ -67,7 +67,7 @@ type AppStoreDeploymentCommonServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository2.EnvironmentRepository chartTemplateService util.ChartTemplateService - gitFactory *util.GitFactory + gitFactory *git.GitFactory gitOpsConfigReadService config.GitOpsConfigReadService gitOperationService git.GitOperationService } @@ -78,7 +78,7 @@ func NewAppStoreDeploymentCommonServiceImpl( appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository2.EnvironmentRepository, chartTemplateService util.ChartTemplateService, - gitFactory *util.GitFactory, + gitFactory *git.GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, gitOperationService git.GitOperationService) *AppStoreDeploymentCommonServiceImpl { return &AppStoreDeploymentCommonServiceImpl{ @@ -115,8 +115,8 @@ func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersi type AppStoreManifestResponse struct { ChartResponse *util.ChartCreateResponse - ValuesConfig *util.ChartConfig - RequirementsConfig *util.ChartConfig + ValuesConfig *git.ChartConfig + RequirementsConfig *git.ChartConfig } type AppStoreGitOpsResponse struct { @@ -228,7 +228,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) ParseGitRepoErrorResponse(err er impl.logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) noTargetFound = true } - if err.Error() == util.BITBUCKET_REPO_NOT_FOUND_ERROR { + if err.Error() == git.BITBUCKET_REPO_NOT_FOUND_ERROR { impl.logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) noTargetFound = true } @@ -289,7 +289,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetRequirementsString(appStoreVe return string(requirementDependenciesByte), nil } -func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*util.ChartConfig, error) { +func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*git.ChartConfig, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { impl.logger.Errorw("fetching error", "err", err) @@ -304,7 +304,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVer argocdAppName := installAppVersionRequest.AppName + "-" + environment.Name gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(installAppVersionRequest.UserId) - YamlConfig := &util.ChartConfig{ + YamlConfig := &git.ChartConfig{ FileName: filename, FileContent: fileString, ChartName: installAppVersionRequest.AppName, @@ -317,7 +317,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GetGitCommitConfig(installAppVer return YamlConfig, nil } -func (impl AppStoreDeploymentCommonServiceImpl) GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartConfig, *util.ChartConfig, error) { +func (impl AppStoreDeploymentCommonServiceImpl) GetValuesAndRequirementGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*git.ChartConfig, *git.ChartConfig, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { @@ -429,7 +429,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepo(installAppVersi } // PushChartToGitopsRepo pushes built chart to gitOps repo -func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, string, error) { +func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartToGitRequest *appStoreBean.PushChartToGitRequestDTO, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, string, error) { space := regexp.MustCompile(`\s+`) appStoreName := space.ReplaceAllString(PushChartToGitRequest.ChartAppStoreName, "-") chartDir := fmt.Sprintf("%s-%s", PushChartToGitRequest.AppName, impl.chartTemplateService.GetDir()) @@ -492,7 +492,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) PushChartToGitopsRepo(PushChartT } // AddConfigFileToChart will override requirements.yaml file in chart -func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *util.ChartConfig, dir string, clonedDir string) error { +func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *git.ChartConfig, dir string, clonedDir string) error { filePath := filepath.Join(clonedDir, config.FileName) file, err := os.Create(filePath) if err != nil { @@ -515,7 +515,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) AddConfigFileToChart(config *uti } // CreateGitOpsRepoAndPushChart is a wrapper for creating gitops repo and pushing chart to created repo -func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *util.ChartConfig, valuesConfig *util.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { +func (impl AppStoreDeploymentCommonServiceImpl) CreateGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { repoURL, isNew, err := impl.CreateGitOpsRepo(installAppVersionRequest) if err != nil { impl.logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index d942bbc4f5..2c2f90e7be 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -1,6 +1,7 @@ package service import ( + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "testing" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" @@ -40,7 +41,7 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { chartGroupDeploymentRepository repository5.ChartGroupDeploymentRepository envService cluster.EnvironmentService ArgoK8sClient argocdServer.ArgoK8sClient - gitFactory *util.GitFactory + gitFactory *git.GitFactory aCDAuthConfig *util2.ACDAuthConfig gitOpsRepository repository3.GitOpsConfigRepository userService user.UserService diff --git a/internal/util/GitCliUtil.go b/pkg/deployment/gitOps/git/GitCliUtil.go similarity index 99% rename from internal/util/GitCliUtil.go rename to pkg/deployment/gitOps/git/GitCliUtil.go index 54d9281a2a..587e20f1c6 100644 --- a/internal/util/GitCliUtil.go +++ b/pkg/deployment/gitOps/git/GitCliUtil.go @@ -1,4 +1,4 @@ -package util +package git import ( "fmt" diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index 08adb97933..6fa5f879d4 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -27,7 +27,7 @@ type GitOperationService interface { chartProxyReq *bean.ChartProxyReqDto) (string, *commonBean.ChartGitAttribute, error) GitPull(clonedDir string, repoUrl string, appStoreName string) error - CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) + CommitValues(chartGitAttr *ChartConfig) (commitHash string, commitTime time.Time, err error) CommitAndPushAllChanges(clonedDir, commitMsg, userName, userEmailId string) (commitHash string, err error) CreateRepository(dto *bean2.GitOpsConfigDto, userId int32) (string, bool, error) @@ -39,12 +39,12 @@ type GitOperationService interface { type GitOperationServiceImpl struct { logger *zap.SugaredLogger - gitFactory *util.GitFactory + gitFactory *GitFactory gitOpsConfigReadService config.GitOpsConfigReadService chartTemplateService util.ChartTemplateService } -func NewGitOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *util.GitFactory, +func NewGitOperationServiceImpl(logger *zap.SugaredLogger, gitFactory *GitFactory, gitOpsConfigReadService config.GitOpsConfigReadService, chartTemplateService util.ChartTemplateService) *GitOperationServiceImpl { return &GitOperationServiceImpl{ @@ -326,7 +326,7 @@ func (impl *GitOperationServiceImpl) GitPull(clonedDir string, repoUrl string, a return nil } -func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *util.ChartConfig) (commitHash string, commitTime time.Time, err error) { +func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *ChartConfig) (commitHash string, commitTime time.Time, err error) { bitbucketMetadata, err := impl.gitOpsConfigReadService.GetBitbucketMetadata() if err != nil { impl.logger.Errorw("error in getting bitbucket metadata", "err", err) diff --git a/internal/util/GitService.go b/pkg/deployment/gitOps/git/GitService.go similarity index 96% rename from internal/util/GitService.go rename to pkg/deployment/gitOps/git/GitService.go index 882772e523..d80e550a6f 100644 --- a/internal/util/GitService.go +++ b/pkg/deployment/gitOps/git/GitService.go @@ -15,7 +15,7 @@ * */ -package util +package git import ( "context" @@ -88,19 +88,19 @@ func (factory *GitFactory) Reload() error { defer func() { util.TriggerGitOpsMetrics("Reload", "GitService", start, err) }() - logger.Infow("reloading gitops details") + factory.logger.Infow("reloading gitops details") cfg, err := GetGitConfig(factory.gitOpsRepository) if err != nil { return err } - gitService := NewGitServiceImpl(cfg, logger, factory.gitCliUtil) + gitService := NewGitServiceImpl(cfg, factory.logger, factory.gitCliUtil) factory.GitService = gitService - client, err := NewGitOpsClient(cfg, logger, gitService, factory.gitOpsRepository) + client, err := NewGitOpsClient(cfg, factory.logger, gitService, factory.gitOpsRepository) if err != nil { return err } factory.Client = client - logger.Infow(" gitops details reload success") + factory.logger.Infow(" gitops details reload success") return nil } @@ -159,15 +159,15 @@ func (factory *GitFactory) NewClientForValidation(gitOpsConfig *bean2.GitOpsConf BitbucketWorkspaceId: gitOpsConfig.BitBucketWorkspaceId, BitbucketProjectKey: gitOpsConfig.BitBucketProjectKey, } - gitService := NewGitServiceImpl(cfg, logger, factory.gitCliUtil) + gitService := NewGitServiceImpl(cfg, factory.logger, factory.gitCliUtil) //factory.GitService = GitService - client, err := NewGitOpsClient(cfg, logger, gitService, factory.gitOpsRepository) + client, err := NewGitOpsClient(cfg, factory.logger, gitService, factory.gitOpsRepository) if err != nil { return client, gitService, err } //factory.Client = client - logger.Infow("client changed successfully", "cfg", cfg) + factory.logger.Infow("client changed successfully", "cfg", cfg) return client, gitService, nil } diff --git a/internal/util/GitServiceAzure.go b/pkg/deployment/gitOps/git/GitServiceAzure.go similarity index 99% rename from internal/util/GitServiceAzure.go rename to pkg/deployment/gitOps/git/GitServiceAzure.go index d47f4f8be4..1bb7dfbbc7 100644 --- a/internal/util/GitServiceAzure.go +++ b/pkg/deployment/gitOps/git/GitServiceAzure.go @@ -1,4 +1,4 @@ -package util +package git import ( "context" @@ -91,7 +91,7 @@ func (impl GitAzureClient) CreateRepository(config *bean2.GitOpsConfigDto) (url detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err return "", true, detailedErrorGitOpsConfigActions } - logger.Infow("repo created ", "r", operationReference.WebUrl) + impl.logger.Infow("repo created ", "r", operationReference.WebUrl) detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, CreateRepoStage) validated, err := impl.ensureProjectAvailabilityOnHttp(config.GitRepoName) if err != nil { diff --git a/internal/util/GitServiceBitbucket.go b/pkg/deployment/gitOps/git/GitServiceBitbucket.go similarity index 99% rename from internal/util/GitServiceBitbucket.go rename to pkg/deployment/gitOps/git/GitServiceBitbucket.go index 8be8359c0e..ec9296f84f 100644 --- a/internal/util/GitServiceBitbucket.go +++ b/pkg/deployment/gitOps/git/GitServiceBitbucket.go @@ -1,4 +1,4 @@ -package util +package git import ( "fmt" @@ -100,7 +100,7 @@ func (impl GitBitbucketClient) CreateRepository(config *bean2.GitOpsConfigDto) ( return "", true, detailedErrorGitOpsConfigActions } repoUrl = fmt.Sprintf(BITBUCKET_CLONE_BASE_URL+"%s/%s.git", repoOptions.Owner, repoOptions.RepoSlug) - logger.Infow("repo created ", "repoUrl", repoUrl) + impl.logger.Infow("repo created ", "repoUrl", repoUrl) detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, CreateRepoStage) validated, err := impl.ensureProjectAvailabilityOnHttp(repoOptions) diff --git a/internal/util/GitServiceGithub.go b/pkg/deployment/gitOps/git/GitServiceGithub.go similarity index 99% rename from internal/util/GitServiceGithub.go rename to pkg/deployment/gitOps/git/GitServiceGithub.go index 12efedebc3..b7cb50c927 100644 --- a/internal/util/GitServiceGithub.go +++ b/pkg/deployment/gitOps/git/GitServiceGithub.go @@ -1,4 +1,4 @@ -package util +package git import ( "context" @@ -99,7 +99,7 @@ func (impl GitHubClient) CreateRepository(config *bean2.GitOpsConfigDto) (url st detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err return "", true, detailedErrorGitOpsConfigActions } - logger.Infow("github repo created ", "r", r.CloneURL) + impl.logger.Infow("github repo created ", "r", r.CloneURL) detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, CreateRepoStage) validated, err := impl.ensureProjectAvailabilityOnHttp(config) diff --git a/internal/util/GitServiceGitlab.go b/pkg/deployment/gitOps/git/GitServiceGitlab.go similarity index 99% rename from internal/util/GitServiceGitlab.go rename to pkg/deployment/gitOps/git/GitServiceGitlab.go index ad34974412..4f8e210698 100644 --- a/internal/util/GitServiceGitlab.go +++ b/pkg/deployment/gitOps/git/GitServiceGitlab.go @@ -1,4 +1,4 @@ -package util +package git import ( "fmt" diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index bda050d404..923b31a65d 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -24,6 +24,7 @@ import ( util4 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "math/rand" "net/http" "net/url" @@ -95,7 +96,7 @@ type GitOpsConfigServiceImpl struct { K8sUtil *util4.K8sServiceImpl aCDAuthConfig *util3.ACDAuthConfig clusterService cluster.ClusterService - gitFactory *util.GitFactory + gitFactory *git.GitFactory argoUserService argo.ArgoUserService clusterServiceCD cluster2.ServiceClient gitOpsConfigReadService config.GitOpsConfigReadService @@ -105,7 +106,7 @@ func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, globalEnvVariables *util2.GlobalEnvVariables, gitOpsRepository repository.GitOpsConfigRepository, K8sUtil *util4.K8sServiceImpl, aCDAuthConfig *util3.ACDAuthConfig, clusterService cluster.ClusterService, - gitFactory *util.GitFactory, argoUserService argo.ArgoUserService, + gitFactory *git.GitFactory, argoUserService argo.ArgoUserService, clusterServiceCD cluster2.ServiceClient, gitOpsConfigReadService config.GitOpsConfigReadService) *GitOpsConfigServiceImpl { return &GitOpsConfigServiceImpl{ randSource: rand.NewSource(time.Now().UnixNano()), @@ -290,7 +291,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req } } if strings.ToUpper(request.Provider) == bean.BITBUCKET_PROVIDER { - request.Host = util.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId + request.Host = git.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId } operationComplete := false retryCount := 0 @@ -491,7 +492,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon } } if strings.ToUpper(request.Provider) == bean.BITBUCKET_PROVIDER { - request.Host = util.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId + request.Host = git.BITBUCKET_CLONE_BASE_URL + request.BitBucketWorkspaceId } operationComplete := false retryCount := 0 @@ -679,13 +680,13 @@ func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsCo } config.Token = model.Token } - detailedErrorGitOpsConfigActions := util.DetailedErrorGitOpsConfigActions{} + detailedErrorGitOpsConfigActions := git.DetailedErrorGitOpsConfigActions{} detailedErrorGitOpsConfigActions.StageErrorMap = make(map[string]error) /*if strings.ToUpper(config.Provider) == GITHUB_PROVIDER { config.Host = GITHUB_HOST }*/ if strings.ToUpper(config.Provider) == bean.BITBUCKET_PROVIDER { - config.Host = util.BITBUCKET_CLONE_BASE_URL + config.Host = git.BITBUCKET_CLONE_BASE_URL config.BitBucketProjectKey = strings.ToUpper(config.BitBucketProjectKey) } client, gitService, err := impl.gitFactory.NewClientForValidation(config) @@ -793,7 +794,7 @@ func (impl *GitOpsConfigServiceImpl) extractErrorMessageByProvider(err error, pr return err } -func (impl *GitOpsConfigServiceImpl) convertDetailedErrorToResponse(detailedErrorGitOpsConfigActions util.DetailedErrorGitOpsConfigActions) (detailedErrorResponse DetailedErrorGitOpsConfigResponse) { +func (impl *GitOpsConfigServiceImpl) convertDetailedErrorToResponse(detailedErrorGitOpsConfigActions git.DetailedErrorGitOpsConfigActions) (detailedErrorResponse DetailedErrorGitOpsConfigResponse) { detailedErrorResponse.StageErrorMap = make(map[string]string) detailedErrorResponse.SuccessfulStages = detailedErrorGitOpsConfigActions.SuccessfulStages for stage, err := range detailedErrorGitOpsConfigActions.StageErrorMap { diff --git a/wire_gen.go b/wire_gen.go index 4a8ed0becf..09d7f89c6e 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -372,8 +372,8 @@ func InitializeApp() (*App, error) { } chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl, utilMergeUtil) gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) - gitCliUtil := util.NewGitCliUtil(sugaredLogger) - gitFactory, err := util.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) + gitCliUtil := git.NewGitCliUtil(sugaredLogger) + gitFactory, err := git.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) if err != nil { return nil, err } From c1ab97005cfc64beef909858126fde52740317e8 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 14:09:14 +0530 Subject: [PATCH 35/83] gitops repository usages refactor --- .../telemetry/TelemetryEventClientExtended.go | 19 +++---- cmd/external-app/wire_gen.go | 2 +- .../sql/repository/GitOpsConfigRepository.go | 13 ----- .../common/AppStoreDeploymentCommonService.go | 2 +- .../service/AppStoreDeploymentService.go | 17 ++---- .../deployment/service/InstalledAppService.go | 12 ++--- .../service/InstalledAppService_test.go | 8 --- pkg/cluster/ClusterServiceExtended.go | 24 ++++----- .../gitOps/config/GitOpsConfigReadService.go | 12 +++++ .../gitOps/git/GitOperationService.go | 44 +++++++-------- pkg/deployment/gitOps/git/GitService.go | 54 +------------------ pkg/gitops/GitOpsConfigService.go | 2 +- util/argo/ArgoUserService.go | 24 ++++----- wire_gen.go | 46 ++++++++-------- 14 files changed, 98 insertions(+), 181 deletions(-) diff --git a/client/telemetry/TelemetryEventClientExtended.go b/client/telemetry/TelemetryEventClientExtended.go index cdf27e02b8..59bde30c0a 100644 --- a/client/telemetry/TelemetryEventClientExtended.go +++ b/client/telemetry/TelemetryEventClientExtended.go @@ -3,6 +3,7 @@ package telemetry import ( "encoding/json" cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "net/http" "time" @@ -35,7 +36,6 @@ type TelemetryEventClientImplExtended struct { appListingRepository repository.AppListingRepository ciPipelineRepository pipelineConfig.CiPipelineRepository pipelineRepository pipelineConfig.PipelineRepository - gitOpsConfigRepository repository.GitOpsConfigRepository gitProviderRepository repository.GitProviderRepository dockerArtifactStoreRepository dockerRegistryRepository.DockerArtifactStoreRepository appRepository app.AppRepository @@ -45,6 +45,7 @@ type TelemetryEventClientImplExtended struct { ciTemplateRepository pipelineConfig.CiTemplateRepository chartRepository chartRepoRepository.ChartRepository ciBuildConfigService pipeline.CiBuildConfigService + gitOpsConfigReadService config.GitOpsConfigReadService *TelemetryEventClientImpl } @@ -53,15 +54,16 @@ func NewTelemetryEventClientImplExtended(logger *zap.SugaredLogger, client *http environmentService cluster.EnvironmentService, userService user2.UserService, appListingRepository repository.AppListingRepository, PosthogClient *PosthogClient, ciPipelineRepository pipelineConfig.CiPipelineRepository, pipelineRepository pipelineConfig.PipelineRepository, - gitOpsConfigRepository repository.GitOpsConfigRepository, gitProviderRepository repository.GitProviderRepository, - attributeRepo repository.AttributesRepository, ssoLoginService sso.SSOLoginService, appRepository app.AppRepository, + gitProviderRepository repository.GitProviderRepository, attributeRepo repository.AttributesRepository, + ssoLoginService sso.SSOLoginService, appRepository app.AppRepository, ciWorkflowRepository pipelineConfig.CiWorkflowRepository, cdWorkflowRepository pipelineConfig.CdWorkflowRepository, dockerArtifactStoreRepository dockerRegistryRepository.DockerArtifactStoreRepository, materialRepository pipelineConfig.MaterialRepository, ciTemplateRepository pipelineConfig.CiTemplateRepository, chartRepository chartRepoRepository.ChartRepository, userAuditService user2.UserAuditService, ciBuildConfigService pipeline.CiBuildConfigService, moduleRepository moduleRepo.ModuleRepository, serverDataStore *serverDataStore.ServerDataStore, helmAppClient client.HelmAppClient, InstalledAppRepository repository2.InstalledAppRepository, userAttributesRepository repository.UserAttributesRepository, - cloudProviderIdentifierService cloudProviderIdentifier.ProviderIdentifierService) (*TelemetryEventClientImplExtended, error) { + cloudProviderIdentifierService cloudProviderIdentifier.ProviderIdentifierService, + gitOpsConfigReadService config.GitOpsConfigReadService) (*TelemetryEventClientImplExtended, error) { cron := cron.New( cron.WithChain()) @@ -71,7 +73,6 @@ func NewTelemetryEventClientImplExtended(logger *zap.SugaredLogger, client *http appListingRepository: appListingRepository, ciPipelineRepository: ciPipelineRepository, pipelineRepository: pipelineRepository, - gitOpsConfigRepository: gitOpsConfigRepository, gitProviderRepository: gitProviderRepository, dockerArtifactStoreRepository: dockerArtifactStoreRepository, appRepository: appRepository, @@ -81,7 +82,7 @@ func NewTelemetryEventClientImplExtended(logger *zap.SugaredLogger, client *http ciTemplateRepository: ciTemplateRepository, chartRepository: chartRepository, ciBuildConfigService: ciBuildConfigService, - + gitOpsConfigReadService: gitOpsConfigReadService, TelemetryEventClientImpl: &TelemetryEventClientImpl{ cron: cron, logger: logger, @@ -233,8 +234,8 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string) return err } - gitOps, err := impl.gitOpsConfigRepository.GetAllGitOpsConfig() - if err != nil && err != pg.ErrNoRows { + gitOpsCount, err := impl.gitOpsConfigReadService.GetConfiguredGitOpsCount() + if err != nil { impl.logger.Errorw("exception caught inside telemetry summary event", "err", err) return err } @@ -308,7 +309,7 @@ func (impl *TelemetryEventClientImplExtended) SendSummaryEvent(eventType string) payload.CdCountPerDay = len(cdPipeline) payload.GitAccountsCount = len(gitAccounts) - payload.GitOpsCount = len(gitOps) + payload.GitOpsCount = gitOpsCount payload.HostURL = hostURL payload.DevtronGitVersion = devtronVersion.GitCommit payload.Build = build diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index dd3932c80d..7fd5f2b637 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -286,7 +286,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) diff --git a/internal/sql/repository/GitOpsConfigRepository.go b/internal/sql/repository/GitOpsConfigRepository.go index 557cfaf488..8e682f5bbf 100644 --- a/internal/sql/repository/GitOpsConfigRepository.go +++ b/internal/sql/repository/GitOpsConfigRepository.go @@ -32,7 +32,6 @@ type GitOpsConfigRepository interface { GetGitOpsConfigActive() (*GitOpsConfig, error) GetConnection() *pg.DB GetEmailIdFromActiveGitOpsConfig() (string, error) - IsGitOpsConfigured() (bool, error) } type GitOpsConfigRepositoryImpl struct { @@ -109,15 +108,3 @@ func (impl *GitOpsConfigRepositoryImpl) GetEmailIdFromActiveGitOpsConfig() (stri Where("active = ?", true).Select(&emailId) return emailId, err } - -func (impl *GitOpsConfigRepositoryImpl) IsGitOpsConfigured() (bool, error) { - gitOpsConfig, err := impl.GetGitOpsConfigActive() - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("Error while getting git-ops config from DB to check if git-ops configured or not", "err", err) - return false, err - } - if gitOpsConfig != nil && gitOpsConfig.Id > 0 { - return true, nil - } - return false, nil -} diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go index 68146304c0..a62122f071 100644 --- a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go @@ -539,7 +539,7 @@ func (impl AppStoreDeploymentCommonServiceImpl) GitOpsOperations(manifestRespons } space := regexp.MustCompile(`\s+`) appStoreName := space.ReplaceAllString(installAppVersionRequest.AppName, "-") - clonedDir := impl.gitFactory.GitWorkingDir + "" + appStoreName + clonedDir := git.GIT_WORKING_DIR + "" + appStoreName // Checking this is the first time chart has been pushed , if yes requirements.yaml has been already pushed with chart as there was sync-delay with github api. // step-2 commit dependencies and values in git diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/deployment/service/AppStoreDeploymentService.go index c8f4db9f2e..203933a51d 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService.go @@ -28,7 +28,6 @@ import ( openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/internal/constants" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" @@ -104,7 +103,6 @@ type AppStoreDeploymentServiceImpl struct { helmAppService client.HelmAppService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - gitOpsRepository repository2.GitOpsConfigRepository deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService @@ -117,7 +115,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService, appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService client.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, - installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, gitOpsRepository repository2.GitOpsConfigRepository, + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, gitOpsConfigReadService config.GitOpsConfigReadService, gitOperationService git.GitOperationService) *AppStoreDeploymentServiceImpl { @@ -137,7 +135,6 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep helmAppService: helmAppService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, installedAppRepositoryHistory: installedAppRepositoryHistory, - gitOpsRepository: gitOpsRepository, deploymentTypeConfig: deploymentTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, @@ -149,17 +146,11 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { var isInternalUse = impl.deploymentTypeConfig.IsInternalUse - - isGitOpsConfigured := false - gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() + if err != nil { + impl.logger.Errorw("error while checking if gitOps is configured", "err", err) return nil, err } - if gitOpsConfig != nil && gitOpsConfig.Id > 0 { - isGitOpsConfigured = true - } - if isInternalUse && !isGitOpsConfigured && installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD { impl.logger.Errorw("gitops not configured but selected for CD") err := &util.ApiError{ diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go index 5566598f01..438e8adbf1 100644 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ b/pkg/appStore/deployment/service/InstalledAppService.go @@ -69,7 +69,6 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" bean2 "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/bean" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" @@ -108,7 +107,6 @@ type InstalledAppServiceImpl struct { chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository envService cluster2.EnvironmentService aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository userService user.UserService appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService @@ -131,13 +129,10 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, - appRepository app.AppRepository, - acdClient application2.ServiceClient, - appStoreValuesService service.AppStoreValuesService, - pubsubClient *pubsub.PubSubClientServiceImpl, + appRepository app.AppRepository, acdClient application2.ServiceClient, + appStoreValuesService service.AppStoreValuesService, pubsubClient *pubsub.PubSubClientServiceImpl, chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository, - envService cluster2.EnvironmentService, - aCDAuthConfig *util2.ACDAuthConfig, gitOpsRepository repository3.GitOpsConfigRepository, userService user.UserService, + envService cluster2.EnvironmentService, aCDAuthConfig *util2.ACDAuthConfig, userService user.UserService, appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService, appStoreDeploymentService AppStoreDeploymentService, installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, @@ -161,7 +156,6 @@ func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, chartGroupDeploymentRepository: chartGroupDeploymentRepository, envService: envService, aCDAuthConfig: aCDAuthConfig, - gitOpsRepository: gitOpsRepository, userService: userService, appStoreDeploymentService: appStoreDeploymentService, appStoreDeploymentFullModeService: appStoreDeploymentFullModeService, diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go index 2c2f90e7be..7bf2ca08c3 100644 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ b/pkg/appStore/deployment/service/InstalledAppService_test.go @@ -8,7 +8,6 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" @@ -43,7 +42,6 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { ArgoK8sClient argocdServer.ArgoK8sClient gitFactory *git.GitFactory aCDAuthConfig *util2.ACDAuthConfig - gitOpsRepository repository3.GitOpsConfigRepository userService user.UserService appStoreDeploymentService AppStoreDeploymentService appStoreDeploymentFullModeService appStoreDeploymentFullMode.AppStoreDeploymentFullModeService @@ -66,8 +64,6 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { impl := &InstalledAppServiceImpl{ logger: tt.fields.logger, installedAppRepository: tt.fields.installedAppRepository, - chartTemplateService: tt.fields.chartTemplateService, - repositoryService: tt.fields.repositoryService, appStoreApplicationVersionRepository: tt.fields.appStoreApplicationVersionRepository, environmentRepository: tt.fields.environmentRepository, teamRepository: tt.fields.teamRepository, @@ -75,13 +71,9 @@ func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { acdClient: tt.fields.acdClient, appStoreValuesService: tt.fields.appStoreValuesService, pubsubClient: tt.fields.pubsubClient, - tokenCache: tt.fields.tokenCache, chartGroupDeploymentRepository: tt.fields.chartGroupDeploymentRepository, envService: tt.fields.envService, - ArgoK8sClient: tt.fields.ArgoK8sClient, - gitFactory: tt.fields.gitFactory, aCDAuthConfig: tt.fields.aCDAuthConfig, - gitOpsRepository: tt.fields.gitOpsRepository, userService: tt.fields.userService, appStoreDeploymentService: tt.fields.appStoreDeploymentService, appStoreDeploymentFullModeService: tt.fields.appStoreDeploymentFullModeService, diff --git a/pkg/cluster/ClusterServiceExtended.go b/pkg/cluster/ClusterServiceExtended.go index 5a11aee3a0..e18865e2b9 100644 --- a/pkg/cluster/ClusterServiceExtended.go +++ b/pkg/cluster/ClusterServiceExtended.go @@ -3,6 +3,7 @@ package cluster import ( "context" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "net/http" "strings" "time" @@ -10,7 +11,6 @@ import ( cluster3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/devtron-labs/common-lib/utils/k8s" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" repository5 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/k8s/informer" @@ -26,12 +26,12 @@ import ( // extends ClusterServiceImpl and enhances method of ClusterService with full mode specific errors type ClusterServiceImplExtended struct { - environmentRepository repository.EnvironmentRepository - grafanaClient grafana.GrafanaClient - installedAppRepository repository2.InstalledAppRepository - clusterServiceCD cluster2.ServiceClient - K8sInformerFactory informer.K8sInformerFactory - gitOpsRepository repository3.GitOpsConfigRepository + environmentRepository repository.EnvironmentRepository + grafanaClient grafana.GrafanaClient + installedAppRepository repository2.InstalledAppRepository + clusterServiceCD cluster2.ServiceClient + K8sInformerFactory informer.K8sInformerFactory + gitOpsConfigReadService config.GitOpsConfigReadService *ClusterServiceImpl } @@ -39,14 +39,14 @@ func NewClusterServiceImplExtended(repository repository.ClusterRepository, envi grafanaClient grafana.GrafanaClient, logger *zap.SugaredLogger, installedAppRepository repository2.InstalledAppRepository, K8sUtil *k8s.K8sServiceImpl, clusterServiceCD cluster2.ServiceClient, K8sInformerFactory informer.K8sInformerFactory, - gitOpsRepository repository3.GitOpsConfigRepository, userAuthRepository repository5.UserAuthRepository, - userRepository repository5.UserRepository, roleGroupRepository repository5.RoleGroupRepository) *ClusterServiceImplExtended { + userAuthRepository repository5.UserAuthRepository, + userRepository repository5.UserRepository, roleGroupRepository repository5.RoleGroupRepository, + gitOpsConfigReadService config.GitOpsConfigReadService) *ClusterServiceImplExtended { clusterServiceExt := &ClusterServiceImplExtended{ environmentRepository: environmentRepository, grafanaClient: grafanaClient, installedAppRepository: installedAppRepository, clusterServiceCD: clusterServiceCD, - gitOpsRepository: gitOpsRepository, ClusterServiceImpl: &ClusterServiceImpl{ clusterRepository: repository, logger: logger, @@ -157,7 +157,7 @@ func (impl *ClusterServiceImplExtended) FindAllExceptVirtual() ([]*ClusterBean, } func (impl *ClusterServiceImplExtended) Update(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error) { - isGitOpsConfigured, err1 := impl.gitOpsRepository.IsGitOpsConfigured() + isGitOpsConfigured, err1 := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err1 != nil { return nil, err1 } @@ -337,7 +337,7 @@ func (impl *ClusterServiceImplExtended) CreateGrafanaDataSource(clusterBean *Clu } func (impl *ClusterServiceImplExtended) Save(ctx context.Context, bean *ClusterBean, userId int32) (*ClusterBean, error) { - isGitOpsConfigured, err := impl.gitOpsRepository.IsGitOpsConfigured() + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err != nil { return nil, err } diff --git a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go index 6daf96c6d3..851cb22c48 100644 --- a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go +++ b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go @@ -20,6 +20,7 @@ type GitOpsConfigReadService interface { GetGitOpsRepoNameFromUrl(gitRepoUrl string) string GetBitbucketMetadata() (*bean.BitbucketProviderMetadata, error) GetGitOpsConfigActive() (*bean2.GitOpsConfigDto, error) + GetConfiguredGitOpsCount() (int, error) } type GitOpsConfigReadServiceImpl struct { @@ -131,3 +132,14 @@ func (impl *GitOpsConfigReadServiceImpl) GetGitOpsConfigActive() (*bean2.GitOpsC } return config, err } + +func (impl *GitOpsConfigReadServiceImpl) GetConfiguredGitOpsCount() (int, error) { + count := 0 + models, err := impl.gitOpsRepository.GetAllGitOpsConfig() + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error, GetGitOpsConfigActive", "err", err) + return count, err + } + count = len(models) + return count, nil +} diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index 6fa5f879d4..0f9c9e3a18 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -90,21 +90,16 @@ func (impl *GitOperationServiceImpl) CreateGitRepositoryForApp(gitOpsRepoName, b func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenceTemplate, version, tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) { chartDir := fmt.Sprintf("%s-%s", gitOpsRepoName, impl.chartTemplateService.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) - return err - } - } else { - err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) - if err != nil { - impl.logger.Errorw("error in pulling git repo", "url", repoUrl, "err", err) - return err - } + clonedDir, err := impl.GetClonedDir(chartDir, repoUrl) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return err + } + err = impl.GitPull(clonedDir, repoUrl, gitOpsRepoName) + if err != nil { + impl.logger.Errorw("error in pulling git repo", "url", repoUrl, "err", err) + return err } - dir := filepath.Join(clonedDir, referenceTemplate, version) pushChartToGit := true @@ -262,18 +257,15 @@ func (impl *GitOperationServiceImpl) createAndPushToGitChartProxy(appStoreName, } chartDir := fmt.Sprintf("%s-%s", chartProxyReq.AppName, impl.chartTemplateService.GetDir()) - clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) - if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - clonedDir, err = impl.gitFactory.GitService.Clone(repoUrl, chartDir) - if err != nil { - impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) - return nil, err - } - } else { - err = impl.GitPull(clonedDir, repoUrl, appStoreName) - if err != nil { - return nil, err - } + clonedDir, err := impl.GetClonedDir(chartDir, repoUrl) + if err != nil { + impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) + return nil, err + } + + err = impl.GitPull(clonedDir, repoUrl, appStoreName) + if err != nil { + return nil, err } acdAppName := fmt.Sprintf("%s-%s", chartProxyReq.AppName, envName) diff --git a/pkg/deployment/gitOps/git/GitService.go b/pkg/deployment/gitOps/git/GitService.go index d80e550a6f..6f0f3815d1 100644 --- a/pkg/deployment/gitOps/git/GitService.go +++ b/pkg/deployment/gitOps/git/GitService.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "github.com/devtron-labs/devtron/util" - "io/ioutil" "net/url" "path/filepath" "time" @@ -63,7 +62,6 @@ type GitClient interface { type GitFactory struct { Client GitClient GitService GitService - GitWorkingDir string logger *zap.SugaredLogger gitOpsRepository repository.GitOpsConfigRepository gitCliUtil *GitCliUtil @@ -150,7 +148,6 @@ func (factory *GitFactory) NewClientForValidation(gitOpsConfig *bean2.GitOpsConf GitlabGroupId: gitOpsConfig.GitLabGroupId, GitToken: gitOpsConfig.Token, GitUserName: gitOpsConfig.Username, - GitWorkingDir: GIT_WORKING_DIR, GithubOrganization: gitOpsConfig.GitHubOrgId, GitProvider: gitOpsConfig.Provider, GitHost: gitOpsConfig.Host, @@ -186,7 +183,6 @@ func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOps logger: logger, GitService: gitService, gitOpsRepository: gitOpsRepository, - GitWorkingDir: cfg.GitWorkingDir, gitCliUtil: gitCliUtil, }, nil } @@ -196,7 +192,6 @@ type GitConfig struct { GitlabGroupPath string //local GitToken string //not null // public GitUserName string //not null // public - GitWorkingDir string //working directory for git. might use pvc GithubOrganization string GitProvider string // SUPPORTED VALUES GITHUB, GITLAB GitHost string @@ -225,7 +220,6 @@ func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfi GitlabGroupId: gitOpsConfig.GitLabGroupId, GitToken: gitOpsConfig.Token, GitUserName: gitOpsConfig.Username, - GitWorkingDir: GIT_WORKING_DIR, GithubOrganization: gitOpsConfig.GitHubOrgId, GitProvider: gitOpsConfig.Provider, GitHost: gitOpsConfig.Host, @@ -271,15 +265,12 @@ type ChartConfig struct { type GitService interface { Clone(url, targetDir string) (clonedDir string, err error) CommitAndPushAllChanges(repoRoot, commitMsg, name, emailId string) (commitHash string, err error) - ForceResetHead(repoRoot string) (err error) - CommitValues(config *ChartConfig) (commitHash string, err error) GetCloneDirectory(targetDir string) (clonedDir string) Pull(repoRoot string) (err error) } type GitServiceImpl struct { Auth *http.BasicAuth - config *GitConfig logger *zap.SugaredLogger gitCliUtil *GitCliUtil } @@ -289,18 +280,16 @@ func NewGitServiceImpl(config *GitConfig, logger *zap.SugaredLogger, GitCliUtil return &GitServiceImpl{ Auth: auth, logger: logger, - config: config, gitCliUtil: GitCliUtil, } } func (impl GitServiceImpl) GetCloneDirectory(targetDir string) (clonedDir string) { - start := time.Now() defer func() { util.TriggerGitOpsMetrics("GetCloneDirectory", "GitService", start, nil) }() - clonedDir = filepath.Join(impl.config.GitWorkingDir, targetDir) + clonedDir = filepath.Join(GIT_WORKING_DIR, targetDir) return clonedDir } @@ -310,7 +299,7 @@ func (impl GitServiceImpl) Clone(url, targetDir string) (clonedDir string, err e util.TriggerGitOpsMetrics("Clone", "GitService", start, err) }() impl.logger.Debugw("git checkout ", "url", url, "dir", targetDir) - clonedDir = filepath.Join(impl.config.GitWorkingDir, targetDir) + clonedDir = filepath.Join(GIT_WORKING_DIR, targetDir) _, errorMsg, err := impl.gitCliUtil.Clone(clonedDir, url, impl.Auth.Username, impl.Auth.Password) if err != nil { impl.logger.Errorw("error in git checkout", "url", url, "targetDir", targetDir, "err", err) @@ -373,45 +362,6 @@ func (impl GitServiceImpl) getRepoAndWorktree(repoRoot string) (*git.Repository, return r, w, err } -func (impl GitServiceImpl) ForceResetHead(repoRoot string) (err error) { - start := time.Now() - defer func() { - util.TriggerGitOpsMetrics("ForceResetHead", "GitService", start, err) - }() - _, workTree, err := impl.getRepoAndWorktree(repoRoot) - if err != nil { - return err - } - err = workTree.Reset(&git.ResetOptions{Mode: git.HardReset}) - if err != nil { - return err - } - err = workTree.Pull(&git.PullOptions{ - Auth: impl.Auth, - Force: true, - SingleBranch: true, - }) - return err -} - -func (impl GitServiceImpl) CommitValues(config *ChartConfig) (commitHash string, err error) { - //TODO acquire lock - start := time.Now() - defer func() { - util.TriggerGitOpsMetrics("CommitValues", "GitService", start, err) - }() - gitDir := filepath.Join(impl.config.GitWorkingDir, config.ChartName) - if err != nil { - return "", err - } - err = ioutil.WriteFile(filepath.Join(gitDir, config.ChartLocation, config.FileName), []byte(config.FileContent), 0600) - if err != nil { - return "", err - } - hash, err := impl.CommitAndPushAllChanges(gitDir, config.ReleaseMessage, "devtron bot", "devtron-bot@devtron.ai") - return hash, err -} - func (impl GitServiceImpl) Pull(repoRoot string) (err error) { start := time.Now() defer func() { diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index 923b31a65d..06e8f7052e 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -322,7 +322,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req } // if git-ops config is created/saved successfully (just before transaction commit) and this was first git-ops config, then upsert clusters in acd - isGitOpsConfigured, err := impl.gitOpsRepository.IsGitOpsConfigured() + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err != nil { return nil, err } diff --git a/util/argo/ArgoUserService.go b/util/argo/ArgoUserService.go index 80af547c6c..75715dd704 100644 --- a/util/argo/ArgoUserService.go +++ b/util/argo/ArgoUserService.go @@ -9,10 +9,9 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/connection" "github.com/devtron-labs/devtron/client/argocdServer/session" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" util2 "github.com/devtron-labs/devtron/util" - "github.com/go-pg/pg" "go.uber.org/zap" "golang.org/x/crypto/bcrypt" apiv1 "k8s.io/api/core/v1" @@ -48,22 +47,25 @@ type ArgoUserServiceImpl struct { clusterService cluster.ClusterService devtronSecretConfig *util2.DevtronSecretConfig runTimeConfig *client.RuntimeConfig - gitOpsRepository repository.GitOpsConfigRepository argoCDConnectionManager connection.ArgoCDConnectionManager versionService argocdServer.VersionService k8sUtil *k8s.K8sServiceImpl + gitOpsConfigReadService config.GitOpsConfigReadService } -func NewArgoUserServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.ClusterService, devtronSecretConfig *util2.DevtronSecretConfig, runTimeConfig *client.RuntimeConfig, gitOpsRepository repository.GitOpsConfigRepository, argoCDConnectionManager connection.ArgoCDConnectionManager, versionService argocdServer.VersionService, k8sUtil *k8s.K8sServiceImpl) (*ArgoUserServiceImpl, error) { +func NewArgoUserServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.ClusterService, + devtronSecretConfig *util2.DevtronSecretConfig, runTimeConfig *client.RuntimeConfig, + argoCDConnectionManager connection.ArgoCDConnectionManager, versionService argocdServer.VersionService, + k8sUtil *k8s.K8sServiceImpl, gitOpsConfigReadService config.GitOpsConfigReadService) (*ArgoUserServiceImpl, error) { argoUserServiceImpl := &ArgoUserServiceImpl{ logger: Logger, clusterService: clusterService, devtronSecretConfig: devtronSecretConfig, runTimeConfig: runTimeConfig, - gitOpsRepository: gitOpsRepository, argoCDConnectionManager: argoCDConnectionManager, versionService: versionService, k8sUtil: k8sUtil, + gitOpsConfigReadService: gitOpsConfigReadService, } if !runTimeConfig.LocalDevMode { go argoUserServiceImpl.ValidateGitOpsAndGetOrUpdateArgoCdUserDetail() @@ -72,7 +74,7 @@ func NewArgoUserServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.Cl } func (impl *ArgoUserServiceImpl) ValidateGitOpsAndGetOrUpdateArgoCdUserDetail() string { - isGitOpsConfigured, err := impl.gitOpsRepository.IsGitOpsConfigured() + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err != nil || !isGitOpsConfigured { return "" } @@ -163,15 +165,11 @@ func (impl *ArgoUserServiceImpl) createNewArgoCdTokenForDevtron(username, passwo // note: this function also called for no gitops case, where apps are installed via helm func (impl *ArgoUserServiceImpl) GetLatestDevtronArgoCdUserToken() (string, error) { - isGitOpsConfigured := false - gitOpsConfig, err := impl.gitOpsRepository.GetGitOpsConfigActive() - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("GetGitOpsConfigActive, error while getting", "err", err) + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() + if err != nil { + impl.logger.Errorw("error while checking if gitOps is configured", "err", err) return "", err } - if gitOpsConfig != nil && gitOpsConfig.Id > 0 { - isGitOpsConfigured = true - } if !isGitOpsConfigured { //here acd token only required in context for argo cd calls return "", nil diff --git a/wire_gen.go b/wire_gen.go index 09d7f89c6e..20d32eb2d1 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -228,24 +228,12 @@ func InitializeApp() (*App, error) { serviceClientImpl := cluster.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) v := informer.NewGlobalMapClusterNamespace() k8sInformerFactoryImpl := informer.NewK8sInformerFactoryImpl(sugaredLogger, v, runtimeConfig, k8sServiceImpl) - gitOpsConfigRepositoryImpl := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) defaultAuthPolicyRepositoryImpl := repository4.NewDefaultAuthPolicyRepositoryImpl(db, sugaredLogger) defaultAuthRoleRepositoryImpl := repository4.NewDefaultAuthRoleRepositoryImpl(db, sugaredLogger) userAuthRepositoryImpl := repository4.NewUserAuthRepositoryImpl(db, sugaredLogger, defaultAuthPolicyRepositoryImpl, defaultAuthRoleRepositoryImpl) userRepositoryImpl := repository4.NewUserRepositoryImpl(db, sugaredLogger) roleGroupRepositoryImpl := repository4.NewRoleGroupRepositoryImpl(db, sugaredLogger) - clusterServiceImplExtended := cluster2.NewClusterServiceImplExtended(clusterRepositoryImpl, environmentRepositoryImpl, grafanaClientImpl, sugaredLogger, installedAppRepositoryImpl, k8sServiceImpl, serviceClientImpl, k8sInformerFactoryImpl, gitOpsConfigRepositoryImpl, userAuthRepositoryImpl, userRepositoryImpl, roleGroupRepositoryImpl) - helmClientConfig, err := client3.GetConfig() - if err != nil { - return nil, err - } - helmAppClientImpl := client3.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) - pumpImpl := connector.NewPumpImpl(sugaredLogger) - teamRepositoryImpl := team.NewTeamRepositoryImpl(db) - appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) - enforcerUtilHelmImpl := rbac.NewEnforcerUtilHelmImpl(sugaredLogger, clusterRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, installedAppRepositoryImpl) - serverDataStoreServerDataStore := serverDataStore.InitServerDataStore() - appStoreApplicationVersionRepositoryImpl := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) + gitOpsConfigRepositoryImpl := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) k8sClient, err := client2.NewK8sClient(runtimeConfig) if err != nil { return nil, err @@ -260,7 +248,6 @@ func InitializeApp() (*App, error) { } apiTokenSecretStore := apiTokenAuth.InitApiTokenSecretStore() sessionManager := middleware.NewSessionManager(settings, dexConfig, apiTokenSecretStore) - loginService := middleware.NewUserLogin(sessionManager, k8sClient) rbacPolicyDataRepositoryImpl := repository4.NewRbacPolicyDataRepositoryImpl(sugaredLogger, db) rbacRoleDataRepositoryImpl := repository4.NewRbacRoleDataRepositoryImpl(sugaredLogger, db) rbacDataCacheFactoryImpl := repository4.NewRbacDataCacheFactoryImpl(sugaredLogger, rbacPolicyDataRepositoryImpl, rbacRoleDataRepositoryImpl) @@ -268,6 +255,24 @@ func InitializeApp() (*App, error) { userAuditRepositoryImpl := repository4.NewUserAuditRepositoryImpl(db) userAuditServiceImpl := user.NewUserAuditServiceImpl(sugaredLogger, userAuditRepositoryImpl) userServiceImpl := user.NewUserServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, sessionManager, userCommonServiceImpl, userAuditServiceImpl) + globalEnvVariables, err := util2.GetGlobalEnvVariables() + if err != nil { + return nil, err + } + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) + clusterServiceImplExtended := cluster2.NewClusterServiceImplExtended(clusterRepositoryImpl, environmentRepositoryImpl, grafanaClientImpl, sugaredLogger, installedAppRepositoryImpl, k8sServiceImpl, serviceClientImpl, k8sInformerFactoryImpl, userAuthRepositoryImpl, userRepositoryImpl, roleGroupRepositoryImpl, gitOpsConfigReadServiceImpl) + helmClientConfig, err := client3.GetConfig() + if err != nil { + return nil, err + } + helmAppClientImpl := client3.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) + pumpImpl := connector.NewPumpImpl(sugaredLogger) + teamRepositoryImpl := team.NewTeamRepositoryImpl(db) + appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) + enforcerUtilHelmImpl := rbac.NewEnforcerUtilHelmImpl(sugaredLogger, clusterRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, installedAppRepositoryImpl) + serverDataStoreServerDataStore := serverDataStore.InitServerDataStore() + appStoreApplicationVersionRepositoryImpl := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) + loginService := middleware.NewUserLogin(sessionManager, k8sClient) userAuthServiceImpl := user.NewUserAuthServiceImpl(userAuthRepositoryImpl, sessionManager, loginService, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userServiceImpl) environmentServiceImpl := cluster2.NewEnvironmentServiceImpl(environmentRepositoryImpl, clusterServiceImplExtended, sugaredLogger, k8sServiceImpl, k8sInformerFactoryImpl, userAuthServiceImpl, attributesRepositoryImpl) helmReleaseConfig, err := client3.GetHelmReleaseConfig() @@ -309,7 +314,7 @@ func InitializeApp() (*App, error) { return nil, err } versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) - argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, gitOpsConfigRepositoryImpl, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl) + argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl, gitOpsConfigReadServiceImpl) if err != nil { return nil, err } @@ -328,10 +333,6 @@ func InitializeApp() (*App, error) { enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) - globalEnvVariables, err := util2.GetGlobalEnvVariables() - if err != nil { - return nil, err - } scopedVariableRepositoryImpl := repository6.NewScopedVariableRepository(db, sugaredLogger) qualifiersMappingRepositoryImpl, err := resourceQualifiers.NewQualifiersMappingRepositoryImpl(db, sugaredLogger) if err != nil { @@ -371,7 +372,6 @@ func InitializeApp() (*App, error) { Logger: sugaredLogger, } chartRefServiceImpl := chartRef.NewChartRefServiceImpl(sugaredLogger, chartRefRepositoryImpl, chartTemplateServiceImpl, utilMergeUtil) - gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) gitCliUtil := git.NewGitCliUtil(sugaredLogger) gitFactory, err := git.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) if err != nil { @@ -547,7 +547,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, gitOpsConfigRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) k8sResourceHistoryRepositoryImpl := repository16.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) @@ -557,7 +557,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, acdAuthConfig, gitOpsConfigRepositoryImpl, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + installedAppServiceImpl, err := service2.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, acdAuthConfig, userServiceImpl, appStoreDeploymentFullModeServiceImpl, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, pipelineStatusTimelineServiceImpl, appStoreDeploymentCommonServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) if err != nil { return nil, err } @@ -716,7 +716,7 @@ func InitializeApp() (*App, error) { return nil, err } providerIdentifierServiceImpl := providerIdentifier.NewProviderIdentifierServiceImpl(sugaredLogger) - telemetryEventClientImplExtended, err := telemetry.NewTelemetryEventClientImplExtended(sugaredLogger, httpClient, clusterServiceImplExtended, k8sServiceImpl, acdAuthConfig, environmentServiceImpl, userServiceImpl, appListingRepositoryImpl, posthogClient, ciPipelineRepositoryImpl, pipelineRepositoryImpl, gitOpsConfigRepositoryImpl, gitProviderRepositoryImpl, attributesRepositoryImpl, ssoLoginServiceImpl, appRepositoryImpl, ciWorkflowRepositoryImpl, cdWorkflowRepositoryImpl, dockerArtifactStoreRepositoryImpl, materialRepositoryImpl, ciTemplateRepositoryImpl, chartRepositoryImpl, userAuditServiceImpl, ciBuildConfigServiceImpl, moduleRepositoryImpl, serverDataStoreServerDataStore, helmAppClientImpl, installedAppRepositoryImpl, userAttributesRepositoryImpl, providerIdentifierServiceImpl) + telemetryEventClientImplExtended, err := telemetry.NewTelemetryEventClientImplExtended(sugaredLogger, httpClient, clusterServiceImplExtended, k8sServiceImpl, acdAuthConfig, environmentServiceImpl, userServiceImpl, appListingRepositoryImpl, posthogClient, ciPipelineRepositoryImpl, pipelineRepositoryImpl, gitProviderRepositoryImpl, attributesRepositoryImpl, ssoLoginServiceImpl, appRepositoryImpl, ciWorkflowRepositoryImpl, cdWorkflowRepositoryImpl, dockerArtifactStoreRepositoryImpl, materialRepositoryImpl, ciTemplateRepositoryImpl, chartRepositoryImpl, userAuditServiceImpl, ciBuildConfigServiceImpl, moduleRepositoryImpl, serverDataStoreServerDataStore, helmAppClientImpl, installedAppRepositoryImpl, userAttributesRepositoryImpl, providerIdentifierServiceImpl, gitOpsConfigReadServiceImpl) if err != nil { return nil, err } From 6e83a5c8f4779f239b65906dde8c58bddb11bd89 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 14:29:03 +0530 Subject: [PATCH 36/83] refactored gitOpsRepository usages --- Wire.go | 2 - cmd/external-app/wire.go | 3 - pkg/deployment/gitOps/git/GitService.go | 37 +++++------ pkg/deployment/gitOps/git/GitServiceAzure.go | 45 +++---------- .../gitOps/git/GitServiceBitbucket.go | 63 +++---------------- pkg/deployment/gitOps/git/GitServiceGithub.go | 42 +++---------- pkg/deployment/gitOps/git/GitServiceGitlab.go | 23 ------- pkg/deployment/gitOps/wire_gitOps.go | 4 ++ pkg/gitops/GitOpsConfigService.go | 4 +- 9 files changed, 48 insertions(+), 175 deletions(-) diff --git a/Wire.go b/Wire.go index d3b14ac7cb..136cb0cf7e 100644 --- a/Wire.go +++ b/Wire.go @@ -637,8 +637,6 @@ func InitializeApp() (*App, error) { wire.Bind(new(restHandler.GitOpsConfigRestHandler), new(*restHandler.GitOpsConfigRestHandlerImpl)), gitops.NewGitOpsConfigServiceImpl, wire.Bind(new(gitops.GitOpsConfigService), new(*gitops.GitOpsConfigServiceImpl)), - repository.NewGitOpsConfigRepositoryImpl, - wire.Bind(new(repository.GitOpsConfigRepository), new(*repository.GitOpsConfigRepositoryImpl)), router.NewAttributesRouterImpl, wire.Bind(new(router.AttributesRouter), new(*router.AttributesRouterImpl)), diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index da0f16094b..fb504e2c7d 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -154,9 +154,6 @@ func InitializeApp() (*App, error) { wire.Bind(new(dashboardEvent.DashboardTelemetryRouter), new(*dashboardEvent.DashboardTelemetryRouterImpl)), - repository.NewGitOpsConfigRepositoryImpl, - wire.Bind(new(repository.GitOpsConfigRepository), new(*repository.GitOpsConfigRepositoryImpl)), - //binding argoUserService to helm via dummy implementation(HelmUserServiceImpl) argo.NewHelmUserServiceImpl, wire.Bind(new(argo.ArgoUserService), new(*argo.HelmUserServiceImpl)), diff --git a/pkg/deployment/gitOps/git/GitService.go b/pkg/deployment/gitOps/git/GitService.go index 6f0f3815d1..80d8b48cb3 100644 --- a/pkg/deployment/gitOps/git/GitService.go +++ b/pkg/deployment/gitOps/git/GitService.go @@ -56,15 +56,13 @@ type GitClient interface { GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error) DeleteRepository(config *bean2.GitOpsConfigDto) error CreateReadme(config *bean2.GitOpsConfigDto) (string, error) - GetCommits(repoName, projectName string) ([]*GitCommitDto, error) } type GitFactory struct { - Client GitClient - GitService GitService - logger *zap.SugaredLogger - gitOpsRepository repository.GitOpsConfigRepository - gitCliUtil *GitCliUtil + Client GitClient + GitService GitService + logger *zap.SugaredLogger + gitCliUtil *GitCliUtil } type DetailedErrorGitOpsConfigActions struct { @@ -80,20 +78,20 @@ type GitCommitDto struct { CommitTime time.Time `json:"commitTime"` } -func (factory *GitFactory) Reload() error { +func (factory *GitFactory) Reload(gitOpsRepository repository.GitOpsConfigRepository) error { var err error start := time.Now() defer func() { util.TriggerGitOpsMetrics("Reload", "GitService", start, err) }() factory.logger.Infow("reloading gitops details") - cfg, err := GetGitConfig(factory.gitOpsRepository) + cfg, err := GetGitConfig(gitOpsRepository) if err != nil { return err } gitService := NewGitServiceImpl(cfg, factory.logger, factory.gitCliUtil) factory.GitService = gitService - client, err := NewGitOpsClient(cfg, factory.logger, gitService, factory.gitOpsRepository) + client, err := NewGitOpsClient(cfg, factory.logger, gitService) if err != nil { return err } @@ -158,7 +156,7 @@ func (factory *GitFactory) NewClientForValidation(gitOpsConfig *bean2.GitOpsConf } gitService := NewGitServiceImpl(cfg, factory.logger, factory.gitCliUtil) //factory.GitService = GitService - client, err := NewGitOpsClient(cfg, factory.logger, gitService, factory.gitOpsRepository) + client, err := NewGitOpsClient(cfg, factory.logger, gitService) if err != nil { return client, gitService, err } @@ -174,16 +172,15 @@ func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOps return nil, err } gitService := NewGitServiceImpl(cfg, logger, gitCliUtil) - client, err := NewGitOpsClient(cfg, logger, gitService, gitOpsRepository) + client, err := NewGitOpsClient(cfg, logger, gitService) if err != nil { logger.Errorw("error in creating gitOps client", "err", err, "gitProvider", cfg.GitProvider) } return &GitFactory{ - Client: client, - logger: logger, - GitService: gitService, - gitOpsRepository: gitOpsRepository, - gitCliUtil: gitCliUtil, + Client: client, + logger: logger, + GitService: gitService, + gitCliUtil: gitCliUtil, }, nil } @@ -231,18 +228,18 @@ func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfi return cfg, err } -func NewGitOpsClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService, gitOpsConfigRepository repository.GitOpsConfigRepository) (GitClient, error) { +func NewGitOpsClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { if config.GitProvider == GITLAB_PROVIDER { gitLabClient, err := NewGitLabClient(config, logger, gitService) return gitLabClient, err } else if config.GitProvider == GITHUB_PROVIDER { - gitHubClient, err := NewGithubClient(config.GitHost, config.GitToken, config.GithubOrganization, logger, gitService, gitOpsConfigRepository) + gitHubClient, err := NewGithubClient(config.GitHost, config.GitToken, config.GithubOrganization, logger, gitService) return gitHubClient, err } else if config.GitProvider == AZURE_DEVOPS_PROVIDER { - gitAzureClient, err := NewGitAzureClient(config.AzureToken, config.GitHost, config.AzureProject, logger, gitService, gitOpsConfigRepository) + gitAzureClient, err := NewGitAzureClient(config.AzureToken, config.GitHost, config.AzureProject, logger, gitService) return gitAzureClient, err } else if config.GitProvider == BITBUCKET_PROVIDER { - gitBitbucketClient := NewGitBitbucketClient(config.GitUserName, config.GitToken, config.GitHost, logger, gitService, gitOpsConfigRepository) + gitBitbucketClient := NewGitBitbucketClient(config.GitUserName, config.GitToken, config.GitHost, logger, gitService) return gitBitbucketClient, nil } else { logger.Errorw("no gitops config provided, gitops will not work ") diff --git a/pkg/deployment/gitOps/git/GitServiceAzure.go b/pkg/deployment/gitOps/git/GitServiceAzure.go index 1bb7dfbbc7..b1fd155d1e 100644 --- a/pkg/deployment/gitOps/git/GitServiceAzure.go +++ b/pkg/deployment/gitOps/git/GitServiceAzure.go @@ -4,7 +4,6 @@ import ( "context" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/microsoft/azure-devops-go-api/azuredevops/git" "go.uber.org/zap" @@ -13,11 +12,10 @@ import ( ) type GitAzureClient struct { - client *git.Client - logger *zap.SugaredLogger - project string - gitService GitService - gitOpsConfigRepository repository.GitOpsConfigRepository + client *git.Client + logger *zap.SugaredLogger + project string + gitService GitService } func (impl GitAzureClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error) { @@ -31,8 +29,7 @@ func (impl GitAzureClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl st } } -func NewGitAzureClient(token string, host string, project string, logger *zap.SugaredLogger, gitService GitService, - gitOpsConfigRepository repository.GitOpsConfigRepository) (GitAzureClient, error) { +func NewGitAzureClient(token string, host string, project string, logger *zap.SugaredLogger, gitService GitService) (GitAzureClient, error) { ctx := context.Background() // Create a connection to your organization connection := azuredevops.NewPatConnection(host, token) @@ -42,11 +39,10 @@ func NewGitAzureClient(token string, host string, project string, logger *zap.Su logger.Errorw("error in creating azure gitops client, gitops related operation might fail", "err", err) } return GitAzureClient{ - client: &coreClient, - project: project, - logger: logger, - gitService: gitService, - gitOpsConfigRepository: gitOpsConfigRepository, + client: &coreClient, + project: project, + logger: logger, + gitService: gitService, }, err } func (impl GitAzureClient) DeleteRepository(config *bean2.GitOpsConfigDto) error { @@ -298,26 +294,3 @@ func (impl GitAzureClient) ensureProjectAvailabilityOnSsh(projectName string, re } return false, nil } - -func (impl GitAzureClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error) { - azureClient := *impl.client - getCommitsArgs := git.GetCommitsArgs{ - RepositoryId: &repoName, - Project: &projectName, - } - gitCommits, err := azureClient.GetCommits(context.Background(), getCommitsArgs) - if err != nil { - impl.logger.Errorw("error in getting commits", "err", err, "repoName", repoName, "projectName", projectName) - return nil, err - } - var gitCommitsDto []*GitCommitDto - for _, gitCommit := range *gitCommits { - gitCommitDto := &GitCommitDto{ - CommitHash: *gitCommit.CommitId, - AuthorName: *gitCommit.Author.Name, - CommitTime: gitCommit.Author.Date.Time, - } - gitCommitsDto = append(gitCommitsDto, gitCommitDto) - } - return gitCommitsDto, nil -} diff --git a/pkg/deployment/gitOps/git/GitServiceBitbucket.go b/pkg/deployment/gitOps/git/GitServiceBitbucket.go index ec9296f84f..a7f6cd1693 100644 --- a/pkg/deployment/gitOps/git/GitServiceBitbucket.go +++ b/pkg/deployment/gitOps/git/GitServiceBitbucket.go @@ -3,8 +3,6 @@ package git import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/go-pg/pg" "github.com/ktrysmt/go-bitbucket" "go.uber.org/zap" "io/ioutil" @@ -22,21 +20,18 @@ const ( ) type GitBitbucketClient struct { - client *bitbucket.Client - logger *zap.SugaredLogger - gitService GitService - gitOpsConfigRepository repository.GitOpsConfigRepository + client *bitbucket.Client + logger *zap.SugaredLogger + gitService GitService } -func NewGitBitbucketClient(username, token, host string, logger *zap.SugaredLogger, gitService GitService, - gitOpsConfigRepository repository.GitOpsConfigRepository) GitBitbucketClient { +func NewGitBitbucketClient(username, token, host string, logger *zap.SugaredLogger, gitService GitService) GitBitbucketClient { coreClient := bitbucket.NewBasicAuth(username, token) logger.Infow("bitbucket client created", "clientDetails", coreClient) return GitBitbucketClient{ - client: coreClient, - logger: logger, - gitService: gitService, - gitOpsConfigRepository: gitOpsConfigRepository, + client: coreClient, + logger: logger, + gitService: gitService, } } @@ -256,47 +251,3 @@ func (impl GitBitbucketClient) CommitValues(config *ChartConfig, gitOpsConfig *b } return commitHash, commitTime, nil } - -func (impl GitBitbucketClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error) { - gitOpsConfigBitbucket, err := impl.gitOpsConfigRepository.GetGitOpsConfigByProvider(BITBUCKET_PROVIDER) - if err != nil { - if err == pg.ErrNoRows { - gitOpsConfigBitbucket = &repository.GitOpsConfig{} - gitOpsConfigBitbucket.BitBucketWorkspaceId = "" - gitOpsConfigBitbucket.BitBucketProjectKey = "" - } else { - impl.logger.Errorw("error in fetching gitOps bitbucket config", "err", err) - return nil, err - } - } - bitbucketWorkspaceId := gitOpsConfigBitbucket.BitBucketWorkspaceId - bitbucketClient := impl.client - getCommitsOptions := &bitbucket.CommitsOptions{ - RepoSlug: repoName, - Owner: bitbucketWorkspaceId, - Branchortag: "master", - } - gitCommitsIf, err := bitbucketClient.Repositories.Commits.GetCommits(getCommitsOptions) - if err != nil { - impl.logger.Errorw("error in getting commits", "err", err, "repoName", repoName) - return nil, err - } - - gitCommits := gitCommitsIf.(map[string]interface{})["values"].([]interface{}) - var gitCommitsDto []*GitCommitDto - for _, gitCommit := range gitCommits { - - commitHash := gitCommit.(map[string]string)["hash"] - commitTime, err := time.Parse(time.RFC3339, gitCommit.(map[string]interface{})["date"].(string)) - if err != nil { - impl.logger.Errorw("error in getting commitTime", "err", err, "gitCommit", gitCommit) - return nil, err - } - gitCommitDto := &GitCommitDto{ - CommitHash: commitHash, - CommitTime: commitTime, - } - gitCommitsDto = append(gitCommitsDto, gitCommitDto) - } - return gitCommitsDto, nil -} diff --git a/pkg/deployment/gitOps/git/GitServiceGithub.go b/pkg/deployment/gitOps/git/GitServiceGithub.go index b7cb50c927..0969370cd4 100644 --- a/pkg/deployment/gitOps/git/GitServiceGithub.go +++ b/pkg/deployment/gitOps/git/GitServiceGithub.go @@ -4,7 +4,6 @@ import ( "context" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/google/go-github/github" "go.uber.org/zap" "golang.org/x/oauth2" @@ -16,17 +15,14 @@ import ( ) type GitHubClient struct { - client *github.Client - - //config *GitConfig - logger *zap.SugaredLogger - org string - gitService GitService - gitOpsConfigRepository repository.GitOpsConfigRepository + client *github.Client + logger *zap.SugaredLogger + org string + gitService GitService } func NewGithubClient(host string, token string, org string, logger *zap.SugaredLogger, - gitService GitService, gitOpsConfigRepository repository.GitOpsConfigRepository) (GitHubClient, error) { + gitService GitService) (GitHubClient, error) { ctx := context.Background() httpTransport := &http2.Transport{} httpClient := &http2.Client{Transport: httpTransport} @@ -52,11 +48,10 @@ func NewGithubClient(host string, token string, org string, logger *zap.SugaredL } return GitHubClient{ - client: client, - org: org, - logger: logger, - gitService: gitService, - gitOpsConfigRepository: gitOpsConfigRepository, + client: client, + org: org, + logger: logger, + gitService: gitService, }, err } func (impl GitHubClient) DeleteRepository(config *bean2.GitOpsConfigDto) error { @@ -244,22 +239,3 @@ func (impl GitHubClient) ensureProjectAvailabilityOnSsh(projectName string, repo } return false, nil } - -func (impl GitHubClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error) { - githubClient := impl.client - gitCommits, _, err := githubClient.Repositories.ListCommits(context.Background(), impl.org, repoName, &github.CommitsListOptions{}) - if err != nil { - impl.logger.Errorw("error in getting commits", "err", err, "repoName", repoName) - return nil, err - } - var gitCommitsDto []*GitCommitDto - for _, gitCommit := range gitCommits { - gitCommitDto := &GitCommitDto{ - CommitHash: gitCommit.GetSHA(), - AuthorName: *gitCommit.Author.Name, - CommitTime: *gitCommit.Commit.Author.Date, - } - gitCommitsDto = append(gitCommitsDto, gitCommitDto) - } - return gitCommitsDto, nil -} diff --git a/pkg/deployment/gitOps/git/GitServiceGitlab.go b/pkg/deployment/gitOps/git/GitServiceGitlab.go index 4f8e210698..fcdc4f8567 100644 --- a/pkg/deployment/gitOps/git/GitServiceGitlab.go +++ b/pkg/deployment/gitOps/git/GitServiceGitlab.go @@ -269,26 +269,3 @@ func (impl GitLabClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.G } return c.ID, *c.AuthoredDate, err } - -func (impl GitLabClient) GetCommits(repoName, projectName string) ([]*GitCommitDto, error) { - gitlabClient := impl.client - branch := "master" - listCommitOptions := &gitlab.ListCommitsOptions{ - RefName: &branch, - } - gitCommits, _, err := gitlabClient.Commits.ListCommits(fmt.Sprintf("%s/%s", impl.config.GitlabGroupPath, repoName), listCommitOptions) - if err != nil { - impl.logger.Errorw("error in getting commits", "err", err, "repoName", repoName) - return nil, err - } - var gitCommitsDto []*GitCommitDto - for _, gitCommit := range gitCommits { - gitCommitDto := &GitCommitDto{ - CommitHash: gitCommit.String(), - AuthorName: gitCommit.AuthorName, - CommitTime: *gitCommit.AuthoredDate, - } - gitCommitsDto = append(gitCommitsDto, gitCommitDto) - } - return gitCommitsDto, nil -} diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go index a0b7daa517..7c2df27271 100644 --- a/pkg/deployment/gitOps/wire_gitOps.go +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -1,12 +1,16 @@ package gitOps import ( + "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/google/wire" ) var GitOpsWireSet = wire.NewSet( + repository.NewGitOpsConfigRepositoryImpl, + wire.Bind(new(repository.GitOpsConfigRepository), new(*repository.GitOpsConfigRepositoryImpl)), + config.NewGitOpsConfigReadServiceImpl, wire.Bind(new(config.GitOpsConfigReadService), new(*config.GitOpsConfigReadServiceImpl)), diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index 06e8f7052e..5925bf06de 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -348,7 +348,7 @@ func (impl *GitOpsConfigServiceImpl) CreateGitOpsConfig(ctx context.Context, req return nil, err } - err = impl.gitFactory.Reload() + err = impl.gitFactory.Reload(impl.gitOpsRepository) if err != nil { return nil, err } @@ -523,7 +523,7 @@ func (impl *GitOpsConfigServiceImpl) UpdateGitOpsConfig(request *bean2.GitOpsCon if err != nil { return err } - err = impl.gitFactory.Reload() + err = impl.gitFactory.Reload(impl.gitOpsRepository) if err != nil { return err } From d6165740c0d1e374c06e88f0f907ae3d9ab7e607 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 15:59:45 +0530 Subject: [PATCH 37/83] gitlab client creation refactoring --- pkg/deployment/gitOps/git/GitService.go | 28 ++----------- pkg/deployment/gitOps/git/GitServiceGitlab.go | 42 +++++++++++-------- .../deployment/gitOps/git}/GitService_test.go | 14 +++---- 3 files changed, 36 insertions(+), 48 deletions(-) rename {internal/util => pkg/deployment/gitOps/git}/GitService_test.go (74%) diff --git a/pkg/deployment/gitOps/git/GitService.go b/pkg/deployment/gitOps/git/GitService.go index 80d8b48cb3..20105abe01 100644 --- a/pkg/deployment/gitOps/git/GitService.go +++ b/pkg/deployment/gitOps/git/GitService.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "github.com/devtron-labs/devtron/util" - "net/url" "path/filepath" "time" @@ -72,12 +71,6 @@ type DetailedErrorGitOpsConfigActions struct { DeleteRepoFailed bool `json:"deleteRepoFailed"` } -type GitCommitDto struct { - CommitHash string `json:"commitHash"` - AuthorName string `json:"authorName"` - CommitTime time.Time `json:"commitTime"` -} - func (factory *GitFactory) Reload(gitOpsRepository repository.GitOpsConfigRepository) error { var err error start := time.Now() @@ -102,27 +95,14 @@ func (factory *GitFactory) Reload(gitOpsRepository repository.GitOpsConfigReposi func (factory *GitFactory) GetGitLabGroupPath(gitOpsConfig *bean2.GitOpsConfigDto) (string, error) { start := time.Now() - var gitLabClient *gitlab.Client var err error defer func() { util.TriggerGitOpsMetrics("GetGitLabGroupPath", "GitService", start, err) }() - if len(gitOpsConfig.Host) > 0 { - _, err = url.ParseRequestURI(gitOpsConfig.Host) - if err != nil { - return "", err - } - gitLabClient, err = gitlab.NewClient(gitOpsConfig.Token, gitlab.WithBaseURL(gitOpsConfig.Host)) - if err != nil { - factory.logger.Errorw("error in getting new gitlab client", "err", err) - return "", err - } - } else { - gitLabClient, err = gitlab.NewClient(gitOpsConfig.Token) - if err != nil { - factory.logger.Errorw("error in getting new gitlab client", "err", err) - return "", err - } + gitLabClient, err := CreateGitlabClient(gitOpsConfig.Host, gitOpsConfig.Token) + if err != nil { + factory.logger.Errorw("error in creating gitlab client", "err", err) + return "", err } group, _, err := gitLabClient.Groups.GetGroup(gitOpsConfig.GitLabGroupId, &gitlab.GetGroupOptions{}) if err != nil { diff --git a/pkg/deployment/gitOps/git/GitServiceGitlab.go b/pkg/deployment/gitOps/git/GitServiceGitlab.go index fcdc4f8567..bf4a69cc63 100644 --- a/pkg/deployment/gitOps/git/GitServiceGitlab.go +++ b/pkg/deployment/gitOps/git/GitServiceGitlab.go @@ -19,24 +19,11 @@ type GitLabClient struct { } func NewGitLabClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { - var gitLabClient *gitlab.Client - var err error - if len(config.GitHost) > 0 { - _, err = url.ParseRequestURI(config.GitHost) - if err != nil { - return nil, err - } - gitLabClient, err = gitlab.NewClient(config.GitToken, gitlab.WithBaseURL(config.GitHost)) - if err != nil { - return nil, err - } - } else { - gitLabClient, err = gitlab.NewClient(config.GitToken) - if err != nil { - return nil, err - } + gitLabClient, err := CreateGitlabClient(config.GitHost, config.GitToken) + if err != nil { + logger.Errorw("error in creating gitlab client", "err", err) + return nil, err } - gitlabGroupId := "" if len(config.GitlabGroupId) > 0 { if _, err := strconv.Atoi(config.GitlabGroupId); err == nil { @@ -82,6 +69,27 @@ func NewGitLabClient(config *GitConfig, logger *zap.SugaredLogger, gitService Gi }, nil } +func CreateGitlabClient(host, token string) (*gitlab.Client, error) { + var gitLabClient *gitlab.Client + var err error + if len(host) > 0 { + _, err = url.ParseRequestURI(host) + if err != nil { + return nil, err + } + gitLabClient, err = gitlab.NewClient(token, gitlab.WithBaseURL(host)) + if err != nil { + return nil, err + } + } else { + gitLabClient, err = gitlab.NewClient(token) + if err != nil { + return nil, err + } + } + return gitLabClient, err +} + func (impl GitLabClient) DeleteRepository(config *bean2.GitOpsConfigDto) error { err := impl.DeleteProject(config.GitRepoName) if err != nil { diff --git a/internal/util/GitService_test.go b/pkg/deployment/gitOps/git/GitService_test.go similarity index 74% rename from internal/util/GitService_test.go rename to pkg/deployment/gitOps/git/GitService_test.go index 10eee631a3..f23da2212b 100644 --- a/internal/util/GitService_test.go +++ b/pkg/deployment/gitOps/git/GitService_test.go @@ -1,17 +1,17 @@ -package util +package git import ( "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" + "github.com/devtron-labs/devtron/internal/util" "testing" ) -func getTestGithubClient() git.GitHubClient { - logger, err := NewSugardLogger() - gitCliUtl := git.NewGitCliUtil(logger) - gitService := git.NewGitServiceImpl(&git.GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) +func getTestGithubClient() GitHubClient { + logger, err := util.NewSugardLogger() + gitCliUtl := NewGitCliUtil(logger) + gitService := NewGitServiceImpl(&GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) - githubClient, err := git.NewGithubClient("", "", "test-org", logger, gitService, nil) + githubClient, err := NewGithubClient("", "", "test-org", logger, gitService) if err != nil { panic(err) } From bde77ef545806258a79ab6b35b0c65ef4739bca0 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Tue, 23 Jan 2024 16:11:12 +0530 Subject: [PATCH 38/83] renamed util/ChartService --- internal/util/{ChartService.go => ChartTemplateService.go} | 0 .../util/{ChartService_test.go => ChartTemplateService_test.go} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename internal/util/{ChartService.go => ChartTemplateService.go} (100%) rename internal/util/{ChartService_test.go => ChartTemplateService_test.go} (100%) diff --git a/internal/util/ChartService.go b/internal/util/ChartTemplateService.go similarity index 100% rename from internal/util/ChartService.go rename to internal/util/ChartTemplateService.go diff --git a/internal/util/ChartService_test.go b/internal/util/ChartTemplateService_test.go similarity index 100% rename from internal/util/ChartService_test.go rename to internal/util/ChartTemplateService_test.go From 9aa630b6c0aa890d88510964adc0769fa735657c Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 24 Jan 2024 17:19:33 +0530 Subject: [PATCH 39/83] reverted renaming changes --- .../deployment-chart_1-0-0/app-values.yaml | 4 ++-- .../deployment-chart_1-1-0/app-values.yaml | 4 ++-- .../deployment-chart_4-18-0/app-values.yaml | 4 ++-- .../deployment-chart_4-19-0/app-values.yaml | 4 ++-- .../reference-chart_3-12-0/app-values.yaml | 4 ++-- .../reference-chart_3-13-0/app-values.yaml | 4 ++-- .../reference-chart_4-11-0/app-values.yaml | 4 ++-- .../reference-chart_4-12-0/app-values.yaml | 4 ++-- .../reference-chart_4-13-0/app-values.yaml | 4 ++-- .../reference-chart_4-14-0/app-values.yaml | 4 ++-- .../reference-chart_4-15-0/app-values.yaml | 4 ++-- .../reference-chart_4-16-0/app-values.yaml | 4 ++-- .../reference-chart_4-17-0/app-values.yaml | 4 ++-- .../reference-chart_4-18-0/app-values.yaml | 4 ++-- .../reference-chart_5-0-0/app-values.yaml | 4 ++-- .../statefulset-chart_4-18-0/app-values.yaml | 4 ++-- .../statefulset-chart_4-19-0/app-values.yaml | 4 ++-- .../statefulset-chart_5-0-0/app-values.yaml | 4 ++-- 18 files changed, 36 insertions(+), 36 deletions(-) diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml index a5bebb5c56..0dce06c558 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_1-0-0/app-values.yaml @@ -308,5 +308,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml index 664b444031..bbebc7acab 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/app-values.yaml @@ -449,5 +449,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml index 96bfcafec7..ff562cb579 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-18-0/app-values.yaml @@ -508,5 +508,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml b/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml index 88daa46112..ce73c2af57 100644 --- a/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/deployment-chart_4-19-0/app-values.yaml @@ -514,5 +514,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml index f524a92391..85f565f40a 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_3-12-0/app-values.yaml @@ -233,5 +233,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml index f524a92391..85f565f40a 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_3-13-0/app-values.yaml @@ -233,5 +233,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml index 2771ba40ed..a9eca0e03a 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-11-0/app-values.yaml @@ -276,5 +276,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml index e9fdbd4d14..a3022d7bb8 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-12-0/app-values.yaml @@ -289,5 +289,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml index e9fdbd4d14..a3022d7bb8 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-13-0/app-values.yaml @@ -289,5 +289,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml index 87327b1d51..d73eee8c80 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-14-0/app-values.yaml @@ -293,5 +293,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml index 92eb571112..ff44a3679a 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-15-0/app-values.yaml @@ -306,5 +306,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml index a93d0fb412..fe18509efd 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-16-0/app-values.yaml @@ -308,5 +308,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml index 80ccc7cb32..a621f49a79 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-17-0/app-values.yaml @@ -360,5 +360,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml index 8079c1e887..f4c8cef663 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_4-18-0/app-values.yaml @@ -424,5 +424,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml index fd93c244d8..0555153aee 100644 --- a/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/reference-chart_5-0-0/app-values.yaml @@ -423,5 +423,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml index 1a8063c237..f1d80a0ea3 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_4-18-0/app-values.yaml @@ -393,5 +393,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml index f7edfb417e..ad27515a44 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_4-19-0/app-values.yaml @@ -397,5 +397,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" diff --git a/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml b/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml index 4a057c104f..1b1912aa68 100644 --- a/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml +++ b/scripts/devtron-reference-helm-charts/statefulset-chart_5-0-0/app-values.yaml @@ -384,5 +384,5 @@ hostAliases: [] # - "bar.local" # - ip: "10.1.2.3" # hostnames: -# - "foo.git" -# - "bar.git" +# - "foo.remote" +# - "bar.remote" From 9961fd0cf9f3533e77eea5ccc421c8f70a8636dd Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 24 Jan 2024 17:22:22 +0530 Subject: [PATCH 40/83] reverted renaming changes --- scripts/sql/49_plugin_integration.up.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/sql/49_plugin_integration.up.sql b/scripts/sql/49_plugin_integration.up.sql index 2fd34bc5b9..e52a73ccbe 100644 --- a/scripts/sql/49_plugin_integration.up.sql +++ b/scripts/sql/49_plugin_integration.up.sql @@ -307,11 +307,11 @@ then export GOCACHE=/usr/local/go/cache export PATH=$PATH:/usr/local/go/bin go install go.k6.io/xk6/cmd/xk6@latest - xk6 build --with github.com/grafana/xk6-output-prometheus-git + xk6 build --with github.com/grafana/xk6-output-prometheus-remote K6_PROMETHEUS_USER=$PrometheusUsername \ K6_PROMETHEUS_PASSWORD=$PrometheusApiKey \ K6_PROMETHEUS_REMOTE_URL=$PrometheusRemoteWriteEndpoint \ - ./k6 run $PathToScript -o output-prometheus-git + ./k6 run $PathToScript -o output-prometheus-remote elif [ $OutputType == "LOG" ] then docker pull grafana/k6 @@ -343,7 +343,7 @@ INSERT INTO "public"."plugin_step_variable" ("id", "plugin_step_id", "name", "fo ('1', '1','RelativePathToScript','STRING','checkout path + script path along with script name','t','f','INPUT','NEW','/./script.js','1','f','now()', '1', 'now()', '1'), ('2', '1','PrometheusUsername','STRING','username of prometheus account','t','t','INPUT','NEW',null, '1' ,'f','now()', '1', 'now()', '1'), ('3', '1','PrometheusApiKey','STRING','api key of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), -('4', '1','PrometheusRemoteWriteEndpoint','STRING','git write endpoint of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), +('4', '1','PrometheusRemoteWriteEndpoint','STRING','remote write endpoint of prometheus account','t','t','INPUT','NEW',null, '1','f','now()', '1', 'now()', '1'), ('5', '1','OutputType','STRING','output type - LOG or PROMETHEUS','t','f','INPUT','NEW','LOG', '1','f','now()', '1', 'now()', '1'), ('6', '2','SonarqubeProjectKey','STRING','project key of grafana sonarqube account','t','t','INPUT','NEW',null, '1', 'f','now()', '1', 'now()', '1'), ('7', '2','SonarqubeApiKey','STRING','api key of sonarqube account','t','t','INPUT','NEW',null, '1', 'f','now()', '1', 'now()', '1'), From 5e128a06c434a9066a3a2662d783296dee919331 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 24 Jan 2024 17:41:23 +0530 Subject: [PATCH 41/83] reverted renaming changes --- .../service/AppStoreDeploymentService_test.go | 4 ++-- pkg/deployment/gitOps/git/GitCliUtil.go | 2 +- pkg/pipeline/DeploymentPipelineConfigService.go | 2 +- pkg/pipeline/PipelineStageServiceIT_test.go | 12 ++++++------ util/RequestUtil.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go index 01aabf55f1..79a6fd1f9f 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go @@ -43,7 +43,7 @@ func TestAppStoreDeploymentService(t *testing.T) { InstalledAppId: 0, InstalledAppVersionId: 0, AppStoreVersion: 6304, - ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, git access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", + ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, remote access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", Readme: "", UserId: 6, ReferenceValueId: 6304, @@ -93,7 +93,7 @@ func TestAppStoreDeploymentService(t *testing.T) { InstalledAppId: 0, InstalledAppVersionId: 0, AppStoreVersion: 6304, - ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, git access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", + ValuesOverrideYaml: "## @section Global parameters\n## Global Docker image parameters\n## Please, note that this will override the image parameters, including dependencies, configured to use the global value\n## Current available global Docker image parameters: imageRegistry, imagePullSecrets and storageClass\n\n## @param global.imageRegistry Global Docker image registry\n## @param global.imagePullSecrets Global Docker registry secret names as an array\n## @param global.storageClass Global StorageClass for Persistent Volume(s)\n##\nglobal:\n imageRegistry: \"\"\n ## E.g.\n ## imagePullSecrets:\n ## - myRegistryKeySecretName\n ##\n imagePullSecrets: []\n storageClass: \"\"\n\n## @section Common parameters\n\n## @param kubeVersion Override Kubernetes version\n##\nkubeVersion: \"\"\n## @param nameOverride String to partially override common.names.fullname template (will maintain the release name)\n##\nnameOverride: \"\"\n## @param fullnameOverride String to fully override common.names.fullname template\n##\nfullnameOverride: \"\"\n## @param clusterDomain Kubernetes Cluster Domain\n##\nclusterDomain: cluster.local\n## @param extraDeploy Extra objects to deploy (evaluated as a template)\n##\nextraDeploy: []\n## @param commonLabels Add labels to all the deployed resources\n##\ncommonLabels: {}\n## @param commonAnnotations Add annotations to all the deployed resources\n##\ncommonAnnotations: {}\n## Enable diagnostic mode in the deployment(s)/statefulset(s)\n##\ndiagnosticMode:\n ## @param diagnosticMode.enabled Enable diagnostic mode (all probes will be disabled and the command will be overridden)\n ##\n enabled: false\n ## @param diagnosticMode.command Command to override all containers in the the deployment(s)/statefulset(s)\n ##\n command:\n - sleep\n ## @param diagnosticMode.args Args to override all containers in the the deployment(s)/statefulset(s)\n ##\n args:\n - infinity\n\n## @section Airflow common parameters\n\n## Authentication parameters\n## ref: https://github.com/bitnami/containers/tree/main/bitnami/airflow#environment-variables\n##\nauth:\n ## @param auth.username Username to access web UI\n ##\n username: user\n ## @param auth.password Password to access web UI\n ##\n password: \"\"\n ## @param auth.fernetKey Fernet key to secure connections\n ## ref: https://airflow.readthedocs.io/en/stable/howto/secure-connections.html\n ## ref: https://bcb.github.io/airflow/fernet-key\n ##\n fernetKey: \"\"\n ## @param auth.secretKey Secret key to run your flask app\n ## ref: https://airflow.apache.org/docs/apache-airflow/stable/configurations-ref.html#secret-key\n ##\n secretKey: \"\"\n ## @param auth.existingSecret Name of an existing secret to use for Airflow credentials\n ## `auth.password`, `auth.fernetKey`, and `auth.secretKey` will be ignored and picked up from this secret\n ## The secret must contain the keys `airflow-password`, `airflow-fernet-key` and `airflow-secret-key'\n ## The value is evaluated as a template\n ##\n existingSecret: \"\"\n## @param executor Airflow executor. Allowed values: `SequentialExecutor`, `LocalExecutor`, `CeleryExecutor`, `KubernetesExecutor`, `CeleryKubernetesExecutor` and `LocalKubernetesExecutor`\n## ref: http://airflow.apache.org/docs/stable/executor/index.html\n##\nexecutor: CeleryExecutor\n## @param loadExamples Switch to load some Airflow examples\n##\nloadExamples: false\n## @param configuration Specify content for Airflow config file (auto-generated based on other env. vars otherwise)\n## e.g:\n## configuration: |-\n## [core]\n## dags_folder=/opt/bitnami/airflow/dags\n## ...\n##\nconfiguration: \"\"\n## @param existingConfigmap Name of an existing ConfigMap with the Airflow config file\n##\nexistingConfigmap: \"\"\n## Load custom DAGs from a ConfigMap\n## Note: an init container will be used to prepare the DAGs available in the ConfigMap to be consumed by Airflow containers\n##\ndags:\n ## @param dags.existingConfigmap Name of an existing ConfigMap with all the DAGs files you want to load in Airflow\n ##\n existingConfigmap: \"\"\n ## Bitnami Shell image\n ## ref: https://hub.docker.com/r/bitnami/bitnami-shell/tags/\n ## @param dags.image.registry Init container load-dags image registry\n ## @param dags.image.repository Init container load-dags image repository\n ## @param dags.image.tag Init container load-dags image tag (immutable tags are recommended)\n ## @param dags.image.digest Init container load-dags image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param dags.image.pullPolicy Init container load-dags image pull policy\n ## @param dags.image.pullSecrets Init container load-dags image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/bitnami-shell\n tag: 11-debian-11-r50\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n## @param extraEnvVars Add extra environment variables for all the Airflow pods\n##\nextraEnvVars: []\n## @param extraEnvVarsCM ConfigMap with extra environment variables for all the Airflow pods\n##\nextraEnvVarsCM: \"\"\n## @param extraEnvVarsSecret Secret with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecret: \"\"\n## @param extraEnvVarsSecrets List of secrets with extra environment variables for all the Airflow pods\n##\nextraEnvVarsSecrets: []\n## @param sidecars Add additional sidecar containers to all the Airflow pods\n## Example:\n## sidecars:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\nsidecars: []\n## @param initContainers Add additional init containers to all the Airflow pods\n## Example:\n## initContainers:\n## - name: your-image-name\n## image: your-image\n## imagePullPolicy: Always\n## ports:\n## - name: portname\n## containerPort: 1234\n##\ninitContainers: []\n## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts for all the Airflow pods\n##\nextraVolumeMounts: []\n## @param extraVolumes Optionally specify extra list of additional volumes for the all the Airflow pods\n##\nextraVolumes: []\n\n## @section Airflow web parameters\n\nweb:\n ## Bitnami Airflow image version\n ## ref: https://hub.docker.com/r/bitnami/airflow/tags/\n ## @param web.image.registry Airflow image registry\n ## @param web.image.repository Airflow image repository\n ## @param web.image.tag Airflow image tag (immutable tags are recommended)\n ## @param web.image.digest Airflow image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param web.image.pullPolicy Airflow image pull policy\n ## @param web.image.pullSecrets Airflow image pull secrets\n ## @param web.image.debug Enable image debug mode\n image:\n registry: docker.io\n repository: bitnami/airflow\n tag: 2.4.2-debian-11-r6\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param web.baseUrl URL used to access to Airflow web ui\n ##\n baseUrl: \"\"\n ## @param web.existingConfigmap Name of an existing config map containing the Airflow web config file\n ##\n existingConfigmap: \"\"\n ## @param web.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param web.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param web.extraEnvVars Array with extra environment variables to add Airflow web pods\n ##\n extraEnvVars: []\n ## @param web.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow web pods\n ##\n extraEnvVarsCM: \"\"\n ## @param web.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow web pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param web.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow web pods\n ##\n extraEnvVarsSecrets: []\n ## @param web.containerPorts.http Airflow web HTTP container port\n ##\n containerPorts:\n http: 8080\n ## @param web.replicaCount Number of Airflow web replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow web containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param web.livenessProbe.enabled Enable livenessProbe on Airflow web containers\n ## @param web.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param web.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param web.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param web.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param web.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.readinessProbe.enabled Enable readinessProbe on Airflow web containers\n ## @param web.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param web.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param web.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param web.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param web.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param web.startupProbe.enabled Enable startupProbe on Airflow web containers\n ## @param web.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param web.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param web.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param web.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param web.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param web.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param web.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param web.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow web resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param web.resources.limits The resources limits for the Airflow web containers\n ## @param web.resources.requests The requested resources for the Airflow web containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow web pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param web.podSecurityContext.enabled Enabled Airflow web pods' Security Context\n ## @param web.podSecurityContext.fsGroup Set Airflow web pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow web containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param web.containerSecurityContext.enabled Enabled Airflow web containers' Security Context\n ## @param web.containerSecurityContext.runAsUser Set Airflow web containers' Security Context runAsUser\n ## @param web.containerSecurityContext.runAsNonRoot Set Airflow web containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param web.lifecycleHooks for the Airflow web container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param web.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param web.podLabels Add extra labels to the Airflow web pods\n ##\n podLabels: {}\n ## @param web.podAnnotations Add extra annotations to the Airflow web pods\n ##\n podAnnotations: {}\n ## @param web.affinity Affinity for Airflow web pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `web.podAffinityPreset`, `web.podAntiAffinityPreset`, and `web.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param web.nodeAffinityPreset.key Node label key to match. Ignored if `web.affinity` is set.\n ## @param web.nodeAffinityPreset.type Node affinity preset type. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`\n ## @param web.nodeAffinityPreset.values Node label values to match. Ignored if `web.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param web.nodeSelector Node labels for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param web.podAffinityPreset Pod affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param web.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `web.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param web.tolerations Tolerations for Airflow web pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param web.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param web.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param web.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param web.terminationGracePeriodSeconds Seconds Airflow web pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param web.updateStrategy.type Airflow web deployment strategy type\n ## @param web.updateStrategy.rollingUpdate Airflow web deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param web.sidecars Add additional sidecar containers to the Airflow web pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param web.initContainers Add additional init containers to the Airflow web pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param web.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow web pods\n ##\n extraVolumeMounts: []\n ## @param web.extraVolumes Optionally specify extra list of additional volumes for the Airflow web pods\n ##\n extraVolumes: []\n ## Airflow web Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param web.pdb.create Deploy a pdb object for the Airflow web pods\n ## @param web.pdb.minAvailable Maximum number/percentage of unavailable Airflow web replicas\n ## @param web.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow web replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow scheduler parameters\n\nscheduler:\n ## Bitnami Airflow Scheduler image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-scheduler/tags/\n ## @param scheduler.image.registry Airflow Scheduler image registry\n ## @param scheduler.image.repository Airflow Scheduler image repository\n ## @param scheduler.image.tag Airflow Scheduler image tag (immutable tags are recommended)\n ## @param scheduler.image.digest Airflow Schefuler image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param scheduler.image.pullPolicy Airflow Scheduler image pull policy\n ## @param scheduler.image.pullSecrets Airflow Scheduler image pull secrets\n ## @param scheduler.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-scheduler\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param scheduler.replicaCount Number of scheduler replicas\n ##\n replicaCount: 1\n ## @param scheduler.command Override cmd\n ##\n command: []\n ## @param scheduler.args Override args\n ##\n args: []\n ## @param scheduler.extraEnvVars Add extra environment variables\n ##\n extraEnvVars: []\n ## @param scheduler.extraEnvVarsCM ConfigMap with extra environment variables\n ##\n extraEnvVarsCM: \"\"\n ## @param scheduler.extraEnvVarsSecret Secret with extra environment variables\n ##\n extraEnvVarsSecret: \"\"\n ## @param scheduler.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow scheduler pods\n ##\n extraEnvVarsSecrets: []\n ## @param scheduler.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param scheduler.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param scheduler.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow scheduler resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param scheduler.resources.limits The resources limits for the Airflow scheduler containers\n ## @param scheduler.resources.requests The requested resources for the Airflow scheduler containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow scheduler pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param scheduler.podSecurityContext.enabled Enabled Airflow scheduler pods' Security Context\n ## @param scheduler.podSecurityContext.fsGroup Set Airflow scheduler pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow scheduler containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param scheduler.containerSecurityContext.enabled Enabled Airflow scheduler containers' Security Context\n ## @param scheduler.containerSecurityContext.runAsUser Set Airflow scheduler containers' Security Context runAsUser\n ## @param scheduler.containerSecurityContext.runAsNonRoot Set Airflow scheduler containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param scheduler.lifecycleHooks for the Airflow scheduler container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param scheduler.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param scheduler.podLabels Add extra labels to the Airflow scheduler pods\n ##\n podLabels: {}\n ## @param scheduler.podAnnotations Add extra annotations to the Airflow scheduler pods\n ##\n podAnnotations: {}\n ## @param scheduler.affinity Affinity for Airflow scheduler pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `scheduler.podAffinityPreset`, `scheduler.podAntiAffinityPreset`, and `scheduler.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param scheduler.nodeAffinityPreset.key Node label key to match. Ignored if `scheduler.affinity` is set.\n ## @param scheduler.nodeAffinityPreset.type Node affinity preset type. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`\n ## @param scheduler.nodeAffinityPreset.values Node label values to match. Ignored if `scheduler.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param scheduler.nodeSelector Node labels for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param scheduler.podAffinityPreset Pod affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param scheduler.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `scheduler.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param scheduler.tolerations Tolerations for Airflow scheduler pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param scheduler.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param scheduler.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param scheduler.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param scheduler.terminationGracePeriodSeconds Seconds Airflow scheduler pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param scheduler.updateStrategy.type Airflow scheduler deployment strategy type\n ## @param scheduler.updateStrategy.rollingUpdate Airflow scheduler deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param scheduler.sidecars Add additional sidecar containers to the Airflow scheduler pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param scheduler.initContainers Add additional init containers to the Airflow scheduler pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param scheduler.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow scheduler pods\n ##\n extraVolumeMounts: []\n ## @param scheduler.extraVolumes Optionally specify extra list of additional volumes for the Airflow scheduler pods\n ##\n extraVolumes: []\n ## Airflow scheduler Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param scheduler.pdb.create Deploy a pdb object for the Airflow scheduler pods\n ## @param scheduler.pdb.minAvailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ## @param scheduler.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow scheduler replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n\n## @section Airflow worker parameters\n\nworker:\n ## Bitnami Airflow Worker image version\n ## ref: https://hub.docker.com/r/bitnami/airflow-worker/tags/\n ## @param worker.image.registry Airflow Worker image registry\n ## @param worker.image.repository Airflow Worker image repository\n ## @param worker.image.tag Airflow Worker image tag (immutable tags are recommended)\n ## @param worker.image.digest Airflow Worker image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param worker.image.pullPolicy Airflow Worker image pull policy\n ## @param worker.image.pullSecrets Airflow Worker image pull secrets\n ## @param worker.image.debug Enable image debug mode\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-worker\n tag: 2.4.2-debian-11-r4\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Set to true if you would like to see extra information on logs\n ##\n debug: false\n ## @param worker.command Override default container command (useful when using custom images)\n ##\n command: []\n ## @param worker.args Override default container args (useful when using custom images)\n ##\n args: []\n ## @param worker.extraEnvVars Array with extra environment variables to add Airflow worker pods\n ##\n extraEnvVars: []\n ## @param worker.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow worker pods\n ##\n extraEnvVarsCM: \"\"\n ## @param worker.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow worker pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param worker.extraEnvVarsSecrets List of secrets with extra environment variables for Airflow worker pods\n ##\n extraEnvVarsSecrets: []\n ## @param worker.containerPorts.http Airflow worker HTTP container port\n ##\n containerPorts:\n http: 8793\n ## @param worker.replicaCount Number of Airflow worker replicas\n ##\n replicaCount: 1\n ## Configure extra options for Airflow worker containers' liveness, readiness and startup probes\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes\n ## @param worker.livenessProbe.enabled Enable livenessProbe on Airflow worker containers\n ## @param worker.livenessProbe.initialDelaySeconds Initial delay seconds for livenessProbe\n ## @param worker.livenessProbe.periodSeconds Period seconds for livenessProbe\n ## @param worker.livenessProbe.timeoutSeconds Timeout seconds for livenessProbe\n ## @param worker.livenessProbe.failureThreshold Failure threshold for livenessProbe\n ## @param worker.livenessProbe.successThreshold Success threshold for livenessProbe\n ##\n livenessProbe:\n enabled: true\n initialDelaySeconds: 180\n periodSeconds: 20\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.readinessProbe.enabled Enable readinessProbe on Airflow worker containers\n ## @param worker.readinessProbe.initialDelaySeconds Initial delay seconds for readinessProbe\n ## @param worker.readinessProbe.periodSeconds Period seconds for readinessProbe\n ## @param worker.readinessProbe.timeoutSeconds Timeout seconds for readinessProbe\n ## @param worker.readinessProbe.failureThreshold Failure threshold for readinessProbe\n ## @param worker.readinessProbe.successThreshold Success threshold for readinessProbe\n ##\n readinessProbe:\n enabled: true\n initialDelaySeconds: 30\n periodSeconds: 10\n timeoutSeconds: 5\n failureThreshold: 6\n successThreshold: 1\n ## @param worker.startupProbe.enabled Enable startupProbe on Airflow worker containers\n ## @param worker.startupProbe.initialDelaySeconds Initial delay seconds for startupProbe\n ## @param worker.startupProbe.periodSeconds Period seconds for startupProbe\n ## @param worker.startupProbe.timeoutSeconds Timeout seconds for startupProbe\n ## @param worker.startupProbe.failureThreshold Failure threshold for startupProbe\n ## @param worker.startupProbe.successThreshold Success threshold for startupProbe\n ##\n startupProbe:\n enabled: false\n initialDelaySeconds: 60\n periodSeconds: 10\n timeoutSeconds: 1\n failureThreshold: 15\n successThreshold: 1\n ## @param worker.customLivenessProbe Custom livenessProbe that overrides the default one\n ##\n customLivenessProbe: {}\n ## @param worker.customReadinessProbe Custom readinessProbe that overrides the default one\n ##\n customReadinessProbe: {}\n ## @param worker.customStartupProbe Custom startupProbe that overrides the default one\n ##\n customStartupProbe: {}\n ## Airflow worker resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param worker.resources.limits The resources limits for the Airflow worker containers\n ## @param worker.resources.requests The requested resources for the Airflow worker containers\n ##\n resources:\n limits: {}\n requests: {}\n ## Configure Airflow worker pods Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param worker.podSecurityContext.enabled Enabled Airflow worker pods' Security Context\n ## @param worker.podSecurityContext.fsGroup Set Airflow worker pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Configure Airflow worker containers (only main one) Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param worker.containerSecurityContext.enabled Enabled Airflow worker containers' Security Context\n ## @param worker.containerSecurityContext.runAsUser Set Airflow worker containers' Security Context runAsUser\n ## @param worker.containerSecurityContext.runAsNonRoot Set Airflow worker containers' Security Context runAsNonRoot\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param worker.lifecycleHooks for the Airflow worker container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param worker.hostAliases Deployment pod host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param worker.podLabels Add extra labels to the Airflow worker pods\n ##\n podLabels: {}\n ## @param worker.podAnnotations Add extra annotations to the Airflow worker pods\n ##\n podAnnotations: {}\n ## @param worker.affinity Affinity for Airflow worker pods assignment (evaluated as a template)\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: `worker.podAffinityPreset`, `worker.podAntiAffinityPreset`, and `worker.nodeAffinityPreset` will be ignored when it's set\n ##\n affinity: {}\n ## Node affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ## @param worker.nodeAffinityPreset.key Node label key to match. Ignored if `worker.affinity` is set.\n ## @param worker.nodeAffinityPreset.type Node affinity preset type. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`\n ## @param worker.nodeAffinityPreset.values Node label values to match. Ignored if `worker.affinity` is set.\n ##\n nodeAffinityPreset:\n ## e.g:\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n type: \"\"\n ## e.g:\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param worker.nodeSelector Node labels for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param worker.podAffinityPreset Pod affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param worker.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `worker.affinity` is set. Allowed values: `soft` or `hard`.\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## @param worker.tolerations Tolerations for Airflow worker pods assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param worker.topologySpreadConstraints Topology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template\n ## Ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/#spread-constraints-for-pods\n ##\n topologySpreadConstraints: []\n ## @param worker.priorityClassName Priority Class Name\n ## ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass\n ##\n priorityClassName: \"\"\n ## @param worker.schedulerName Use an alternate scheduler, e.g. \"stork\".\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## @param worker.terminationGracePeriodSeconds Seconds Airflow worker pod needs to terminate gracefully\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods\n ##\n terminationGracePeriodSeconds: \"\"\n ## @param worker.updateStrategy.type Airflow worker deployment strategy type\n ## @param worker.updateStrategy.rollingUpdate Airflow worker deployment rolling update configuration parameters\n ## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy\n ##\n updateStrategy:\n type: RollingUpdate\n rollingUpdate: {}\n ## @param worker.sidecars Add additional sidecar containers to the Airflow worker pods\n ## Example:\n ## sidecars:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n sidecars: []\n ## @param worker.initContainers Add additional init containers to the Airflow worker pods\n ## Example:\n ## initContainers:\n ## - name: your-image-name\n ## image: your-image\n ## imagePullPolicy: Always\n ## ports:\n ## - name: portname\n ## containerPort: 1234\n ##\n initContainers: []\n ## @param worker.extraVolumeMounts Optionally specify extra list of additional volumeMounts for the Airflow worker pods\n ##\n extraVolumeMounts: []\n ## @param worker.extraVolumes Optionally specify extra list of additional volumes for the Airflow worker pods\n ##\n extraVolumes: []\n ## @param worker.extraVolumeClaimTemplates Optionally specify extra list of volumesClaimTemplates for the Airflow worker statefulset\n ##\n extraVolumeClaimTemplates: []\n ## @param worker.podTemplate Template to replace the default one to be use when `executor=KubernetesExecutor` to create Airflow worker pods\n ##\n podTemplate: {}\n ## Airflow worker Pod Disruption Budget\n ## ref: https://kubernetes.io/docs/concepts/workloads/pods/disruptions/\n ## @param worker.pdb.create Deploy a pdb object for the Airflow worker pods\n ## @param worker.pdb.minAvailable Maximum number/percentage of unavailable Airflow worker replicas\n ## @param worker.pdb.maxUnavailable Maximum number/percentage of unavailable Airflow worker replicas\n ##\n pdb:\n create: false\n minAvailable: 1\n maxUnavailable: \"\"\n ## Enable HorizontalPodAutoscaler for worker pods\n ## ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/\n ## @param worker.autoscaling.enabled Whether enable horizontal pod autoscaler\n ## @param worker.autoscaling.minReplicas Configure a minimum amount of pods\n ## @param worker.autoscaling.maxReplicas Configure a maximum amount of pods\n ## @param worker.autoscaling.targetCPU Define the CPU target to trigger the scaling actions (utilization percentage)\n ## @param worker.autoscaling.targetMemory Define the memory target to trigger the scaling actions (utilization percentage)\n ##\n autoscaling:\n enabled: false\n minReplicas: 1\n maxReplicas: 3\n targetCPU: 80\n targetMemory: 80\n\n## @section Airflow git sync parameters\n\n## Configure Git to pull dags and plugins\n##\ngit:\n ## Bitnami Git image version\n ## ref: https://hub.docker.com/r/bitnami/git/tags/\n ## @param git.image.registry Git image registry\n ## @param git.image.repository Git image repository\n ## @param git.image.tag Git image tag (immutable tags are recommended)\n ## @param git.image.digest Git image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param git.image.pullPolicy Git image pull policy\n ## @param git.image.pullSecrets Git image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/git\n tag: 2.38.1-debian-11-r7\n digest: \"\"\n ## Specify a imagePullPolicy\n ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'\n ## ref: https://kubernetes.io/docs/user-guide/images/#pre-pulling-images\n ##\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## Get DAG files from git repositories\n ## @param git.dags.enabled Enable in order to download DAG files from git repositories.\n ## @param git.dags.repositories [array] Array of repositories from which to download DAG files\n ##\n dags:\n enabled: false\n ## Name for repositories can be anything unique and must follow same naming conventions as kubernetes.\n ## Kubernetes resources can have names up to 253 characters long. The characters allowed in names are:\n ## digits (0-9), lower case letters (a-z), -, and .\n ## Example:\n ## - repository: https://github.com/myuser/myrepo\n ## branch: main\n ## name: my-dags\n ## path: /\n ##\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the dags\n ##\n path: \"\"\n ## Get Plugins files from git repositories.\n ## @param git.plugins.enabled Enable in order to download Plugins files from git repositories.\n ## @param git.plugins.repositories [array] Array of repositories from which to download DAG files\n ##\n plugins:\n enabled: false\n repositories:\n - repository: \"\"\n ## Branch from repository to checkout\n ##\n branch: \"\"\n ## An unique identifier for repository, must be unique for each repository\n ##\n name: \"\"\n ## Path to a folder in the repository containing the plugins\n ##\n path: \"\"\n ## Properties for the Clone init container\n ## @param git.clone.command Override cmd\n ## @param git.clone.args Override args\n ## @param git.clone.extraVolumeMounts Add extra volume mounts\n ## @param git.clone.extraEnvVars Add extra environment variables\n ## @param git.clone.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.clone.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.clone.resources Clone init container resource requests and limits\n ##\n clone:\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Clone init container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n ## Properties for the Sync sidecar container\n ## @param git.sync.interval Interval in seconds to pull the git repository containing the plugins and/or DAG files\n ## @param git.sync.command Override cmd\n ## @param git.sync.args Override args\n ## @param git.sync.extraVolumeMounts Add extra volume mounts\n ## @param git.sync.extraEnvVars Add extra environment variables\n ## @param git.sync.extraEnvVarsCM ConfigMap with extra environment variables\n ## @param git.sync.extraEnvVarsSecret Secret with extra environment variables\n ## @param git.sync.resources Sync sidecar container resource requests and limits\n ##\n sync:\n interval: 60\n command: []\n args: []\n extraVolumeMounts: []\n extraEnvVars: []\n extraEnvVarsCM: \"\"\n extraEnvVarsSecret: \"\"\n ## Sync sidecar container resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ##\n resources: {}\n\n## @section Airflow ldap parameters\n\n## LDAP configuration\n## @param ldap.enabled Enable LDAP authentication\n## @param ldap.uri Server URI, eg. ldap://ldap_server:389\n## DEPRECATED ldap.base It will be removed in a future release, please use 'ldap.basedn' instead\n## @param ldap.basedn Base of the search, eg. ou=example,o=org.\n## DEPRECATED ldap.uidField It will be removed in a future release,, please use 'ldap.searchAttribute' instead\n## @param ldap.searchAttribute if doing an indirect bind to ldap, this is the field that matches the username when searching for the account to bind to\n## @param ldap.binddn DN of the account used to search in the LDAP server.\n## @param ldap.bindpw Bind Password\n## @param ldap.userRegistration Set to True to enable user self registration\n## @param ldap.userRegistrationRole Set role name to be assign when a user registers himself. This role must already exist. Mandatory when using ldap.userRegistration\n## @param ldap.rolesMapping mapping from LDAP DN to a list of roles\n## @param ldap.rolesSyncAtLogin replace ALL the user's roles each login, or only on registration\n##\nldap:\n enabled: false\n uri: \"ldap://ldap_server:389\"\n basedn: \"dc=example,dc=org\"\n searchAttribute: \"cn\"\n binddn: \"cn=admin,dc=example,dc=org\"\n bindpw: \"\"\n userRegistration: 'True'\n userRegistrationRole: \"Public\"\n rolesMapping: '{ \"cn=All,ou=Groups,dc=example,dc=org\": [\"User\"], \"cn=Admins,ou=Groups,dc=example,dc=org\": [\"Admin\"], }'\n rolesSyncAtLogin: 'True'\n\n ## SSL/TLS parameters for LDAP\n ## @param ldap.tls.enabled Enabled TLS/SSL for LDAP, you must include the CA file.\n ## @param ldap.tls.allowSelfSigned Allow to use self signed certificates\n ## DEPRECATED ldap.tls.CAcertificateSecret It will be removed in a future release, please use ldap.tls.certificatesSecret instead\n ## @param ldap.tls.certificatesSecret Name of the existing secret containing the certificate CA file that will be used by ldap client\n ## @param ldap.tls.certificatesMountPath Where LDAP certifcates are mounted.\n ## DEPRECATED ldap.tls.CAcertificateFilename It will be removed in a future release, please use ldap.tls.CAFilename instead\n ## @param ldap.tls.CAFilename LDAP CA cert filename\n ##\n tls:\n enabled: false\n allowSelfSigned: true\n certificatesSecret: \"\"\n certificatesMountPath: /opt/bitnami/airflow/conf/certs\n CAFilename: \"\"\n\n## @section Traffic Exposure Parameters\n\n## Airflow service parameters\n##\nservice:\n ## @param service.type Airflow service type\n ##\n type: ClusterIP\n ## @param service.ports.http Airflow service HTTP port\n ##\n ports:\n http: 8080\n ## Node ports to expose\n ## @param service.nodePorts.http Node port for HTTP\n ## NOTE: choose port between <30000-32767>\n ##\n nodePorts:\n http: \"\"\n ## @param service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param service.sessionAffinityConfig Additional settings for the sessionAffinity\n ## sessionAffinityConfig:\n ## clientIP:\n ## timeoutSeconds: 300\n ##\n sessionAffinityConfig: {}\n ## @param service.clusterIP Airflow service Cluster IP\n ## e.g.:\n ## clusterIP: None\n ##\n clusterIP: \"\"\n ## @param service.loadBalancerIP Airflow service Load Balancer IP\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-loadbalancer\n ##\n loadBalancerIP: \"\"\n ## @param service.loadBalancerSourceRanges Airflow service Load Balancer sources\n ## ref: https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/#restrict-access-for-loadbalancer-service\n ## e.g:\n ## loadBalancerSourceRanges:\n ## - 10.10.10.0/24\n ##\n loadBalancerSourceRanges: []\n ## @param service.externalTrafficPolicy Airflow service external traffic policy\n ## ref https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip\n ##\n externalTrafficPolicy: Cluster\n ## @param service.annotations Additional custom annotations for Airflow service\n ##\n annotations: {}\n ## @param service.extraPorts Extra port to expose on Airflow service\n ##\n extraPorts: []\n\n## Airflow ingress parameters\n## ref: https://kubernetes.io/docs/user-guide/ingress/\n##\ningress:\n ## @param ingress.enabled Enable ingress record generation for Airflow\n ##\n enabled: false\n ## @param ingress.ingressClassName IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)\n ## This is supported in Kubernetes 1.18+ and required if you have more than one IngressClass marked as the default for your cluster .\n ## ref: https://kubernetes.io/blog/2020/04/02/improvements-to-the-ingress-api-in-kubernetes-1.18/\n ##\n ingressClassName: \"\"\n ## @param ingress.pathType Ingress path type\n ##\n pathType: ImplementationSpecific\n ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set)\n ##\n apiVersion: \"\"\n ## @param ingress.hostname Default host for the ingress record\n ##\n hostname: airflow.local\n ## @param ingress.path Default path for the ingress record\n ## NOTE: You may need to set this to '/*' in order to use this with ALB ingress controllers\n ##\n path: /\n ## @param ingress.annotations [object] Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.\n ## Use this parameter to set the required annotations for cert-manager, see\n ## ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations\n ## e.g:\n ## annotations:\n ## kubernetes.io/ingress.class: nginx\n ## cert-manager.io/cluster-issuer: cluster-issuer-name\n ##\n annotations: {}\n ## @param ingress.tls Enable TLS configuration for the host defined at `ingress.hostname` parameter\n ## TLS certificates will be retrieved from a TLS secret with name: `{{- printf \"%s-tls\" .Values.ingress.hostname }}`\n ## You can:\n ## - Use the `ingress.secrets` parameter to create this TLS secret\n ## - Rely on cert-manager to create it by setting the corresponding annotations\n ## - Rely on Helm to create self-signed certificates by setting `ingress.selfSigned=true`\n ##\n tls: false\n ## @param ingress.selfSigned Create a TLS secret for this ingress record using self-signed certificates generated by Helm\n ##\n selfSigned: false\n ## @param ingress.extraHosts An array with additional hostname(s) to be covered with the ingress record\n ## e.g:\n ## extraHosts:\n ## - name: airflow.local\n ## path: /\n ##\n extraHosts: []\n ## @param ingress.extraPaths An array with additional arbitrary paths that may need to be added to the ingress under the main host\n ## e.g:\n ## extraPaths:\n ## - path: /*\n ## backend:\n ## serviceName: ssl-redirect\n ## servicePort: use-annotation\n ##\n extraPaths: []\n ## @param ingress.extraTls TLS configuration for additional hostname(s) to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#tls\n ## e.g:\n ## extraTls:\n ## - hosts:\n ## - airflow.local\n ## secretName: airflow.local-tls\n ##\n extraTls: []\n ## @param ingress.secrets Custom TLS certificates as secrets\n ## NOTE: 'key' and 'certificate' are expected in PEM format\n ## NOTE: 'name' should line up with a 'secretName' set further up\n ## If it is not set and you're using cert-manager, this is unneeded, as it will create a secret for you with valid certificates\n ## If it is not set and you're NOT using cert-manager either, self-signed certificates will be created valid for 365 days\n ## It is also possible to create and manage the certificates outside of this helm chart\n ## Please see README.md for more information\n ## e.g:\n ## secrets:\n ## - name: airflow.local-tls\n ## key: |-\n ## -----BEGIN RSA PRIVATE KEY-----\n ## ...\n ## -----END RSA PRIVATE KEY-----\n ## certificate: |-\n ## -----BEGIN CERTIFICATE-----\n ## ...\n ## -----END CERTIFICATE-----\n ##\n secrets: []\n ## @param ingress.extraRules Additional rules to be covered with this ingress record\n ## ref: https://kubernetes.io/docs/concepts/services-networking/ingress/#ingress-rules\n ## e.g:\n ## extraRules:\n ## - host: example.local\n ## http:\n ## path: /\n ## backend:\n ## service:\n ## name: example-svc\n ## port:\n ## name: http\n ##\n extraRules: []\n\n## @section Other Parameters\n\n## Service account for Airflow pods to use.\n## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/\n##\nserviceAccount:\n ## @param serviceAccount.create Enable creation of ServiceAccount for Airflow pods\n ##\n create: false\n ## @param serviceAccount.name The name of the ServiceAccount to use.\n ## If not set and create is true, a name is generated using the common.names.fullname template\n ##\n name: \"\"\n ## @param serviceAccount.automountServiceAccountToken Allows auto mount of ServiceAccountToken on the serviceAccount created\n ## Can be set to false if pods using this serviceAccount do not need to use K8s API\n ##\n automountServiceAccountToken: true\n ## @param serviceAccount.annotations Additional custom annotations for the ServiceAccount\n ##\n annotations: {}\n## Role Based Access\n## Ref: https://kubernetes.io/docs/admin/authorization/rbac/\n## @param rbac.create Create Role and RoleBinding\n##\nrbac:\n create: false\n ## @param rbac.rules Custom RBAC rules to set\n ## e.g:\n ## rules:\n ## - apiGroups:\n ## - \"\"\n ## resources:\n ## - pods\n ## verbs:\n ## - get\n ## - list\n ##\n rules: []\n\n## @section Airflow metrics parameters\n\nmetrics:\n ## @param metrics.enabled Whether or not to create a standalone Airflow exporter to expose Airflow metrics\n ##\n enabled: false\n ## Bitnami Airflow exporter image\n ## ref: https://hub.docker.com/r/bitnami/airflow-exporter/tags/\n ## @param metrics.image.registry Airflow exporter image registry\n ## @param metrics.image.repository Airflow exporter image repository\n ## @param metrics.image.tag Airflow exporter image tag (immutable tags are recommended)\n ## @param metrics.image.digest Airflow exporter image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag\n ## @param metrics.image.pullPolicy Airflow exporter image pull policy\n ## @param metrics.image.pullSecrets Airflow exporter image pull secrets\n ##\n image:\n registry: docker.io\n repository: bitnami/airflow-exporter\n tag: 0.20220314.0-debian-11-r57\n digest: \"\"\n pullPolicy: IfNotPresent\n ## Optionally specify an array of imagePullSecrets.\n ## Secrets must be manually created in the namespace.\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/\n ## e.g:\n ## pullSecrets:\n ## - myRegistryKeySecretName\n ##\n pullSecrets: []\n ## @param metrics.extraEnvVars Array with extra environment variables to add Airflow exporter pods\n ##\n extraEnvVars: []\n ## @param metrics.extraEnvVarsCM ConfigMap containing extra environment variables for Airflow exporter pods\n ##\n extraEnvVarsCM: \"\"\n ## @param metrics.extraEnvVarsSecret Secret containing extra environment variables (in case of sensitive data) for Airflow exporter pods\n ##\n extraEnvVarsSecret: \"\"\n ## @param metrics.containerPorts.http Airflow exporter metrics container port\n ##\n containerPorts:\n http: 9112\n ## Airflow exporter resource requests and limits\n ## ref: https://kubernetes.io/docs/user-guide/compute-resources/\n ## @param metrics.resources.limits The resources limits for the container\n ## @param metrics.resources.requests The requested resources for the container\n ##\n resources:\n limits: {}\n requests: {}\n ## Airflow exporter pods' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod\n ## @param metrics.podSecurityContext.enabled Enable security context for the pods\n ## @param metrics.podSecurityContext.fsGroup Set Airflow exporter pod's Security Context fsGroup\n ##\n podSecurityContext:\n enabled: true\n fsGroup: 1001\n ## Airflow exporter containers' Security Context\n ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container\n ## @param metrics.containerSecurityContext.enabled Enable Airflow exporter containers' Security Context\n ## @param metrics.containerSecurityContext.runAsUser Set Airflow exporter containers' Security Context runAsUser\n ## @param metrics.containerSecurityContext.runAsNonRoot Set Airflow exporter containers' Security Context runAsNonRoot\n ## e.g:\n ## containerSecurityContext:\n ## enabled: true\n ## capabilities:\n ## drop: [\"NET_RAW\"]\n ## readOnlyRootFilesystem: true\n ##\n containerSecurityContext:\n enabled: true\n runAsUser: 1001\n runAsNonRoot: true\n ## @param metrics.lifecycleHooks for the Airflow exporter container(s) to automate configuration before or after startup\n ##\n lifecycleHooks: {}\n ## @param metrics.hostAliases Airflow exporter pods host aliases\n ## https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/\n ##\n hostAliases: []\n ## @param metrics.podLabels Extra labels for Airflow exporter pods\n ## Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/\n ##\n podLabels: {}\n ## @param metrics.podAnnotations Extra annotations for Airflow exporter pods\n ## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/\n ##\n podAnnotations: {}\n ## @param metrics.podAffinityPreset Pod affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAffinityPreset: \"\"\n ## @param metrics.podAntiAffinityPreset Pod anti-affinity preset. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#inter-pod-affinity-and-anti-affinity\n ##\n podAntiAffinityPreset: soft\n ## Node metrics.affinity preset\n ## Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity\n ##\n nodeAffinityPreset:\n ## @param metrics.nodeAffinityPreset.type Node affinity preset type. Ignored if `metrics.affinity` is set. Allowed values: `soft` or `hard`\n ##\n type: \"\"\n ## @param metrics.nodeAffinityPreset.key Node label key to match Ignored if `metrics.affinity` is set.\n ## E.g.\n ## key: \"kubernetes.io/e2e-az-name\"\n ##\n key: \"\"\n ## @param metrics.nodeAffinityPreset.values Node label values to match. Ignored if `metrics.affinity` is set.\n ## E.g.\n ## values:\n ## - e2e-az1\n ## - e2e-az2\n ##\n values: []\n ## @param metrics.affinity Affinity for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity\n ## Note: metrics.podAffinityPreset, metrics.podAntiAffinityPreset, and metrics.nodeAffinityPreset will be ignored when it's set\n ##\n affinity: {}\n ## @param metrics.nodeSelector Node labels for pod assignment\n ## Ref: https://kubernetes.io/docs/user-guide/node-selection/\n ##\n nodeSelector: {}\n ## @param metrics.tolerations Tolerations for pod assignment\n ## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/\n ##\n tolerations: []\n ## @param metrics.schedulerName Name of the k8s scheduler (other than default) for Airflow exporter\n ## ref: https://kubernetes.io/docs/tasks/administer-cluster/configure-multiple-schedulers/\n ##\n schedulerName: \"\"\n ## Airflow exporter service configuration\n ##\n service:\n ## @param metrics.service.ports.http Airflow exporter metrics service port\n ##\n ports:\n http: 9112\n ## @param metrics.service.clusterIP Static clusterIP or None for headless services\n ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#choosing-your-own-ip-address\n ##\n clusterIP: \"\"\n ## @param metrics.service.sessionAffinity Control where client requests go, to the same pod or round-robin\n ## Values: ClientIP or None\n ## ref: https://kubernetes.io/docs/user-guide/services/\n ##\n sessionAffinity: None\n ## @param metrics.service.annotations [object] Annotations for the Airflow exporter service\n ##\n annotations:\n prometheus.io/scrape: \"true\"\n prometheus.io/port: \"{{ .Values.metrics.service.ports.http }}\"\n ## Prometheus Operator ServiceMonitor configuration\n ##\n serviceMonitor:\n ## @param metrics.serviceMonitor.enabled if `true`, creates a Prometheus Operator ServiceMonitor (requires `metrics.enabled` to be `true`)\n ##\n enabled: false\n ## @param metrics.serviceMonitor.namespace Namespace in which Prometheus is running\n ##\n namespace: \"\"\n ## @param metrics.serviceMonitor.interval Interval at which metrics should be scraped\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n interval: \"\"\n ## @param metrics.serviceMonitor.scrapeTimeout Timeout after which the scrape is ended\n ## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint\n ##\n scrapeTimeout: \"\"\n ## @param metrics.serviceMonitor.labels Additional labels that can be used so ServiceMonitor will be discovered by Prometheus\n ##\n labels: {}\n ## @param metrics.serviceMonitor.selector Prometheus instance selector labels\n ## ref: https://github.com/bitnami/charts/tree/main/bitnami/prometheus-operator#prometheus-configuration\n ##\n selector: {}\n ## @param metrics.serviceMonitor.relabelings RelabelConfigs to apply to samples before scraping\n ##\n relabelings: []\n ## @param metrics.serviceMonitor.metricRelabelings MetricRelabelConfigs to apply to samples before ingestion\n ##\n metricRelabelings: []\n ## @param metrics.serviceMonitor.honorLabels Specify honorLabels parameter to add the scrape endpoint\n ##\n honorLabels: false\n ## @param metrics.serviceMonitor.jobLabel The name of the label on the target service to use as the job name in prometheus.\n ##\n jobLabel: \"\"\n\n## @section Airflow database parameters\n\n## PostgreSQL chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/postgresql/values.yaml\n## @param postgresql.enabled Switch to enable or disable the PostgreSQL helm chart\n## @param postgresql.auth.enablePostgresUser Assign a password to the \"postgres\" admin user. Otherwise, remote access will be blocked for this user\n## @param postgresql.auth.username Name for a custom user to create\n## @param postgresql.auth.password Password for the custom user to create\n## @param postgresql.auth.database Name for a custom database to create\n## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials\n## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)\n##\npostgresql:\n enabled: true\n auth:\n enablePostgresUser: false\n username: bn_airflow\n password: \"\"\n database: bitnami_airflow\n existingSecret: \"\"\n architecture: standalone\n## External PostgreSQL configuration\n## All of these values are only used when postgresql.enabled is set to false\n## @param externalDatabase.host Database host\n## @param externalDatabase.port Database port number\n## @param externalDatabase.user Non-root username for Airflow\n## @param externalDatabase.password Password for the non-root username for Airflow\n## @param externalDatabase.database Airflow database name\n## @param externalDatabase.existingSecret Name of an existing secret resource containing the database credentials\n## @param externalDatabase.existingSecretPasswordKey Name of an existing secret key containing the database credentials\n##\nexternalDatabase:\n host: localhost\n port: 5432\n user: bn_airflow\n database: bitnami_airflow\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n\n## Redis® chart configuration\n## ref: https://github.com/bitnami/charts/blob/main/bitnami/redis/values.yaml\n## @param redis.enabled Switch to enable or disable the Redis® helm\n## @param redis.auth.enabled Enable password authentication\n## @param redis.auth.password Redis® password\n## @param redis.auth.existingSecret The name of an existing secret with Redis® credentials\n## @param redis.architecture Redis® architecture. Allowed values: `standalone` or `replication`\n##\nredis:\n enabled: true\n auth:\n enabled: true\n ## Redis® password (both master and slave). Defaults to a random 10-character alphanumeric string if not set and auth.enabled is true.\n ## It should always be set using the password value or in the existingSecret to avoid issues\n ## with Airflow.\n ## The password value is ignored if existingSecret is set\n password: \"\"\n existingSecret: \"\"\n architecture: standalone\n\n## External Redis® configuration\n## All of these values are only used when redis.enabled is set to false\n## @param externalRedis.host Redis® host\n## @param externalRedis.port Redis® port number\n## @param externalRedis.username Redis® username\n## @param externalRedis.password Redis® password\n## @param externalRedis.existingSecret Name of an existing secret resource containing the Redis&trade credentials\n## @param externalRedis.existingSecretPasswordKey Name of an existing secret key containing the Redis&trade credentials\n##\nexternalRedis:\n host: localhost\n port: 6379\n ## Most Redis® implementations do not require a username\n ## to authenticate and it should be enough with the password\n username: \"\"\n password: \"\"\n existingSecret: \"\"\n existingSecretPasswordKey: \"\"\n", Readme: "", UserId: 6, ReferenceValueId: 6304, diff --git a/pkg/deployment/gitOps/git/GitCliUtil.go b/pkg/deployment/gitOps/git/GitCliUtil.go index 587e20f1c6..1b54874f94 100644 --- a/pkg/deployment/gitOps/git/GitCliUtil.go +++ b/pkg/deployment/gitOps/git/GitCliUtil.go @@ -137,7 +137,7 @@ func (impl *GitCliUtil) Clone(rootDir string, remoteUrl string, username string, } response, errMsg, err = impl.Fetch(rootDir, username, password) if err == nil && errMsg == "" { - impl.logger.Warn("git fetch completed, pulling master branch data from git origin") + impl.logger.Warn("git fetch completed, pulling master branch data from remote origin") response, errMsg, err = impl.ListBranch(rootDir, username, password) if err != nil { impl.logger.Errorw("error on git pull", "response", response, "errMsg", errMsg, "err", err) diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index c806a1942e..5c7338ad5a 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -1593,7 +1593,7 @@ func (impl *CdPipelineConfigServiceImpl) RegisterInACD(gitOpsRepoName string, ch err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) if err != nil { impl.logger.Errorw("error while register git repo in argo", "err", err) - emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "git repository is empty"} + emptyRepoErrorMessage := []string{"failed to get index: 404 Not Found", "remote repository is empty"} if strings.Contains(err.Error(), emptyRepoErrorMessage[0]) || strings.Contains(err.Error(), emptyRepoErrorMessage[1]) { // - found empty repository, create some file in repository err := impl.gitOperationService.CreateReadmeInGitRepo(gitOpsRepoName, userId) diff --git a/pkg/pipeline/PipelineStageServiceIT_test.go b/pkg/pipeline/PipelineStageServiceIT_test.go index 532d509eb7..f6e8d803c5 100644 --- a/pkg/pipeline/PipelineStageServiceIT_test.go +++ b/pkg/pipeline/PipelineStageServiceIT_test.go @@ -26,9 +26,9 @@ import ( "time" ) -const CiPipelineStageCreateReqJson = `{"appId":1,"appWorkflowId":0,"action":0,"ciPipeline":{"active":true,"ciMaterial":[{"gitMaterialId":1,"id":0,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"dockerArgs":{},"externalCiConfig":{},"id":0,"isExternal":false,"isManual":false,"name":"ci-1-xyze","linkedCount":0,"scanEnabled":false,"preBuildStage":{"id":0,"steps":[{"id":1,"index":1,"name":"Task 1","description":"chbsdkhbc","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"echo \"ifudsbvnv\"","conditionDetails":[],"inputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"jnsdvbdvbsd","defaultValue":"","variableType":"GLOBAL","refVariableStepIndex":0,"refVariableName":"WORKING_DIRECTORY","refVariableStage":""}],"outputVariables":null,"commandArgsMap":[{"command":"echo","args":["\"HOSTNAME\"","\"PORT\""]}],"portMap":[{"portOnLocal":8080,"portOnContainer":9090}],"mountCodeToContainer":true,"mountDirectoryFromHost":true,"mountCodeToContainerPath":"/sourcecode","mountPathMap":[{"filePathOnDisk":"./test","filePathOnContainer":"./test_container"}],"containerImagePath":"python:latest","isMountCustomScript":true,"storeScriptAt":"./directory/script"},"outputDirectoryPath":["./test1"]},{"id":2,"index":2,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","stepType":"REF_PLUGIN","directoryPath":"","pluginRefStepDetail":{"id":0,"pluginId":1,"conditionDetails":[{"id":0,"conditionOnVariable":"RelativePathToScript","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"svfsv"},{"id":0,"conditionOnVariable":"PrometheusApiKey","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"dfbeavafsv"}],"inputVariables":[{"id":1,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"allowEmptyValue":false,"defaultValue":"/./script.js","variableType":"NEW","variableStepIndexInPlugin":1,"value":"dethdt","refVariableName":"","refVariableStage":""},{"id":2,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"ghmfnbd","refVariableName":"","refVariableStage":""},{"id":3,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"afegs","refVariableName":"","refVariableStage":""},{"id":4,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"aef","refVariableName":"","refVariableStage":""},{"id":5,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"allowEmptyValue":false,"defaultValue":"LOG","variableType":"NEW","variableStepIndexInPlugin":1,"value":"fdgn","refVariableName":"","refVariableStage":""}]}},{"id":3,"index":3,"name":"Task 3","description":"sfdbvf","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \n#set -v ## uncomment this to debug the script \n","conditionDetails":[{"id":0,"conditionOnVariable":"Hello","conditionOperator":"==","conditionType":"PASS","conditionalValue":"aedfrwgwr"},{"id":0,"conditionOnVariable":"Hello","conditionOperator":"!=","conditionType":"PASS","conditionalValue":"tegegr"}],"inputVariables":[],"outputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"dsuihvsuvhbdv","defaultValue":"","variableType":"NEW","refVariableStepIndex":0,"refVariableName":""}],"commandArgsMap":[{"command":"","args":[]}],"portMap":[],"mountCodeToContainer":false,"mountDirectoryFromHost":false},"outputDirectoryPath":["./test2"]}]},"postBuildStage":{},"dockerConfigOverride":{}}}` -const CiPipelineStageUpdateReqJson = `{"appId":1,"appWorkflowId":3,"action":1,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":3,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unov","id":3,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":3,"preBuildStage":{"id":5,"type":"PRE_CI","steps":[{"id":9,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":1,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":44,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":45,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":46,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":47,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":48,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":10,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":null,"storeScriptAt":null,"mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[],"mountCodeToContainerPath":null,"mountPathMap":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":8,"name":"Task 1","description":"","index":2,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Hello from inside pre-build stage\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"postBuildStage":{},"isDockerConfigOverridden":false,"dockerConfigOverride":{}}}` -const CiPipelineStageDeleteReqJson = `{"appId":1,"appWorkflowId":8,"action":2,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":8,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unjn","id":8,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":8,"preBuildStage":{"id":7,"type":"PRE_CI","steps":[{"id":11,"name":"Task 1","description":"","index":1,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Prakash\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":12,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":2,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":49,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":50,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":51,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":52,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"git write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":53,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":13,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"","storeScriptAt":"","mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[]},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"isDockerConfigOverridden":false,"dockerConfigOverride":{},"postBuildStage":{}}}` +const CiPipelineStageCreateReqJson = `{"appId":1,"appWorkflowId":0,"action":0,"ciPipeline":{"active":true,"ciMaterial":[{"gitMaterialId":1,"id":0,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"dockerArgs":{},"externalCiConfig":{},"id":0,"isExternal":false,"isManual":false,"name":"ci-1-xyze","linkedCount":0,"scanEnabled":false,"preBuildStage":{"id":0,"steps":[{"id":1,"index":1,"name":"Task 1","description":"chbsdkhbc","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"echo \"ifudsbvnv\"","conditionDetails":[],"inputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"jnsdvbdvbsd","defaultValue":"","variableType":"GLOBAL","refVariableStepIndex":0,"refVariableName":"WORKING_DIRECTORY","refVariableStage":""}],"outputVariables":null,"commandArgsMap":[{"command":"echo","args":["\"HOSTNAME\"","\"PORT\""]}],"portMap":[{"portOnLocal":8080,"portOnContainer":9090}],"mountCodeToContainer":true,"mountDirectoryFromHost":true,"mountCodeToContainerPath":"/sourcecode","mountPathMap":[{"filePathOnDisk":"./test","filePathOnContainer":"./test_container"}],"containerImagePath":"python:latest","isMountCustomScript":true,"storeScriptAt":"./directory/script"},"outputDirectoryPath":["./test1"]},{"id":2,"index":2,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","stepType":"REF_PLUGIN","directoryPath":"","pluginRefStepDetail":{"id":0,"pluginId":1,"conditionDetails":[{"id":0,"conditionOnVariable":"RelativePathToScript","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"svfsv"},{"id":0,"conditionOnVariable":"PrometheusApiKey","conditionOperator":"==","conditionType":"TRIGGER","conditionalValue":"dfbeavafsv"}],"inputVariables":[{"id":1,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"allowEmptyValue":false,"defaultValue":"/./script.js","variableType":"NEW","variableStepIndexInPlugin":1,"value":"dethdt","refVariableName":"","refVariableStage":""},{"id":2,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"ghmfnbd","refVariableName":"","refVariableStage":""},{"id":3,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"afegs","refVariableName":"","refVariableStage":""},{"id":4,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"defaultValue":"","variableType":"NEW","variableStepIndexInPlugin":1,"value":"aef","refVariableName":"","refVariableStage":""},{"id":5,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"allowEmptyValue":false,"defaultValue":"LOG","variableType":"NEW","variableStepIndexInPlugin":1,"value":"fdgn","refVariableName":"","refVariableStage":""}]}},{"id":3,"index":3,"name":"Task 3","description":"sfdbvf","stepType":"INLINE","directoryPath":"","inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \n#set -v ## uncomment this to debug the script \n","conditionDetails":[{"id":0,"conditionOnVariable":"Hello","conditionOperator":"==","conditionType":"PASS","conditionalValue":"aedfrwgwr"},{"id":0,"conditionOnVariable":"Hello","conditionOperator":"!=","conditionType":"PASS","conditionalValue":"tegegr"}],"inputVariables":[],"outputVariables":[{"id":1,"name":"Hello","value":"","format":"STRING","description":"dsuihvsuvhbdv","defaultValue":"","variableType":"NEW","refVariableStepIndex":0,"refVariableName":""}],"commandArgsMap":[{"command":"","args":[]}],"portMap":[],"mountCodeToContainer":false,"mountDirectoryFromHost":false},"outputDirectoryPath":["./test2"]}]},"postBuildStage":{},"dockerConfigOverride":{}}}` +const CiPipelineStageUpdateReqJson = `{"appId":1,"appWorkflowId":3,"action":1,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":3,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unov","id":3,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":3,"preBuildStage":{"id":5,"type":"PRE_CI","steps":[{"id":9,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":1,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":44,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":45,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":46,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":47,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":48,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":10,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":null,"storeScriptAt":null,"mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[],"mountCodeToContainerPath":null,"mountPathMap":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":8,"name":"Task 1","description":"","index":2,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Hello from inside pre-build stage\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"postBuildStage":{},"isDockerConfigOverridden":false,"dockerConfigOverride":{}}}` +const CiPipelineStageDeleteReqJson = `{"appId":1,"appWorkflowId":8,"action":2,"ciPipeline":{"isManual":false,"dockerArgs":{},"isExternal":false,"parentCiPipeline":0,"parentAppId":0,"appId":1,"externalCiConfig":{"id":0,"webhookUrl":"","payload":"","accessKey":"","payloadOption":null,"schema":null,"responses":null,"projectId":0,"projectName":"","environmentId":"","environmentName":"","environmentIdentifier":"","appId":0,"appName":"","role":""},"ciMaterial":[{"gitMaterialId":1,"id":8,"source":{"type":"SOURCE_TYPE_BRANCH_FIXED","value":"main","regex":""}}],"name":"ci-1-unjn","id":8,"active":true,"linkedCount":0,"scanEnabled":false,"appWorkflowId":8,"preBuildStage":{"id":7,"type":"PRE_CI","steps":[{"id":11,"name":"Task 1","description":"","index":1,"stepType":"INLINE","outputDirectoryPath":["./test"],"inlineStepDetail":{"scriptType":"SHELL","script":"#!/bin/sh \nset -eo pipefail \necho \"Prakash\"\n#set -v ## uncomment this to debug the script \n","storeScriptAt":"","mountDirectoryFromHost":false,"commandArgsMap":[{"command":"","args":null}],"inputVariables":null,"outputVariables":null,"conditionDetails":null},"pluginRefStepDetail":null,"triggerIfParentStageFail":false},{"id":12,"name":"K6 Load testing","description":"K6 is an open-source tool and cloud service that makes load testing easy for developers and QA engineers.","index":2,"stepType":"REF_PLUGIN","outputDirectoryPath":null,"inlineStepDetail":null,"pluginRefStepDetail":{"pluginId":1,"inputVariables":[{"id":49,"name":"RelativePathToScript","format":"STRING","description":"checkout path + script path along with script name","isExposed":true,"defaultValue":"/./script.js","value":"sfds","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":50,"name":"PrometheusUsername","format":"STRING","description":"username of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"sdf","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":51,"name":"PrometheusApiKey","format":"STRING","description":"api key of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"hter","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":52,"name":"PrometheusRemoteWriteEndpoint","format":"STRING","description":"remote write endpoint of prometheus account","isExposed":true,"allowEmptyValue":true,"value":"ewq","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""},{"id":53,"name":"OutputType","format":"STRING","description":"output type - LOG or PROMETHEUS","isExposed":true,"defaultValue":"LOG","value":"erg","variableType":"NEW","variableStepIndexInPlugin":1,"refVariableStage":""}],"outputVariables":null,"conditionDetails":null},"triggerIfParentStageFail":false},{"id":13,"name":"Task 3","description":"","index":3,"stepType":"INLINE","outputDirectoryPath":["./asap"],"inlineStepDetail":{"scriptType":"CONTAINER_IMAGE","script":"","storeScriptAt":"","mountDirectoryFromHost":false,"containerImagePath":"alpine:latest","commandArgsMap":[{"command":"echo","args":["HOSTNAME"]}],"inputVariables":null,"outputVariables":null,"conditionDetails":null,"portMap":[]},"pluginRefStepDetail":null,"triggerIfParentStageFail":false}]},"isDockerConfigOverridden":false,"dockerConfigOverride":{},"postBuildStage":{}}}` const ScopedVariablePayload = `{"variables":[{"definition":{"varName":"KAFKA","dataType":"primitive","varType":"public","description":"Enter any notes for additional details","shortDescription":"Some description for variables"},"attributeValue":[{"variableValue":{"value":"Global"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"NewVariable","dataType":"primitive","varType":"private","description":"New Notes","shortDescription":"New Descriotion"},"attributeValue":[{"variableValue":{"value":"gg"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"test-var-1","dataType":"primitive","varType":"public","description":"","shortDescription":""},"attributeValue":[{"variableValue":{"value":"test1"},"attributeType":"Global","attributeParams":null}]},{"definition":{"varName":"test-var-2","dataType":"primitive","varType":"public","description":"","shortDescription":""},"attributeValue":[{"variableValue":{"value":"test2"},"attributeType":"Global","attributeParams":null}]}]}` var ciPipelineId int @@ -143,7 +143,7 @@ var pipelineStageReq = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "git write endpoint of prometheus account", + Description: "remote write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", @@ -323,7 +323,7 @@ var pipelineStageReqUnresolved = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "git write endpoint of prometheus account", + Description: "remote write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", @@ -504,7 +504,7 @@ var pipelineStageReqResolved = &bean.PipelineStageDto{ Id: 4, Name: "PrometheusRemoteWriteEndpoint", Format: "STRING", - Description: "git write endpoint of prometheus account", + Description: "remote write endpoint of prometheus account", IsExposed: true, AllowEmptyValue: true, DefaultValue: "", diff --git a/util/RequestUtil.go b/util/RequestUtil.go index eb0b251ec9..3eb349bc3d 100644 --- a/util/RequestUtil.go +++ b/util/RequestUtil.go @@ -24,7 +24,7 @@ import ( const xForwardedForHeaderName = "X-Forwarded-For" // GetClientIP gets a requests IP address by reading off the forwarded-for -// header (for proxies) and falls back to use the git address. +// header (for proxies) and falls back to use the remote address. func GetClientIP(r *http.Request) string { xForwardedFor := r.Header.Get(xForwardedForHeaderName) if len(xForwardedFor) > 0 { From 0af9223e4f41496124f688f764c875a89064d60e Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 25 Jan 2024 12:51:53 +0530 Subject: [PATCH 42/83] wip --- client/telemetry/TelemetryEventClient.go | 2 +- pkg/cluster/ClusterServiceExtended.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index c806f42f7f..5b34cd95c9 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -67,7 +67,7 @@ type TelemetryEventClient interface { SendTelemetryDashboardLoggedInEvent() error SendGenericTelemetryEvent(eventType string, prop map[string]interface{}) error SendSummaryEvent(eventType string) error -} +}w func NewTelemetryEventClientImpl(logger *zap.SugaredLogger, client *http.Client, clusterService cluster.ClusterService, K8sUtil *k8s.K8sServiceImpl, aCDAuthConfig *util3.ACDAuthConfig, userService user2.UserService, diff --git a/pkg/cluster/ClusterServiceExtended.go b/pkg/cluster/ClusterServiceExtended.go index e18865e2b9..0982b9b9f4 100644 --- a/pkg/cluster/ClusterServiceExtended.go +++ b/pkg/cluster/ClusterServiceExtended.go @@ -43,10 +43,11 @@ func NewClusterServiceImplExtended(repository repository.ClusterRepository, envi userRepository repository5.UserRepository, roleGroupRepository repository5.RoleGroupRepository, gitOpsConfigReadService config.GitOpsConfigReadService) *ClusterServiceImplExtended { clusterServiceExt := &ClusterServiceImplExtended{ - environmentRepository: environmentRepository, - grafanaClient: grafanaClient, - installedAppRepository: installedAppRepository, - clusterServiceCD: clusterServiceCD, + environmentRepository: environmentRepository, + grafanaClient: grafanaClient, + installedAppRepository: installedAppRepository, + clusterServiceCD: clusterServiceCD, + gitOpsConfigReadService: gitOpsConfigReadService, ClusterServiceImpl: &ClusterServiceImpl{ clusterRepository: repository, logger: logger, From 799ffaec59461d2f01cb8c79d4e8f824120da5f6 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 25 Jan 2024 13:45:32 +0530 Subject: [PATCH 43/83] wip --- .../DeploymentTemplateRepository.go | 6 ++--- .../DeployementTemplateService.go | 4 ++-- .../DeployementTemplateService_test.go | 24 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/sql/repository/DeploymentTemplateRepository.go b/internal/sql/repository/DeploymentTemplateRepository.go index c96760ece5..c35df61721 100644 --- a/internal/sql/repository/DeploymentTemplateRepository.go +++ b/internal/sql/repository/DeploymentTemplateRepository.go @@ -16,7 +16,7 @@ const ( ) type DeploymentTemplateComparisonMetadata struct { - ChartId int `json:"chartRefId"` + ChartRefId int `json:"chartRefId"` ChartVersion string `json:"chartVersion,omitempty"` ChartType string `json:"chartType,omitempty"` EnvironmentId int `json:"environmentId,omitempty"` @@ -78,7 +78,7 @@ func (impl DeploymentTemplateRepositoryImpl) FetchLatestDeploymentWithChartRefs( p.id as pipeline_id, p.environment_id, dth.id as deployment_template_history_id, - ceco.chart_id, + c.chart_ref_id, c.chart_version, ROW_NUMBER() OVER (PARTITION BY p.environment_id ORDER BY pco.id DESC) AS row_num FROM @@ -100,7 +100,7 @@ func (impl DeploymentTemplateRepositoryImpl) FetchLatestDeploymentWithChartRefs( rr.pipeline_id, rr.environment_id, rr.deployment_template_history_id, - rr.chart_id, + rr.chart_ref_id, rr.chart_version, e.environment_name FROM diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index cc5bf594dc..82b8a909a8 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -135,7 +135,7 @@ func (impl DeploymentTemplateServiceImpl) FetchDeploymentsWithChartRefs(appId in for _, item := range defaultVersions.ChartRefs { res := &repository.DeploymentTemplateComparisonMetadata{ - ChartId: item.Id, + ChartRefId: item.Id, ChartVersion: item.Version, ChartType: item.Name, Type: repository.DefaultVersions, @@ -151,7 +151,7 @@ func (impl DeploymentTemplateServiceImpl) FetchDeploymentsWithChartRefs(appId in for _, env := range publishedOnEnvs { item := &repository.DeploymentTemplateComparisonMetadata{ - ChartId: env.ChartRefId, + ChartRefId: env.ChartRefId, EnvironmentId: env.EnvironmentId, EnvironmentName: env.EnvironmentName, Type: repository.PublishedOnEnvironments, diff --git a/pkg/generateManifest/DeployementTemplateService_test.go b/pkg/generateManifest/DeployementTemplateService_test.go index 43bce354d7..d2aac53148 100644 --- a/pkg/generateManifest/DeployementTemplateService_test.go +++ b/pkg/generateManifest/DeployementTemplateService_test.go @@ -65,7 +65,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. deployedOnEnv := []*repository.DeploymentTemplateComparisonMetadata{ { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", EnvironmentId: 1, PipelineConfigOverrideId: 5, @@ -74,7 +74,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "Succeeded", }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", EnvironmentId: 1, PipelineConfigOverrideId: 5, @@ -83,7 +83,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "Succeeded", }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", EnvironmentId: 1, PipelineConfigOverrideId: 5, @@ -95,7 +95,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. deployedOnOtherEnvs := []*repository.DeploymentTemplateComparisonMetadata{ { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", EnvironmentId: 2, PipelineConfigOverrideId: 9, @@ -121,7 +121,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. }, want: []*repository.DeploymentTemplateComparisonMetadata{ { - ChartId: 1, + ChartRefId: 1, ChartVersion: "v1.0.1", ChartType: "Deployment", EnvironmentId: 0, @@ -133,7 +133,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Type: 1, }, { - ChartId: 2, + ChartRefId: 2, ChartVersion: "v1.0.2", ChartType: "Deployment", EnvironmentId: 0, @@ -144,7 +144,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "", Type: 1, }, { - ChartId: 3, + ChartRefId: 3, ChartVersion: "v1.0.3", ChartType: "Deployment", EnvironmentId: 0, @@ -155,7 +155,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "", Type: 1, }, { - ChartId: 2, + ChartRefId: 2, ChartVersion: "", ChartType: "", EnvironmentId: 1, @@ -166,7 +166,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "", Type: 2, }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", ChartType: "", EnvironmentId: 1, @@ -177,7 +177,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "Succeeded", Type: 3, }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", ChartType: "", EnvironmentId: 1, @@ -188,7 +188,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "Succeeded", Type: 3, }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "4.18.1", ChartType: "", EnvironmentId: 1, @@ -199,7 +199,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. Status: "Succeeded", Type: 3, }, { - ChartId: 1, + ChartRefId: 1, ChartVersion: "v1.0.1", ChartType: "Deployment", EnvironmentId: 2, From 7b9be042eba4b731b582e5e62471a13e4410c9b9 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 25 Jan 2024 16:57:00 +0530 Subject: [PATCH 44/83] removed typo --- client/telemetry/TelemetryEventClient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index 5b34cd95c9..c806f42f7f 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -67,7 +67,7 @@ type TelemetryEventClient interface { SendTelemetryDashboardLoggedInEvent() error SendGenericTelemetryEvent(eventType string, prop map[string]interface{}) error SendSummaryEvent(eventType string) error -}w +} func NewTelemetryEventClientImpl(logger *zap.SugaredLogger, client *http.Client, clusterService cluster.ClusterService, K8sUtil *k8s.K8sServiceImpl, aCDAuthConfig *util3.ACDAuthConfig, userService user2.UserService, From 2aa56bfb3a0b415307217a3deacc5a402eec9376 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 25 Jan 2024 17:58:28 +0530 Subject: [PATCH 45/83] changes --- .../gitOps/git/GitOperationService.go | 18 ++++----- pkg/deployment/gitOps/git/GitService.go | 39 ++++--------------- pkg/deployment/gitOps/git/GitServiceAzure.go | 2 +- pkg/deployment/gitOps/git/GitServiceGithub.go | 6 ++- pkg/deployment/gitOps/git/GitServiceGitlab.go | 11 ++++-- pkg/deployment/gitOps/git/GitService_test.go | 3 +- pkg/deployment/gitOps/git/bean/bean.go | 14 +++++++ .../chartRef/ChartRefService.go | 14 ++++--- 8 files changed, 55 insertions(+), 52 deletions(-) diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index 0f9c9e3a18..70c88e3f82 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -34,7 +34,7 @@ type GitOperationService interface { GetRepoUrlByRepoName(repoName string) (string, error) GetClonedDir(chartDir, repoUrl string) (string, error) - CloneDir(repoUrl, chartDir string) (string, error) + CloneInDir(repoUrl, chartDir string) (string, error) } type GitOperationServiceImpl struct { @@ -91,6 +91,7 @@ func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenc tempReferenceTemplateDir string, repoUrl string, userId int32) (err error) { chartDir := fmt.Sprintf("%s-%s", gitOpsRepoName, impl.chartTemplateService.GetDir()) clonedDir, err := impl.GetClonedDir(chartDir, repoUrl) + defer impl.chartTemplateService.CleanDir(clonedDir) if err != nil { impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) return err @@ -101,7 +102,7 @@ func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenc return err } dir := filepath.Join(clonedDir, referenceTemplate, version) - pushChartToGit := true + performFirstCommitPush := true //if chart already exists don't overrides it by reference template if _, err := os.Stat(dir); os.IsNotExist(err) { @@ -128,12 +129,12 @@ func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenc } } else { // chart exists on git, hence not performing first commit - pushChartToGit = false + performFirstCommitPush = false } } // if push needed, then only push - if pushChartToGit { + if performFirstCommitPush { userEmailId, userName := impl.gitOpsConfigReadService.GetUserEmailIdAndNameForGitOpsCommit(userId) commit, err := impl.gitFactory.GitService.CommitAndPushAllChanges(clonedDir, "first commit", userName, userEmailId) if err != nil { @@ -157,7 +158,6 @@ func (impl *GitOperationServiceImpl) PushChartToGitRepo(gitOpsRepoName, referenc impl.logger.Debugw("template committed", "url", repoUrl, "commit", commit) } - defer impl.chartTemplateService.CleanDir(clonedDir) return nil } @@ -176,6 +176,7 @@ func (impl *GitOperationServiceImpl) CreateReadmeInGitRepo(gitOpsRepoName string } _, err = impl.gitFactory.Client.CreateReadme(gitOpsConfig) if err != nil { + impl.logger.Errorw("error in creating readme", "err", err, "gitOpsRepoName", gitOpsRepoName, "userId", userId) return err } return nil @@ -330,9 +331,6 @@ func (impl *GitOperationServiceImpl) CommitValues(chartGitAttr *ChartConfig) (co impl.logger.Errorw("error in git commit", "err", err) return commitHash, commitTime, err } - if commitTime.IsZero() { - commitTime = time.Now() - } return commitHash, commitTime, nil } @@ -385,7 +383,7 @@ func (impl *GitOperationServiceImpl) GetRepoUrlByRepoName(repoName string) (stri func (impl *GitOperationServiceImpl) GetClonedDir(chartDir, repoUrl string) (string, error) { clonedDir := impl.gitFactory.GitService.GetCloneDirectory(chartDir) if _, err := os.Stat(clonedDir); os.IsNotExist(err) { - return impl.CloneDir(repoUrl, chartDir) + return impl.CloneInDir(repoUrl, chartDir) } else if err != nil { impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) return "", err @@ -393,7 +391,7 @@ func (impl *GitOperationServiceImpl) GetClonedDir(chartDir, repoUrl string) (str return clonedDir, nil } -func (impl *GitOperationServiceImpl) CloneDir(repoUrl, chartDir string) (string, error) { +func (impl *GitOperationServiceImpl) CloneInDir(repoUrl, chartDir string) (string, error) { clonedDir, err := impl.gitFactory.GitService.Clone(repoUrl, chartDir) if err != nil { impl.logger.Errorw("error in cloning repo", "url", repoUrl, "err", err) diff --git a/pkg/deployment/gitOps/git/GitService.go b/pkg/deployment/gitOps/git/GitService.go index 20105abe01..7577f2c8ae 100644 --- a/pkg/deployment/gitOps/git/GitService.go +++ b/pkg/deployment/gitOps/git/GitService.go @@ -20,6 +20,8 @@ package git import ( "context" "fmt" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/adapter" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "github.com/devtron-labs/devtron/util" "path/filepath" "time" @@ -122,18 +124,7 @@ func (factory *GitFactory) NewClientForValidation(gitOpsConfig *bean2.GitOpsConf defer func() { util.TriggerGitOpsMetrics("NewClientForValidation", "GitService", start, err) }() - cfg := &GitConfig{ - GitlabGroupId: gitOpsConfig.GitLabGroupId, - GitToken: gitOpsConfig.Token, - GitUserName: gitOpsConfig.Username, - GithubOrganization: gitOpsConfig.GitHubOrgId, - GitProvider: gitOpsConfig.Provider, - GitHost: gitOpsConfig.Host, - AzureToken: gitOpsConfig.Token, - AzureProject: gitOpsConfig.AzureProjectName, - BitbucketWorkspaceId: gitOpsConfig.BitBucketWorkspaceId, - BitbucketProjectKey: gitOpsConfig.BitBucketProjectKey, - } + cfg := adapter.ConvertGitOpsConfigToGitConfig(gitOpsConfig) gitService := NewGitServiceImpl(cfg, factory.logger, factory.gitCliUtil) //factory.GitService = GitService client, err := NewGitOpsClient(cfg, factory.logger, gitService) @@ -164,21 +155,7 @@ func NewGitFactory(logger *zap.SugaredLogger, gitOpsRepository repository.GitOps }, nil } -type GitConfig struct { - GitlabGroupId string //local - GitlabGroupPath string //local - GitToken string //not null // public - GitUserName string //not null // public - GithubOrganization string - GitProvider string // SUPPORTED VALUES GITHUB, GITLAB - GitHost string - AzureToken string - AzureProject string - BitbucketWorkspaceId string - BitbucketProjectKey string -} - -func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfig, error) { +func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*bean.GitConfig, error) { gitOpsConfig, err := gitOpsRepository.GetGitOpsConfigActive() if err != nil && err != pg.ErrNoRows { return nil, err @@ -187,13 +164,13 @@ func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfi // cfg := &GitConfig{} // err := env.Parse(cfg) // return cfg, err - return &GitConfig{}, nil + return &bean.GitConfig{}, nil } if gitOpsConfig == nil || gitOpsConfig.Id == 0 { return nil, err } - cfg := &GitConfig{ + cfg := &bean.GitConfig{ GitlabGroupId: gitOpsConfig.GitLabGroupId, GitToken: gitOpsConfig.Token, GitUserName: gitOpsConfig.Username, @@ -208,7 +185,7 @@ func GetGitConfig(gitOpsRepository repository.GitOpsConfigRepository) (*GitConfi return cfg, err } -func NewGitOpsClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { +func NewGitOpsClient(config *bean.GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { if config.GitProvider == GITLAB_PROVIDER { gitLabClient, err := NewGitLabClient(config, logger, gitService) return gitLabClient, err @@ -252,7 +229,7 @@ type GitServiceImpl struct { gitCliUtil *GitCliUtil } -func NewGitServiceImpl(config *GitConfig, logger *zap.SugaredLogger, GitCliUtil *GitCliUtil) *GitServiceImpl { +func NewGitServiceImpl(config *bean.GitConfig, logger *zap.SugaredLogger, GitCliUtil *GitCliUtil) *GitServiceImpl { auth := &http.BasicAuth{Password: config.GitToken, Username: config.GitUserName} return &GitServiceImpl{ Auth: auth, diff --git a/pkg/deployment/gitOps/git/GitServiceAzure.go b/pkg/deployment/gitOps/git/GitServiceAzure.go index b1fd155d1e..d474070f3d 100644 --- a/pkg/deployment/gitOps/git/GitServiceAzure.go +++ b/pkg/deployment/gitOps/git/GitServiceAzure.go @@ -233,7 +233,7 @@ func (impl GitAzureClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2 } //gitPush.Commits commitId := "" - commitAuthorTime := time.Time{} + commitAuthorTime := time.Now() //default is current time, if found then will get updated accordingly if len(*push.Commits) > 0 { commitId = *(*push.Commits)[0].CommitId commitAuthorTime = (*push.Commits)[0].Author.Date.Time diff --git a/pkg/deployment/gitOps/git/GitServiceGithub.go b/pkg/deployment/gitOps/git/GitServiceGithub.go index 0969370cd4..2d4fc52fbf 100644 --- a/pkg/deployment/gitOps/git/GitServiceGithub.go +++ b/pkg/deployment/gitOps/git/GitServiceGithub.go @@ -191,7 +191,11 @@ func (impl GitHubClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.G impl.logger.Errorw("error in commit github", "err", err, "config", config) return "", time.Time{}, err } - return *c.SHA, *c.Commit.Author.Date, nil + commitTime = time.Now() // default is current time, if found then will get updated accordingly + if c != nil && c.Commit.Author != nil { + commitTime = *c.Commit.Author.Date + } + return *c.SHA, commitTime, nil } func (impl GitHubClient) GetRepoUrl(config *bean2.GitOpsConfigDto) (repoUrl string, err error) { diff --git a/pkg/deployment/gitOps/git/GitServiceGitlab.go b/pkg/deployment/gitOps/git/GitServiceGitlab.go index bf4a69cc63..12eb11e85e 100644 --- a/pkg/deployment/gitOps/git/GitServiceGitlab.go +++ b/pkg/deployment/gitOps/git/GitServiceGitlab.go @@ -3,6 +3,7 @@ package git import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "github.com/xanzy/go-gitlab" "go.uber.org/zap" "net/url" @@ -13,12 +14,12 @@ import ( type GitLabClient struct { client *gitlab.Client - config *GitConfig + config *bean.GitConfig logger *zap.SugaredLogger gitService GitService } -func NewGitLabClient(config *GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { +func NewGitLabClient(config *bean.GitConfig, logger *zap.SugaredLogger, gitService GitService) (GitClient, error) { gitLabClient, err := CreateGitlabClient(config.GitHost, config.GitToken) if err != nil { logger.Errorw("error in creating gitlab client", "err", err) @@ -275,5 +276,9 @@ func (impl GitLabClient) CommitValues(config *ChartConfig, gitOpsConfig *bean2.G if err != nil { return "", time.Time{}, err } - return c.ID, *c.AuthoredDate, err + commitTime = time.Now() //default is current time, if found then will get updated accordingly + if c != nil { + commitTime = *c.AuthoredDate + } + return c.ID, commitTime, err } diff --git a/pkg/deployment/gitOps/git/GitService_test.go b/pkg/deployment/gitOps/git/GitService_test.go index f23da2212b..3726bfdfcc 100644 --- a/pkg/deployment/gitOps/git/GitService_test.go +++ b/pkg/deployment/gitOps/git/GitService_test.go @@ -3,13 +3,14 @@ package git import ( "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/util" + bean2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "testing" ) func getTestGithubClient() GitHubClient { logger, err := util.NewSugardLogger() gitCliUtl := NewGitCliUtil(logger) - gitService := NewGitServiceImpl(&GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) + gitService := NewGitServiceImpl(&bean2.GitConfig{GitToken: "", GitUserName: "nishant"}, logger, gitCliUtl) githubClient, err := NewGithubClient("", "", "test-org", logger, gitService) if err != nil { diff --git a/pkg/deployment/gitOps/git/bean/bean.go b/pkg/deployment/gitOps/git/bean/bean.go index 361b0ec78c..c806e55251 100644 --- a/pkg/deployment/gitOps/git/bean/bean.go +++ b/pkg/deployment/gitOps/git/bean/bean.go @@ -5,3 +5,17 @@ type ChartProxyReqDto struct { AppName string `json:"appName,omitempty"` UserId int32 `json:"-"` } + +type GitConfig struct { + GitlabGroupId string //local + GitlabGroupPath string //local + GitToken string //not null // public + GitUserName string //not null // public + GithubOrganization string + GitProvider string // SUPPORTED VALUES GITHUB, GITLAB + GitHost string + AzureToken string + AzureProject string + BitbucketWorkspaceId string + BitbucketProjectKey string +} diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go index 58964b0876..9db0e2ade5 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -24,8 +24,12 @@ import ( ) type ChartRefService interface { - //below methods are for getting data from db + ChartRefDbReadService + CustomChartService + ChartRefFileOpService +} +type ChartRefDbReadService interface { GetDefault() (*bean.ChartRefDto, error) GetAll() ([]*bean.ChartRefDto, error) GetAllChartMetadata() (map[string]bean.ChartRefMetaData, error) @@ -35,15 +39,15 @@ type ChartRefService interface { ChartRefAutocomplete() ([]*bean.ChartRefAutocompleteDto, error) CheckChartExists(chartRefId int) error ChartRefIdsCompatible(oldChartRefId int, newChartRefId int) (bool, string, string) +} - //below methods are for custom chart - +type CustomChartService interface { SaveCustomChart(req *bean.CustomChartRefDto) error FetchCustomChartsInfo() ([]*bean.ChartDto, error) ValidateCustomChartUploadedFileFormat(fileName string) error +} - //below methods are for chart file data actions - +type ChartRefFileOpService interface { GetAppOverrideForDefaultTemplate(chartRefId int) (map[string]interface{}, string, error) JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, string, error) GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) ([]byte, []byte, error) From 60fcf0a52eb4f82d153ba4df7e7bb460e32d700a Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Thu, 25 Jan 2024 17:59:16 +0530 Subject: [PATCH 46/83] changes --- pkg/deployment/gitOps/git/adapter/adapter.go | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 pkg/deployment/gitOps/git/adapter/adapter.go diff --git a/pkg/deployment/gitOps/git/adapter/adapter.go b/pkg/deployment/gitOps/git/adapter/adapter.go new file mode 100644 index 0000000000..62b7f9c964 --- /dev/null +++ b/pkg/deployment/gitOps/git/adapter/adapter.go @@ -0,0 +1,21 @@ +package adapter + +import ( + bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" +) + +func ConvertGitOpsConfigToGitConfig(dto *bean2.GitOpsConfigDto) *bean.GitConfig { + return &bean.GitConfig{ + GitlabGroupId: dto.GitLabGroupId, + GitToken: dto.Token, + GitUserName: dto.Username, + GithubOrganization: dto.GitHubOrgId, + GitProvider: dto.Provider, + GitHost: dto.Host, + AzureToken: dto.Token, + AzureProject: dto.AzureProjectName, + BitbucketWorkspaceId: dto.BitBucketWorkspaceId, + BitbucketProjectKey: dto.BitBucketProjectKey, + } +} From ecd7cc07a424d1e20154376ad655cb4312bacbc7 Mon Sep 17 00:00:00 2001 From: Asutosh Das Date: Tue, 30 Jan 2024 16:11:03 +0530 Subject: [PATCH 47/83] chore: App store services refactoring (#4596) * chore: fixed test file * chore: app store deployment services refactoring * updated todo --- Wire.go | 15 +- api/appStore/InstalledAppRestHandler.go | 37 +- .../AppStoreDeploymentRestHandler.go | 4 +- .../deployment/CommonDeploymentRestHandler.go | 12 +- .../deployment/wire_appStoreDeployment.go | 15 +- api/appStore/values/wire_appStoreValues.go | 2 +- api/helm-app/HelmAppRestHandler.go | 11 +- api/helm-app/service/HelmAppService.go | 2 +- api/restHandler/AppListingRestHandler.go | 15 +- api/router/pubsub/ApplicationStatusHandler.go | 9 +- .../cron/CdApplicationStatusUpdateHandler.go | 8 +- client/telemetry/TelemetryEventClient.go | 2 +- .../telemetry/TelemetryEventClientExtended.go | 6 +- cmd/external-app/wire.go | 10 +- cmd/external-app/wire_gen.go | 24 +- pkg/app/AppCrudOperationService.go | 2 +- pkg/app/AppService.go | 2 +- .../status/PipelineStatusTimelineService.go | 2 +- pkg/appStore/adapter/Adapter.go | 2 +- pkg/appStore/chartGroup/ChartGroupService.go | 691 +++++++++- .../deployment/service/InstalledAppService.go | 1106 ----------------- .../service/InstalledAppService_test.go | 83 -- .../adapter/Adapter.go | 0 .../ClusterInstalledAppsRepository.go | 0 .../repository/InstalledAppModels.go | 0 .../repository/InstalledAppRepository.go | 0 .../repository/InstalledAppVersionHistory.go | 0 .../service/AppStoreDeploymentDBService.go | 36 +- .../service/AppStoreDeploymentService.go | 212 ++-- .../service/AppStoreDeploymentService_test.go | 2 +- .../EAMode/EAModeDeploymentService.go} | 62 +- .../service/EAMode/InstalledAppDBService.go | 237 ++++ .../FullMode/InstalledAppDBExtendedService.go | 160 +++ .../deployment}/DeploymentStatusService.go | 38 +- .../deployment/FullModeDeploymentService.go} | 251 +--- .../deployment/InstalledAppArgoCdService.go | 208 ++++ .../deployment/InstalledAppGitOpsService.go} | 46 +- .../FullMode/resource/NotesService.go} | 8 +- .../FullMode/resource/ResourceTreeService.go} | 171 ++- .../service}/bean/bean.go | 0 .../common/AppStoreDeploymentCommonService.go | 0 .../values/service/AppStoreValuesService.go | 2 +- pkg/cluster/ClusterServiceExtended.go | 2 +- pkg/delete/DeleteService.go | 2 +- pkg/delete/DeleteServiceExtended.go | 2 +- pkg/deployment/gitOps/wire_gitOps.go | 8 + pkg/pipeline/CdHandler.go | 2 +- pkg/pipeline/WorkflowDagExecutor.go | 26 +- util/rbac/EnforcerUtilHelm.go | 2 +- wire_gen.go | 76 +- 50 files changed, 1820 insertions(+), 1793 deletions(-) delete mode 100644 pkg/appStore/deployment/service/InstalledAppService.go delete mode 100644 pkg/appStore/deployment/service/InstalledAppService_test.go rename pkg/appStore/{deployment => installedApp}/adapter/Adapter.go (100%) rename pkg/appStore/{deployment => installedApp}/repository/ClusterInstalledAppsRepository.go (100%) rename pkg/appStore/{deployment => installedApp}/repository/InstalledAppModels.go (100%) rename pkg/appStore/{deployment => installedApp}/repository/InstalledAppRepository.go (100%) rename pkg/appStore/{deployment => installedApp}/repository/InstalledAppVersionHistory.go (100%) rename pkg/appStore/{deployment => installedApp}/service/AppStoreDeploymentDBService.go (78%) rename pkg/appStore/{deployment => installedApp}/service/AppStoreDeploymentService.go (81%) rename pkg/appStore/{deployment => installedApp}/service/AppStoreDeploymentService_test.go (99%) rename pkg/appStore/{deployment/tool/AppStoreDeploymentHelmService.go => installedApp/service/EAMode/EAModeDeploymentService.go} (76%) create mode 100644 pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go create mode 100644 pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go rename pkg/appStore/{deployment/tool => installedApp/service/FullMode/deployment}/DeploymentStatusService.go (75%) rename pkg/appStore/{deployment/tool/AppStoreDeploymentArgoCdService.go => installedApp/service/FullMode/deployment/FullModeDeploymentService.go} (64%) create mode 100644 pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go rename pkg/appStore/{deployment/tool/AppStoreDeploymentGitOpsService.go => installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go} (76%) rename pkg/appStore/{deployment/service/Notes.go => installedApp/service/FullMode/resource/NotesService.go} (92%) rename pkg/appStore/{deployment/service/ResourceTree.go => installedApp/service/FullMode/resource/ResourceTreeService.go} (64%) rename pkg/appStore/{deployment/tool => installedApp/service}/bean/bean.go (100%) rename pkg/appStore/{deployment => installedApp/service}/common/AppStoreDeploymentCommonService.go (100%) diff --git a/Wire.go b/Wire.go index 1a26330f4d..7edecf73b9 100644 --- a/Wire.go +++ b/Wire.go @@ -89,8 +89,9 @@ import ( "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" + deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bulkAction" @@ -504,8 +505,10 @@ func InitializeApp() (*App, error) { wire.Bind(new(appStoreRestHandler.AppStoreStatusTimelineRestHandler), new(*appStoreRestHandler.AppStoreStatusTimelineRestHandlerImpl)), appStoreRestHandler.NewInstalledAppRestHandlerImpl, wire.Bind(new(appStoreRestHandler.InstalledAppRestHandler), new(*appStoreRestHandler.InstalledAppRestHandlerImpl)), - service.NewInstalledAppServiceImpl, - wire.Bind(new(service.InstalledAppService), new(*service.InstalledAppServiceImpl)), + FullMode.NewInstalledAppDBExtendedServiceImpl, + wire.Bind(new(FullMode.InstalledAppDBExtendedService), new(*FullMode.InstalledAppDBExtendedServiceImpl)), + resource.NewInstalledAppResourceServiceImpl, + wire.Bind(new(resource.InstalledAppResourceService), new(*resource.InstalledAppResourceServiceImpl)), appStoreRestHandler.NewAppStoreRouterImpl, wire.Bind(new(appStoreRestHandler.AppStoreRouter), new(*appStoreRestHandler.AppStoreRouterImpl)), @@ -719,8 +722,8 @@ func InitializeApp() (*App, error) { delete2.NewDeleteServiceFullModeImpl, wire.Bind(new(delete2.DeleteServiceFullMode), new(*delete2.DeleteServiceFullModeImpl)), - appStoreDeploymentGitopsTool.NewAppStoreDeploymentArgoCdServiceImpl, - wire.Bind(new(appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentGitopsTool.AppStoreDeploymentArgoCdServiceImpl)), + deployment3.NewFullModeDeploymentServiceImpl, + wire.Bind(new(deployment3.FullModeDeploymentService), new(*deployment3.FullModeDeploymentServiceImpl)), // util2.NewGoJsonSchemaCustomFormatChecker, //history starts diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index 94399e6a38..a209d1f5b0 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -23,6 +23,8 @@ import ( "errors" "fmt" client "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" "net/http" "strconv" "strings" @@ -39,8 +41,8 @@ import ( app2 "github.com/devtron-labs/devtron/pkg/app" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" @@ -75,7 +77,9 @@ type InstalledAppRestHandlerImpl struct { enforcer casbin.Enforcer enforcerUtil rbac.EnforcerUtil enforcerUtilHelm rbac.EnforcerUtilHelm - installedAppService service.InstalledAppService + installedAppService FullMode.InstalledAppDBExtendedService + installedAppResourceService resource.InstalledAppResourceService + chartGroupService chartGroup.ChartGroupService validator *validator.Validate clusterService cluster.ClusterService acdServiceClient application.ServiceClient @@ -89,10 +93,11 @@ type InstalledAppRestHandlerImpl struct { } func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, installedAppService service.InstalledAppService, - validator *validator.Validate, clusterService cluster.ClusterService, acdServiceClient application.ServiceClient, - appStoreDeploymentService service.AppStoreDeploymentService, helmAppClient client.HelmAppClient, - argoUserService argo.ArgoUserService, + enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, + installedAppService FullMode.InstalledAppDBExtendedService, installedAppResourceService resource.InstalledAppResourceService, + chartGroupService chartGroup.ChartGroupService, validator *validator.Validate, clusterService cluster.ClusterService, + acdServiceClient application.ServiceClient, appStoreDeploymentService service.AppStoreDeploymentService, + helmAppClient client.HelmAppClient, argoUserService argo.ArgoUserService, cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, installedAppRepository repository.InstalledAppRepository, appCrudOperationService app2.AppCrudOperationService) *InstalledAppRestHandlerImpl { @@ -103,6 +108,8 @@ func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService u enforcerUtil: enforcerUtil, enforcerUtilHelm: enforcerUtilHelm, installedAppService: installedAppService, + installedAppResourceService: installedAppResourceService, + chartGroupService: chartGroupService, validator: validator, clusterService: clusterService, acdServiceClient: acdServiceClient, @@ -371,7 +378,7 @@ func (handler *InstalledAppRestHandlerImpl) DeployBulk(w http.ResponseWriter, r return } } - res, err := handler.installedAppService.DeployBulk(&request) + res, err := handler.chartGroupService.DeployBulk(&request) if err != nil { handler.Logger.Errorw("service err, DeployBulk", "err", err, "payload", request) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -433,7 +440,7 @@ func (impl *InstalledAppRestHandlerImpl) DefaultComponentInstallation(w http.Res return } // RBAC enforcer ends - isTriggered, err := impl.installedAppService.DeployDefaultChartOnCluster(cluster, userId) + isTriggered, err := impl.chartGroupService.DeployDefaultChartOnCluster(cluster, userId) if err != nil { impl.Logger.Errorw("service err, DefaultComponentInstallation", "error", err, "cluster", cluster) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -462,7 +469,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchNotesForArgoInstalledApp(w http return } handler.Logger.Infow("request payload, FetchNotesForArgoInstalledApp, app store", "installedAppId", installedAppId, "envId", envId) - notes, err := handler.installedAppService.FetchChartNotes(installedAppId, envId, token, handler.checkNotesAuth) + notes, err := handler.installedAppResourceService.FetchChartNotes(installedAppId, envId, token, handler.checkNotesAuth) if err != nil { handler.Logger.Errorw("service err, FetchNotesFromdb, app store", "err", err, "installedAppId", installedAppId, "envId", envId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -621,7 +628,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledApp(w htt apiError, ok := err.(*util2.ApiError) if ok && apiError != nil { if apiError.Code == constants.AppDetailResourceTreeNotFound && installedApp.DeploymentAppDeleteRequest == true { - err = handler.installedAppService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId) + // TODO refactoring: should be performed through nats + err = handler.appStoreDeploymentService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId) appDeleteErr, appDeleteErrOk := err.(*util2.ApiError) if appDeleteErrOk && appDeleteErr != nil { handler.Logger.Errorw(appDeleteErr.InternalMessage) @@ -738,7 +746,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri apiError, ok := err.(*util2.ApiError) if ok && apiError != nil { if apiError.Code == constants.AppDetailResourceTreeNotFound && installedApp.DeploymentAppDeleteRequest == true { - err = handler.installedAppService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId) + // TODO refactoring: should be performed in go routine + err = handler.appStoreDeploymentService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId) appDeleteErr, appDeleteErrOk := err.(*util2.ApiError) if appDeleteErrOk && appDeleteErr != nil { handler.Logger.Errorw(appDeleteErr.InternalMessage) @@ -825,12 +834,12 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTreeForACDApp(w http.Re func (handler *InstalledAppRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer *bean2.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error { ctx := r.Context() cn, _ := w.(http.CloseNotifier) - err := handler.installedAppService.FetchResourceTree(ctx, cn, resourceTreeAndNotesContainer, installedApp, helmReleaseInstallStatus, status) + err := handler.installedAppResourceService.FetchResourceTree(ctx, cn, resourceTreeAndNotesContainer, installedApp, helmReleaseInstallStatus, status) return err } func (handler *InstalledAppRestHandlerImpl) fetchResourceTreeWithHibernateForACD(w http.ResponseWriter, r *http.Request, appDetail *bean2.AppDetailContainer) { ctx := r.Context() cn, _ := w.(http.CloseNotifier) - handler.installedAppService.FetchResourceTreeWithHibernateForACD(ctx, cn, appDetail) + handler.installedAppResourceService.FetchResourceTreeWithHibernateForACD(ctx, cn, appDetail) } diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index ef8e9a28e6..ab7faf4943 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" service2 "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "net/http" "strconv" "strings" @@ -33,8 +34,7 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/appStore/deployment/CommonDeploymentRestHandler.go b/api/appStore/deployment/CommonDeploymentRestHandler.go index e6b04f65a3..1963952319 100644 --- a/api/appStore/deployment/CommonDeploymentRestHandler.go +++ b/api/appStore/deployment/CommonDeploymentRestHandler.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" service2 "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "net/http" "strconv" "time" @@ -32,7 +33,7 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" util2 "github.com/devtron-labs/devtron/util" @@ -57,6 +58,7 @@ type CommonDeploymentRestHandlerImpl struct { enforcerUtil rbac.EnforcerUtil enforcerUtilHelm rbac.EnforcerUtilHelm appStoreDeploymentService service.AppStoreDeploymentService + installedAppService EAMode.InstalledAppDBService validator *validator.Validate helmAppService service2.HelmAppService helmAppRestHandler client.HelmAppRestHandler @@ -64,7 +66,8 @@ type CommonDeploymentRestHandlerImpl struct { } func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, appStoreDeploymentService service.AppStoreDeploymentService, + enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, + appStoreDeploymentService service.AppStoreDeploymentService, installedAppService EAMode.InstalledAppDBService, validator *validator.Validate, helmAppService service2.HelmAppService, helmAppRestHandler client.HelmAppRestHandler, argoUserService argo.ArgoUserService) *CommonDeploymentRestHandlerImpl { return &CommonDeploymentRestHandlerImpl{ @@ -74,6 +77,7 @@ func NewCommonDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthServi enforcerUtil: enforcerUtil, enforcerUtilHelm: enforcerUtilHelm, appStoreDeploymentService: appStoreDeploymentService, + installedAppService: installedAppService, validator: validator, helmAppService: helmAppService, helmAppRestHandler: helmAppRestHandler, @@ -89,7 +93,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"} return appOfferingMode, installedAppDto, err } - installedAppDto, err = handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedAppDto, err = handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"} return appOfferingMode, installedAppDto, err @@ -115,7 +119,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid installed app id"} return appOfferingMode, installedAppDto, err } - installedAppDto, err = handler.appStoreDeploymentService.GetInstalledAppByInstalledAppId(installedAppId) + installedAppDto, err = handler.installedAppService.GetInstalledAppByInstalledAppId(installedAppId) if err != nil { err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"} return appOfferingMode, installedAppDto, err diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index da9d39a798..7897c45032 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -2,10 +2,10 @@ package appStoreDeployment import ( "github.com/devtron-labs/devtron/client/argocdServer" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/google/wire" ) @@ -15,8 +15,8 @@ var AppStoreDeploymentWireSet = wire.NewSet( wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), - appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl, - wire.Bind(new(appStoreDeploymentTool.AppStoreDeploymentHelmService), new(*appStoreDeploymentTool.AppStoreDeploymentHelmServiceImpl)), + EAMode.NewEAModeDeploymentServiceImpl, + wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), NewAppStoreDeploymentRestHandlerImpl, @@ -31,4 +31,7 @@ var AppStoreDeploymentWireSet = wire.NewSet( NewCommonDeploymentRouterImpl, wire.Bind(new(CommonDeploymentRouter), new(*CommonDeploymentRouterImpl)), argocdServer.GetACDDeploymentConfig, + + EAMode.NewInstalledAppDBServiceImpl, + wire.Bind(new(EAMode.InstalledAppDBService), new(*EAMode.InstalledAppDBServiceImpl)), ) diff --git a/api/appStore/values/wire_appStoreValues.go b/api/appStore/values/wire_appStoreValues.go index 7a21a676e8..2f2157738f 100644 --- a/api/appStore/values/wire_appStoreValues.go +++ b/api/appStore/values/wire_appStoreValues.go @@ -1,7 +1,7 @@ package appStoreValues import ( - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" appStoreValuesRepository "github.com/devtron-labs/devtron/pkg/appStore/values/repository" "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/google/wire" diff --git a/api/helm-app/HelmAppRestHandler.go b/api/helm-app/HelmAppRestHandler.go index 45e504c08f..6990ad279e 100644 --- a/api/helm-app/HelmAppRestHandler.go +++ b/api/helm-app/HelmAppRestHandler.go @@ -6,7 +6,8 @@ import ( "errors" "github.com/devtron-labs/devtron/api/helm-app/bean" service2 "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "net/http" "strconv" "strings" @@ -50,6 +51,7 @@ type HelmAppRestHandlerImpl struct { clusterService cluster.ClusterService enforcerUtil rbac.EnforcerUtilHelm appStoreDeploymentService service.AppStoreDeploymentService + installedAppService EAMode.InstalledAppDBService userAuthService user.UserService attributesService attributes.AttributesService serverEnvConfig *serverEnvConfig.ServerEnvConfig @@ -58,7 +60,7 @@ type HelmAppRestHandlerImpl struct { func NewHelmAppRestHandlerImpl(logger *zap.SugaredLogger, helmAppService service2.HelmAppService, enforcer casbin.Enforcer, clusterService cluster.ClusterService, enforcerUtil rbac.EnforcerUtilHelm, - appStoreDeploymentService service.AppStoreDeploymentService, + appStoreDeploymentService service.AppStoreDeploymentService, installedAppService EAMode.InstalledAppDBService, userAuthService user.UserService, attributesService attributes.AttributesService, serverEnvConfig *serverEnvConfig.ServerEnvConfig) *HelmAppRestHandlerImpl { return &HelmAppRestHandlerImpl{ logger: logger, @@ -67,6 +69,7 @@ func NewHelmAppRestHandlerImpl(logger *zap.SugaredLogger, clusterService: clusterService, enforcerUtil: enforcerUtil, appStoreDeploymentService: appStoreDeploymentService, + installedAppService: installedAppService, userAuthService: userAuthService, attributesService: attributesService, serverEnvConfig: serverEnvConfig, @@ -120,7 +123,7 @@ func (handler *HelmAppRestHandlerImpl) GetApplicationDetail(w http.ResponseWrite return } - installedApp, err := handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedApp, err := handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return @@ -221,7 +224,7 @@ func (handler *HelmAppRestHandlerImpl) GetReleaseInfo(w http.ResponseWriter, r * common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } - installedApp, err := handler.appStoreDeploymentService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) + installedApp, err := handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) if err != nil { common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return diff --git a/api/helm-app/service/HelmAppService.go b/api/helm-app/service/HelmAppService.go index 5d98580ca7..f14a52806f 100644 --- a/api/helm-app/service/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -26,8 +26,8 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" serverBean "github.com/devtron-labs/devtron/pkg/server/bean" diff --git a/api/restHandler/AppListingRestHandler.go b/api/restHandler/AppListingRestHandler.go index 6c20e37b98..59b922f6c1 100644 --- a/api/restHandler/AppListingRestHandler.go +++ b/api/restHandler/AppListingRestHandler.go @@ -23,6 +23,8 @@ import ( "fmt" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" "net/http" "strconv" "strings" @@ -45,8 +47,7 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appStatus" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - service1 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" @@ -106,7 +107,8 @@ type AppListingRestHandlerImpl struct { helmAppService client.HelmAppService argoUserService argo.ArgoUserService k8sCommonService k8s.K8sCommonService - installedAppService service1.InstalledAppService + installedAppService FullMode.InstalledAppDBExtendedService + installedAppResourceService resource.InstalledAppResourceService cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler pipelineRepository pipelineConfig.PipelineRepository appStatusService appStatus.AppStatusService @@ -140,7 +142,9 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient, logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil, deploymentGroupService deploymentGroup.DeploymentGroupService, userService user.UserService, helmAppClient gRPC.HelmAppClient, clusterService cluster.ClusterService, helmAppService client.HelmAppService, - argoUserService argo.ArgoUserService, k8sCommonService k8s.K8sCommonService, installedAppService service1.InstalledAppService, + argoUserService argo.ArgoUserService, k8sCommonService k8s.K8sCommonService, + installedAppService FullMode.InstalledAppDBExtendedService, + installedAppResourceService resource.InstalledAppResourceService, cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, pipelineRepository pipelineConfig.PipelineRepository, appStatusService appStatus.AppStatusService, installedAppRepository repository.InstalledAppRepository, @@ -171,6 +175,7 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient, argoUserService: argoUserService, k8sCommonService: k8sCommonService, installedAppService: installedAppService, + installedAppResourceService: installedAppResourceService, cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, pipelineRepository: pipelineRepository, appStatusService: appStatusService, @@ -1349,7 +1354,7 @@ func (handler AppListingRestHandlerImpl) RedirectToLinkouts(w http.ResponseWrite func (handler AppListingRestHandlerImpl) fetchResourceTreeFromInstallAppService(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer bean.AppDetailsContainer, installedApps repository.InstalledApps) (bean.AppDetailsContainer, error) { rctx := r.Context() cn, _ := w.(http.CloseNotifier) - err := handler.installedAppService.FetchResourceTree(rctx, cn, &resourceTreeAndNotesContainer, installedApps, "", "") + err := handler.installedAppResourceService.FetchResourceTree(rctx, cn, &resourceTreeAndNotesContainer, installedApps, "", "") return resourceTreeAndNotesContainer, err } func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWriter, r *http.Request) { diff --git a/api/router/pubsub/ApplicationStatusHandler.go b/api/router/pubsub/ApplicationStatusHandler.go index 3767a44f1e..df6a20cbab 100644 --- a/api/router/pubsub/ApplicationStatusHandler.go +++ b/api/router/pubsub/ApplicationStatusHandler.go @@ -24,18 +24,19 @@ import ( "fmt" "github.com/devtron-labs/common-lib/pubsub-lib/model" "github.com/devtron-labs/devtron/pkg/app" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "k8s.io/utils/pointer" "time" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/bean" "k8s.io/utils/strings/slices" v1alpha12 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/go-pg/pg" "go.uber.org/zap" @@ -51,7 +52,7 @@ type ApplicationStatusHandlerImpl struct { pubsubClient *pubsub.PubSubClientServiceImpl appService app.AppService workflowDagExecutor pipeline.WorkflowDagExecutor - installedAppService service.InstalledAppService + installedAppService FullMode.InstalledAppDBExtendedService appStoreDeploymentService service.AppStoreDeploymentService pipelineBuilder pipeline.PipelineBuilder pipelineRepository pipelineConfig.PipelineRepository @@ -59,7 +60,7 @@ type ApplicationStatusHandlerImpl struct { } func NewApplicationStatusHandlerImpl(logger *zap.SugaredLogger, pubsubClient *pubsub.PubSubClientServiceImpl, appService app.AppService, - workflowDagExecutor pipeline.WorkflowDagExecutor, installedAppService service.InstalledAppService, + workflowDagExecutor pipeline.WorkflowDagExecutor, installedAppService FullMode.InstalledAppDBExtendedService, appStoreDeploymentService service.AppStoreDeploymentService, pipelineBuilder pipeline.PipelineBuilder, pipelineRepository pipelineConfig.PipelineRepository, installedAppRepository repository4.InstalledAppRepository) *ApplicationStatusHandlerImpl { appStatusUpdateHandlerImpl := &ApplicationStatusHandlerImpl{ diff --git a/client/cron/CdApplicationStatusUpdateHandler.go b/client/cron/CdApplicationStatusUpdateHandler.go index f9d377112d..ec277f9818 100644 --- a/client/cron/CdApplicationStatusUpdateHandler.go +++ b/client/cron/CdApplicationStatusUpdateHandler.go @@ -12,8 +12,8 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" util2 "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/util" cron2 "github.com/devtron-labs/devtron/util/cron" @@ -39,7 +39,7 @@ type CdApplicationStatusUpdateHandlerImpl struct { cron *cron.Cron appService app.AppService workflowDagExecutor pipeline.WorkflowDagExecutor - installedAppService service.InstalledAppService + installedAppService EAMode.InstalledAppDBService CdHandler pipeline.CdHandler AppStatusConfig *app.AppServiceConfig pubsubClient *pubsub.PubSubClientServiceImpl @@ -53,7 +53,7 @@ type CdApplicationStatusUpdateHandlerImpl struct { } func NewCdApplicationStatusUpdateHandlerImpl(logger *zap.SugaredLogger, appService app.AppService, - workflowDagExecutor pipeline.WorkflowDagExecutor, installedAppService service.InstalledAppService, + workflowDagExecutor pipeline.WorkflowDagExecutor, installedAppService EAMode.InstalledAppDBService, CdHandler pipeline.CdHandler, AppStatusConfig *app.AppServiceConfig, pubsubClient *pubsub.PubSubClientServiceImpl, pipelineStatusTimelineRepository pipelineConfig.PipelineStatusTimelineRepository, eventClient client2.EventClient, appListingRepository repository.AppListingRepository, diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index 8449e756c5..352e51ff37 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -14,7 +14,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/sql/repository" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/sso" user2 "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/client/telemetry/TelemetryEventClientExtended.go b/client/telemetry/TelemetryEventClientExtended.go index 92961ab549..2a8e725546 100644 --- a/client/telemetry/TelemetryEventClientExtended.go +++ b/client/telemetry/TelemetryEventClientExtended.go @@ -14,7 +14,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/sso" user2 "github.com/devtron-labs/devtron/pkg/auth/user" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" @@ -63,7 +63,7 @@ func NewTelemetryEventClientImplExtended(logger *zap.SugaredLogger, client *http chartRepository chartRepoRepository.ChartRepository, userAuditService user2.UserAuditService, ciBuildConfigService pipeline.CiBuildConfigService, moduleRepository moduleRepo.ModuleRepository, serverDataStore *serverDataStore.ServerDataStore, helmAppClient client.HelmAppClient, InstalledAppRepository repository2.InstalledAppRepository, userAttributesRepository repository.UserAttributesRepository, - cloudProviderIdentifierService cloudProviderIdentifier.ProviderIdentifierService,cronLogger *cron3.CronLoggerImpl, + cloudProviderIdentifierService cloudProviderIdentifier.ProviderIdentifierService, cronLogger *cron3.CronLoggerImpl, gitOpsConfigReadService config.GitOpsConfigReadService) (*TelemetryEventClientImplExtended, error) { cron := cron.New( @@ -102,7 +102,7 @@ func NewTelemetryEventClientImplExtended(logger *zap.SugaredLogger, client *http InstalledAppRepository: InstalledAppRepository, userAttributesRepository: userAttributesRepository, cloudProviderIdentifierService: cloudProviderIdentifierService, - telemetryConfig: TelemetryConfig{}, + telemetryConfig: TelemetryConfig{}, }, } diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 4c94633236..30acc2fa2a 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -40,11 +40,11 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/attributes" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/pipeline" @@ -82,7 +82,7 @@ func InitializeApp() (*App, error) { apiToken.ApiTokenWireSet, webhookHelm.WebhookHelmWireSet, terminal.TerminalWireSet, - gitOps.GitOpsWireSet, + gitOps.GitOpsEAWireSet, NewApp, NewMuxRouter, util3.GetGlobalEnvVariables, @@ -141,7 +141,7 @@ func InitializeApp() (*App, error) { // // needed for enforcer util ends // binding gitops to helm (for hyperion) - wire.Bind(new(appStoreDeploymentTool.AppStoreDeploymentArgoCdService), new(*appStoreDeploymentTool.AppStoreDeploymentHelmServiceImpl)), + wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), router.NewTelemetryRouterImpl, wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), @@ -177,8 +177,6 @@ func InitializeApp() (*App, error) { util.NewChartTemplateServiceImpl, wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - git.NewGitFactory, - git.NewGitCliUtil, security2.NewScanToolMetadataRepositoryImpl, wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index badb07718f..886d7c3835 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -50,12 +50,12 @@ import ( app2 "github.com/devtron-labs/devtron/pkg/app" repository7 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - service2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service3 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" service4 "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/devtron-labs/devtron/pkg/attributes" @@ -71,7 +71,6 @@ import ( "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/genericNotes" repository6 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" @@ -237,7 +236,7 @@ func InitializeApp() (*App, error) { dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) chartGroupDeploymentRepositoryImpl := repository7.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) + eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) @@ -255,15 +254,10 @@ func InitializeApp() (*App, error) { return nil, err } gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) - gitCliUtil := git.NewGitCliUtil(sugaredLogger) - gitFactory, err := git.NewGitFactory(sugaredLogger, gitOpsConfigRepositoryImpl, gitCliUtil) - if err != nil { - return nil, err - } - gitOperationServiceImpl := git.NewGitOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentHelmServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) - helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) + helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sServiceImpl, clusterServiceImpl) environmentRestHandlerImpl := cluster2.NewEnvironmentRestHandlerImpl(environmentServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceImpl, k8sServiceImpl, k8sCommonServiceImpl) @@ -310,7 +304,7 @@ func InitializeApp() (*App, error) { } dashboardTelemetryRestHandlerImpl := dashboardEvent.NewDashboardTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImpl) dashboardTelemetryRouterImpl := dashboardEvent.NewDashboardTelemetryRouterImpl(dashboardTelemetryRestHandlerImpl) - commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, helmUserServiceImpl) + commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, helmUserServiceImpl) commonDeploymentRouterImpl := appStoreDeployment.NewCommonDeploymentRouterImpl(commonDeploymentRestHandlerImpl) externalLinkMonitoringToolRepositoryImpl := externalLink.NewExternalLinkMonitoringToolRepositoryImpl(db) externalLinkIdentifierMappingRepositoryImpl := externalLink.NewExternalLinkIdentifierMappingRepositoryImpl(db) diff --git a/pkg/app/AppCrudOperationService.go b/pkg/app/AppCrudOperationService.go index 29add13ad4..377144e0bf 100644 --- a/pkg/app/AppCrudOperationService.go +++ b/pkg/app/AppCrudOperationService.go @@ -29,7 +29,7 @@ import ( appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/genericNotes" diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 62a158d4af..a6b137ee05 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -39,7 +39,7 @@ import ( k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8s/health" status2 "github.com/devtron-labs/devtron/pkg/app/status" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" bean2 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" "github.com/devtron-labs/devtron/pkg/variables" diff --git a/pkg/app/status/PipelineStatusTimelineService.go b/pkg/app/status/PipelineStatusTimelineService.go index f85a35e30f..31413f262e 100644 --- a/pkg/app/status/PipelineStatusTimelineService.go +++ b/pkg/app/status/PipelineStatusTimelineService.go @@ -6,7 +6,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go index 4065e755d0..e24837b9e2 100644 --- a/pkg/appStore/adapter/Adapter.go +++ b/pkg/appStore/adapter/Adapter.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" ) // NewInstallAppModel is used to generate new repository.InstalledApps model to be saved; diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index 7036d946a5..d22b66a58d 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -18,12 +18,37 @@ package chartGroup import ( + "bytes" + "context" + "crypto/sha1" + "encoding/json" "errors" + "fmt" + pubsub "github.com/devtron-labs/common-lib/pubsub-lib" + "github.com/devtron-labs/common-lib/pubsub-lib/model" + "github.com/devtron-labs/devtron/client/argocdServer" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/app/status" + appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + "github.com/devtron-labs/devtron/pkg/appStore/values/service" + cluster2 "github.com/devtron-labs/devtron/pkg/cluster" + repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" + repository4 "github.com/devtron-labs/devtron/pkg/team" + "github.com/devtron-labs/devtron/util/argo" + "io/ioutil" + "os" + "strconv" + "strings" "time" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository2 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" appStoreValuesRepository "github.com/devtron-labs/devtron/pkg/appStore/values/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/auth/user/bean" @@ -33,28 +58,74 @@ import ( ) type ChartGroupServiceImpl struct { - chartGroupEntriesRepository repository2.ChartGroupEntriesRepository - chartGroupRepository repository2.ChartGroupReposotory - Logger *zap.SugaredLogger - chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository - installedAppRepository repository.InstalledAppRepository - appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository - userAuthService user.UserAuthService + logger *zap.SugaredLogger + chartGroupEntriesRepository repository2.ChartGroupEntriesRepository + chartGroupRepository repository2.ChartGroupReposotory + chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository + installedAppRepository repository.InstalledAppRepository + appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository + userAuthService user.UserAuthService + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository + environmentRepository repository5.EnvironmentRepository + teamRepository repository4.TeamRepository + appStoreValuesService service.AppStoreValuesService + pubSubClient *pubsub.PubSubClientServiceImpl + envService cluster2.EnvironmentService + appStoreDeploymentService service2.AppStoreDeploymentService + argoUserService argo.ArgoUserService + pipelineStatusTimelineService status.PipelineStatusTimelineService + acdConfig *argocdServer.ACDConfig + fullModeDeploymentService deployment.FullModeDeploymentService + gitOperationService git.GitOperationService } -func NewChartGroupServiceImpl(chartGroupEntriesRepository repository2.ChartGroupEntriesRepository, +func NewChartGroupServiceImpl(logger *zap.SugaredLogger, + chartGroupEntriesRepository repository2.ChartGroupEntriesRepository, chartGroupRepository repository2.ChartGroupReposotory, - Logger *zap.SugaredLogger, chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, - installedAppRepository repository.InstalledAppRepository, appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository, userAuthService user.UserAuthService) *ChartGroupServiceImpl { - return &ChartGroupServiceImpl{ - chartGroupEntriesRepository: chartGroupEntriesRepository, - chartGroupRepository: chartGroupRepository, - Logger: Logger, - chartGroupDeploymentRepository: chartGroupDeploymentRepository, - installedAppRepository: installedAppRepository, - appStoreVersionValuesRepository: appStoreVersionValuesRepository, - userAuthService: userAuthService, + chartGroupDeploymentRepository repository2.ChartGroupDeploymentRepository, + installedAppRepository repository.InstalledAppRepository, + appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository, + userAuthService user.UserAuthService, + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, + environmentRepository repository5.EnvironmentRepository, + teamRepository repository4.TeamRepository, + appStoreValuesService service.AppStoreValuesService, + pubSubClient *pubsub.PubSubClientServiceImpl, + envService cluster2.EnvironmentService, + appStoreDeploymentService service2.AppStoreDeploymentService, + argoUserService argo.ArgoUserService, + pipelineStatusTimelineService status.PipelineStatusTimelineService, + acdConfig *argocdServer.ACDConfig, + fullModeDeploymentService deployment.FullModeDeploymentService, + gitOperationService git.GitOperationService) (*ChartGroupServiceImpl, error) { + impl := &ChartGroupServiceImpl{ + logger: logger, + chartGroupEntriesRepository: chartGroupEntriesRepository, + chartGroupRepository: chartGroupRepository, + chartGroupDeploymentRepository: chartGroupDeploymentRepository, + installedAppRepository: installedAppRepository, + appStoreVersionValuesRepository: appStoreVersionValuesRepository, + userAuthService: userAuthService, + appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, + environmentRepository: environmentRepository, + teamRepository: teamRepository, + appStoreValuesService: appStoreValuesService, + pubSubClient: pubSubClient, + envService: envService, + appStoreDeploymentService: appStoreDeploymentService, + argoUserService: argoUserService, + pipelineStatusTimelineService: pipelineStatusTimelineService, + acdConfig: acdConfig, + fullModeDeploymentService: fullModeDeploymentService, + gitOperationService: gitOperationService, } + + err := impl.subscribe() + if err != nil { + impl.logger.Errorw("error in nats subscription", "topic", pubsub.BULK_APPSTORE_DEPLOY_TOPIC, "err", err) + return nil, err + } + return impl, nil } type ChartGroupService interface { @@ -66,6 +137,9 @@ type ChartGroupService interface { GetChartGroupWithInstallationDetail(chartGroupId int) (*ChartGroupBean, error) ChartGroupListMin(max int) ([]*ChartGroupBean, error) DeleteChartGroup(req *ChartGroupBean) error + + DeployBulk(chartGroupInstallRequest *ChartGroupInstallRequest) (*ChartGroupInstallAppRes, error) + DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) } type ChartGroupList struct { @@ -114,15 +188,15 @@ type InstalledChart struct { const AppNameAlreadyExistsError = "A chart with this name already exist" func (impl *ChartGroupServiceImpl) CreateChartGroup(req *ChartGroupBean) (*ChartGroupBean, error) { - impl.Logger.Debugw("chart group create request", "req", req) + impl.logger.Debugw("chart group create request", "req", req) exist, err := impl.chartGroupRepository.FindByName(req.Name) if err != nil { - impl.Logger.Errorw("error in creating chart group", "req", req, "err", err) + impl.logger.Errorw("error in creating chart group", "req", req, "err", err) return nil, err } if exist { - impl.Logger.Errorw("Chart with this name already exist", "req", req, "err", err) + impl.logger.Errorw("Chart with this name already exist", "req", req, "err", err) return nil, errors.New(AppNameAlreadyExistsError) } @@ -138,7 +212,7 @@ func (impl *ChartGroupServiceImpl) CreateChartGroup(req *ChartGroupBean) (*Chart } group, err := impl.chartGroupRepository.Save(chartGrouModel) if err != nil { - impl.Logger.Errorw("error in creating chart group", "req", chartGrouModel, "err", err) + impl.logger.Errorw("error in creating chart group", "req", chartGrouModel, "err", err) return nil, err } req.Id = group.Id @@ -146,7 +220,7 @@ func (impl *ChartGroupServiceImpl) CreateChartGroup(req *ChartGroupBean) (*Chart } func (impl *ChartGroupServiceImpl) UpdateChartGroup(req *ChartGroupBean) (*ChartGroupBean, error) { - impl.Logger.Debugw("chart group update request", "req", req) + impl.logger.Debugw("chart group update request", "req", req) chartGrouModel := &repository2.ChartGroup{ Name: req.Name, Description: req.Description, @@ -159,7 +233,7 @@ func (impl *ChartGroupServiceImpl) UpdateChartGroup(req *ChartGroupBean) (*Chart group, err := impl.chartGroupRepository.Update(chartGrouModel) if err != nil { - impl.Logger.Errorw("error in update chart group", "req", chartGrouModel, "err", err) + impl.logger.Errorw("error in update chart group", "req", chartGrouModel, "err", err) return nil, err } req.Id = group.Id @@ -169,7 +243,7 @@ func (impl *ChartGroupServiceImpl) UpdateChartGroup(req *ChartGroupBean) (*Chart func (impl *ChartGroupServiceImpl) SaveChartGroupEntries(req *ChartGroupBean) (*ChartGroupBean, error) { group, err := impl.chartGroupRepository.FindByIdWithEntries(req.Id) if err != nil { - impl.Logger.Errorw("error in fetching chart group", "id", req.Id, "err", err) + impl.logger.Errorw("error in fetching chart group", "id", req.Id, "err", err) return nil, err } var newEntries []*ChartGroupEntryBean @@ -216,10 +290,10 @@ func (impl *ChartGroupServiceImpl) SaveChartGroupEntries(req *ChartGroupBean) (* } finalEntries, err := impl.chartGroupEntriesRepository.SaveAndUpdateInTransaction(createEntries, updateEntries) if err != nil { - impl.Logger.Errorw("error in adding entries", "err", err) + impl.logger.Errorw("error in adding entries", "err", err) return nil, err } - impl.Logger.Debugw("all entries,", "entry", finalEntries) + impl.logger.Debugw("all entries,", "entry", finalEntries) return impl.GetChartGroupWithChartMetaData(req.Id) } @@ -340,7 +414,7 @@ func (impl *ChartGroupServiceImpl) GetChartGroupWithInstallationDetail(chartGrou } deployments, err := impl.chartGroupDeploymentRepository.FindByChartGroupId(chartGroupId) if err != nil { - impl.Logger.Errorw("error in finding deployment", "chartGroupId", chartGroupId, "err", err) + impl.logger.Errorw("error in finding deployment", "chartGroupId", chartGroupId, "err", err) return nil, err } groupDeploymentMap := make(map[string][]*repository2.ChartGroupDeployment) @@ -431,13 +505,13 @@ func (impl *ChartGroupServiceImpl) DeleteChartGroup(req *ChartGroupBean) error { //finding existing existingChartGroup, err := impl.chartGroupRepository.FindById(req.Id) if err != nil { - impl.Logger.Errorw("No matching entry found for delete.", "err", err, "id", req.Id) + impl.logger.Errorw("No matching entry found for delete.", "err", err, "id", req.Id) return err } //finding chart mappings by group id chartGroupMappings, err := impl.chartGroupEntriesRepository.FindEntriesWithChartMetaByChartGroupId([]int{req.Id}) if err != nil && err != pg.ErrNoRows { - impl.Logger.Errorw("error in getting chart group entries, DeleteChartGroup", "err", err, "chartGroupId", req.Id) + impl.logger.Errorw("error in getting chart group entries, DeleteChartGroup", "err", err, "chartGroupId", req.Id) return err } var chartGroupMappingIds []int @@ -447,7 +521,7 @@ func (impl *ChartGroupServiceImpl) DeleteChartGroup(req *ChartGroupBean) error { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { - impl.Logger.Errorw("error in establishing connection", "err", err) + impl.logger.Errorw("error in establishing connection", "err", err) return err } // Rollback tx on error. @@ -457,20 +531,20 @@ func (impl *ChartGroupServiceImpl) DeleteChartGroup(req *ChartGroupBean) error { if len(chartGroupMappingIds) > 0 { _, err = impl.chartGroupEntriesRepository.MarkChartGroupEntriesDeleted(chartGroupMappingIds, tx) if err != nil { - impl.Logger.Errorw("error in deleting chart group mappings", "err", err) + impl.logger.Errorw("error in deleting chart group mappings", "err", err) return err } } //deleting chart group err = impl.chartGroupRepository.MarkChartGroupDeleted(existingChartGroup.Id, tx) if err != nil { - impl.Logger.Errorw("error in deleting chart group", "err", err, "chartGroupId", existingChartGroup.Id) + impl.logger.Errorw("error in deleting chart group", "err", err, "chartGroupId", existingChartGroup.Id) return err } //deleting auth roles entries for this chart group err = impl.userAuthService.DeleteRoles(bean.CHART_GROUP_TYPE, req.Name, tx, "", "") if err != nil { - impl.Logger.Errorw("error in deleting auth roles", "err", err) + impl.logger.Errorw("error in deleting auth roles", "err", err) return err } err = tx.Commit() @@ -479,3 +553,550 @@ func (impl *ChartGroupServiceImpl) DeleteChartGroup(req *ChartGroupBean) error { } return nil } + +func (impl *ChartGroupServiceImpl) DeployBulk(chartGroupInstallRequest *ChartGroupInstallRequest) (*ChartGroupInstallAppRes, error) { + impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) + //save in db + // raise nats event + + var installAppVersionDTOList []*appStoreBean.InstallAppVersionDTO + for _, chartGroupInstall := range chartGroupInstallRequest.ChartGroupInstallChartRequest { + installAppVersionDTO, err := impl.requestBuilderForBulkDeployment(chartGroupInstall, chartGroupInstallRequest.ProjectId, chartGroupInstallRequest.UserId) + if err != nil { + impl.logger.Errorw("DeployBulk, error in request builder", "err", err) + return nil, err + } + installAppVersionDTOList = append(installAppVersionDTOList, installAppVersionDTO) + } + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return nil, err + } + var installAppVersions []*appStoreBean.InstallAppVersionDTO + // Rollback tx on error. + defer tx.Rollback() + for _, installAppVersionDTO := range installAppVersionDTOList { + installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) + if err != nil { + impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) + return nil, err + } + installAppVersions = append(installAppVersions, installAppVersionDTO) + } + if chartGroupInstallRequest.ChartGroupId > 0 { + groupINstallationId, err := getInstallationId(installAppVersions) + if err != nil { + return nil, err + } + for _, installAppVersionDTO := range installAppVersions { + chartGroupEntry := createChartGroupEntryObject(installAppVersionDTO, chartGroupInstallRequest.ChartGroupId, groupINstallationId) + err := impl.chartGroupDeploymentRepository.Save(tx, chartGroupEntry) + if err != nil { + impl.logger.Errorw("DeployBulk, error in creating ChartGroupEntryObject", "err", err) + return nil, err + } + } + } + //commit transaction + err = tx.Commit() + if err != nil { + impl.logger.Errorw("DeployBulk, error in tx commit", "err", err) + return nil, err + } + //nats event + impl.triggerDeploymentEvent(installAppVersions) + return &ChartGroupInstallAppRes{}, nil +} + +func (impl *ChartGroupServiceImpl) requestBuilderForBulkDeployment(installRequest *ChartGroupInstallChartRequest, projectId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { + valYaml := installRequest.ValuesOverrideYaml + if valYaml == "" { + valVersion, err := impl.appStoreValuesService.FindValuesByIdAndKind(installRequest.ReferenceValueId, installRequest.ReferenceValueKind) + if err != nil { + return nil, err + } + valYaml = valVersion.Values + } + req := &appStoreBean.InstallAppVersionDTO{ + AppName: installRequest.AppName, + TeamId: projectId, + EnvironmentId: installRequest.EnvironmentId, + AppStoreVersion: installRequest.AppStoreVersion, + ValuesOverrideYaml: valYaml, + UserId: userId, + ReferenceValueId: installRequest.ReferenceValueId, + ReferenceValueKind: installRequest.ReferenceValueKind, + ChartGroupEntryId: installRequest.ChartGroupEntryId, + DefaultClusterComponent: installRequest.DefaultClusterComponent, + } + return req, nil +} + +// generate unique installation ID using APPID +func getInstallationId(installAppVersions []*appStoreBean.InstallAppVersionDTO) (string, error) { + var buffer bytes.Buffer + for _, installAppVersionDTO := range installAppVersions { + if installAppVersionDTO.AppId == 0 { + return "", fmt.Errorf("app ID not present") + } + buffer.WriteString( + strconv.Itoa(installAppVersionDTO.AppId)) + } + /* #nosec */ + h := sha1.New() + _, err := h.Write([]byte(buffer.String())) + if err != nil { + return "", err + } + bs := h.Sum(nil) + return fmt.Sprintf("%x", bs), nil +} + +func createChartGroupEntryObject(installAppVersionDTO *appStoreBean.InstallAppVersionDTO, chartGroupId int, groupINstallationId string) *repository2.ChartGroupDeployment { + return &repository2.ChartGroupDeployment{ + ChartGroupId: chartGroupId, + ChartGroupEntryId: installAppVersionDTO.ChartGroupEntryId, + InstalledAppId: installAppVersionDTO.InstalledAppId, + Deleted: false, + GroupInstallationId: groupINstallationId, + AuditLog: sql.AuditLog{ + CreatedOn: time.Now(), + CreatedBy: installAppVersionDTO.UserId, + UpdatedOn: time.Now(), + UpdatedBy: installAppVersionDTO.UserId, + }, + } +} + +func (impl *ChartGroupServiceImpl) triggerDeploymentEvent(installAppVersions []*appStoreBean.InstallAppVersionDTO) { + for _, versions := range installAppVersions { + var installedAppDeploymentStatus appStoreBean.AppstoreDeploymentStatus + payload := &appStoreBean.DeployPayload{InstalledAppVersionId: versions.InstalledAppVersionId, InstalledAppVersionHistoryId: versions.InstalledAppVersionHistoryId} + data, err := json.Marshal(payload) + if err != nil { + installedAppDeploymentStatus = appStoreBean.QUE_ERROR + } else { + err = impl.pubSubClient.Publish(pubsub.BULK_APPSTORE_DEPLOY_TOPIC, string(data)) + if err != nil { + impl.logger.Errorw("err while publishing msg for app-store bulk deploy", "msg", data, "err", err) + installedAppDeploymentStatus = appStoreBean.QUE_ERROR + } else { + installedAppDeploymentStatus = appStoreBean.ENQUEUED + } + + } + if versions.Status == appStoreBean.DEPLOY_INIT || versions.Status == appStoreBean.QUE_ERROR || versions.Status == appStoreBean.ENQUEUED { + impl.logger.Debugw("status for bulk app-store deploy", "status", installedAppDeploymentStatus) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(payload.InstalledAppVersionId, installedAppDeploymentStatus) + if err != nil { + impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) + } + } + } +} + +func (impl *ChartGroupServiceImpl) DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) { + // STEP 1 - create environment with name "devton" + impl.logger.Infow("STEP 1", "create environment for cluster component", bean) + envName := fmt.Sprintf("%d-%s", bean.Id, appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) + env, err := impl.envService.FindOne(envName) + if err != nil && err != pg.ErrNoRows { + return false, err + } + if err == pg.ErrNoRows { + env = &cluster2.EnvironmentBean{ + Environment: envName, + ClusterId: bean.Id, + Namespace: envName, + Default: false, + Active: true, + } + _, err := impl.envService.Create(env, userId) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, error in creating environment", "data", env, "err", err) + return false, err + } + } + + // STEP 2 - create project with name "devtron" + impl.logger.Info("STEP 2", "create project for cluster components") + t, err := impl.teamRepository.FindByTeamName(appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) + if err != nil && err != pg.ErrNoRows { + return false, err + } + if err == pg.ErrNoRows { + t := &repository4.Team{ + Name: appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT, + Active: true, + AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, + } + err = impl.teamRepository.Save(t) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, error in creating team", "data", t, "err", err) + return false, err + } + } + + // STEP 3- read the input data from env variables + impl.logger.Info("STEP 3", "read the input data from env variables") + charts := &appStoreBean.ChartComponents{} + var chartComponents []*appStoreBean.ChartComponent + if _, err := os.Stat(appStoreBean.CLUSTER_COMPONENT_DIR_PATH); os.IsNotExist(err) { + impl.logger.Infow("default cluster component directory error", "cluster", bean.ClusterName, "err", err) + return false, nil + } else { + fileInfo, err := ioutil.ReadDir(appStoreBean.CLUSTER_COMPONENT_DIR_PATH) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, err while reading directory", "err", err) + return false, err + } + for _, file := range fileInfo { + impl.logger.Infow("file", "name", file.Name()) + if strings.Contains(file.Name(), ".yaml") { + content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", appStoreBean.CLUSTER_COMPONENT_DIR_PATH, file.Name())) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, error on reading file", "err", err) + return false, err + } + chartComponent := &appStoreBean.ChartComponent{ + Name: strings.ReplaceAll(file.Name(), ".yaml", ""), + Values: string(content), + } + chartComponents = append(chartComponents, chartComponent) + } + } + + if len(chartComponents) > 0 { + charts.ChartComponent = chartComponents + impl.logger.Info("STEP 4 - prepare a bulk request") + // STEP 4 - prepare a bulk request (unique names need to apply for deploying chart) + // STEP 4.1 - fetch chart for required name(actual chart name (app-store)) with default values + // STEP 4.2 - update all the required charts, override values.yaml with env variables. + chartGroupInstallRequest := &ChartGroupInstallRequest{} + chartGroupInstallRequest.ProjectId = t.Id + chartGroupInstallRequest.UserId = userId + var chartGroupInstallChartRequests []*ChartGroupInstallChartRequest + for _, item := range charts.ChartComponent { + appStore, err := impl.appStoreApplicationVersionRepository.FindByAppStoreName(item.Name) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, error in getting app store", "data", t, "err", err) + return false, err + } + chartGroupInstallChartRequest := &ChartGroupInstallChartRequest{ + AppName: fmt.Sprintf("%d-%d-%s", bean.Id, env.Id, item.Name), + EnvironmentId: env.Id, + ValuesOverrideYaml: item.Values, + AppStoreVersion: appStore.AppStoreApplicationVersionId, + ReferenceValueId: appStore.AppStoreApplicationVersionId, + ReferenceValueKind: appStoreBean.REFERENCE_TYPE_DEFAULT, + DefaultClusterComponent: true, + } + chartGroupInstallChartRequests = append(chartGroupInstallChartRequests, chartGroupInstallChartRequest) + } + chartGroupInstallRequest.ChartGroupInstallChartRequest = chartGroupInstallChartRequests + + impl.logger.Info("STEP 5 - deploy bulk initiated") + // STEP 5 - deploy + _, err = impl.deployDefaultComponent(chartGroupInstallRequest) + if err != nil { + impl.logger.Errorw("DeployDefaultChartOnCluster, error on bulk deploy", "err", err) + return false, err + } + } + } + return true, nil +} + +func (impl *ChartGroupServiceImpl) deployDefaultComponent(chartGroupInstallRequest *ChartGroupInstallRequest) (*ChartGroupInstallAppRes, error) { + impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) + //save in db + // raise nats event + + var installAppVersionDTOList []*appStoreBean.InstallAppVersionDTO + for _, installRequest := range chartGroupInstallRequest.ChartGroupInstallChartRequest { + installAppVersionDTO, err := impl.requestBuilderForBulkDeployment(installRequest, chartGroupInstallRequest.ProjectId, chartGroupInstallRequest.UserId) + if err != nil { + impl.logger.Errorw("DeployBulk, error in request builder", "err", err) + return nil, err + } + installAppVersionDTOList = append(installAppVersionDTOList, installAppVersionDTO) + } + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return nil, err + } + var installAppVersions []*appStoreBean.InstallAppVersionDTO + // Rollback tx on error. + defer tx.Rollback() + for _, installAppVersionDTO := range installAppVersionDTOList { + installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) + if err != nil { + impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) + return nil, err + } + installAppVersions = append(installAppVersions, installAppVersionDTO) + } + if chartGroupInstallRequest.ChartGroupId > 0 { + groupINstallationId, err := getInstallationId(installAppVersions) + if err != nil { + return nil, err + } + for _, installAppVersionDTO := range installAppVersions { + chartGroupEntry := createChartGroupEntryObject(installAppVersionDTO, chartGroupInstallRequest.ChartGroupId, groupINstallationId) + err := impl.chartGroupDeploymentRepository.Save(tx, chartGroupEntry) + if err != nil { + impl.logger.Errorw("DeployBulk, error in creating ChartGroupEntryObject", "err", err) + return nil, err + } + } + } + //commit transaction + err = tx.Commit() + if err != nil { + impl.logger.Errorw("DeployBulk, error in tx commit", "err", err) + return nil, err + } + //nats event + + for _, versions := range installAppVersions { + _, err := impl.performDeployStage(versions.InstalledAppVersionId, versions.InstalledAppVersionHistoryId, chartGroupInstallRequest.UserId) + if err != nil { + impl.logger.Errorw("error in performing deploy stage", "deployPayload", versions, "err", err) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(versions.InstalledAppVersionId, appStoreBean.QUE_ERROR) + if err != nil { + impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) + } + } + } + + return &ChartGroupInstallAppRes{}, nil +} + +func (impl *ChartGroupServiceImpl) subscribe() error { + callback := func(msg *model.PubSubMsg) { + deployPayload := &appStoreBean.DeployPayload{} + err := json.Unmarshal([]byte(string(msg.Data)), &deployPayload) + if err != nil { + impl.logger.Error("Error while unmarshalling deployPayload json object", "error", err) + return + } + impl.logger.Debugw("deployPayload:", "deployPayload", deployPayload) + //using userId 1 - for system user + _, err = impl.performDeployStage(deployPayload.InstalledAppVersionId, deployPayload.InstalledAppVersionHistoryId, 1) + if err != nil { + impl.logger.Errorw("error in performing deploy stage", "deployPayload", deployPayload, "err", err) + } + } + + // add required logging here + var loggerFunc pubsub.LoggerFunc = func(msg model.PubSubMsg) (string, []interface{}) { + deployPayload := &appStoreBean.DeployPayload{} + err := json.Unmarshal([]byte(string(msg.Data)), &deployPayload) + if err != nil { + return "error while unmarshalling deployPayload json object", []interface{}{"error", err} + } + return "got message for deploy app-store apps in bulk", []interface{}{"installedAppVersionId", deployPayload.InstalledAppVersionId, "installedAppVersionHistoryId", deployPayload.InstalledAppVersionHistoryId} + } + + err := impl.pubSubClient.Subscribe(pubsub.BULK_APPSTORE_DEPLOY_TOPIC, callback, loggerFunc) + if err != nil { + impl.logger.Error("err", err) + return err + } + return nil +} + +func (impl *ChartGroupServiceImpl) performDeployStage(installedAppVersionId int, installedAppVersionHistoryId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { + ctx := context.Background() + installedAppVersion, err := impl.appStoreDeploymentService.GetInstalledAppVersion(installedAppVersionId, userId) + if err != nil { + return nil, err + } + installedAppVersion.InstalledAppVersionHistoryId = installedAppVersionHistoryId + if util.IsAcdApp(installedAppVersion.DeploymentAppType) { + //this method should only call in case of argo-integration installed and git-ops has configured + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.logger.Errorw("error in getting acd token", "err", err) + return nil, err + } + ctx = context.WithValue(ctx, "token", acdToken) + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, + Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, + StatusDetail: "Deployment initiated successfully.", + StatusTime: time.Now(), + AuditLog: sql.AuditLog{ + CreatedBy: installedAppVersion.UserId, + CreatedOn: time.Now(), + UpdatedBy: installedAppVersion.UserId, + UpdatedOn: time.Now(), + }, + } + err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) + if err != nil { + impl.logger.Errorw("error in creating timeline status for deployment initiation for this app store application", "err", err, "timeline", timeline) + } + _, err = impl.performDeployStageOnAcd(installedAppVersion, ctx, userId) + if err != nil { + impl.logger.Errorw("error", "err", err) + return nil, err + } + } else if util.IsHelmApp(installedAppVersion.DeploymentAppType) { + + _, err = impl.appStoreDeploymentService.InstallAppByHelm(installedAppVersion, ctx) + if err != nil { + impl.logger.Errorw("error", "err", err) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.HELM_ERROR) + if err != nil { + impl.logger.Errorw("error", "err", err) + return nil, err + } + return nil, err + } + } + + //step 4 db operation status triggered + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) + if err != nil { + impl.logger.Errorw("error", "err", err) + return nil, err + } + + return installedAppVersion, nil +} + +func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion *appStoreBean.InstallAppVersionDTO, ctx context.Context, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { + installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Name) + chartGitAttr := &commonBean.ChartGitAttribute{} + if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || + installedAppVersion.Status == appStoreBean.ENQUEUED || + installedAppVersion.Status == appStoreBean.QUE_ERROR || + installedAppVersion.Status == appStoreBean.GIT_ERROR { + //step 2 git operation pull push + //TODO: save git Timeline here + appStoreGitOpsResponse, err := impl.fullModeDeploymentService.GenerateManifestAndPerformGitOperations(installedAppVersion) + if err != nil { + impl.logger.Errorw(" error", "err", err) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_ERROR) + if err != nil { + impl.logger.Errorw(" error", "err", err) + return nil, err + } + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, + Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, + StatusDetail: fmt.Sprintf("Git commit failed - %v", err), + StatusTime: time.Now(), + AuditLog: sql.AuditLog{ + CreatedBy: installedAppVersion.UserId, + CreatedOn: time.Now(), + UpdatedBy: installedAppVersion.UserId, + UpdatedOn: time.Now(), + }, + } + _ = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) + return nil, err + } + + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, + Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, + StatusDetail: "Git commit done successfully.", + StatusTime: time.Now(), + AuditLog: sql.AuditLog{ + CreatedBy: installedAppVersion.UserId, + CreatedOn: time.Now(), + UpdatedBy: installedAppVersion.UserId, + UpdatedOn: time.Now(), + }, + } + _ = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) + impl.logger.Infow("GIT SUCCESSFUL", "chartGitAttrDB", appStoreGitOpsResponse) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_SUCCESS) + if err != nil { + impl.logger.Errorw(" error", "err", err) + return nil, err + } + + GitCommitSuccessTimeline := impl.pipelineStatusTimelineService. + GetTimelineDbObjectByTimelineStatusAndTimelineDescription(0, installedAppVersion.InstalledAppVersionHistoryId, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", installedAppVersion.UserId, time.Now()) + + timelines := []*pipelineConfig.PipelineStatusTimeline{GitCommitSuccessTimeline} + if !impl.acdConfig.ArgoCDAutoSyncEnabled { + ArgocdSyncInitiatedTimeline := impl.pipelineStatusTimelineService. + GetTimelineDbObjectByTimelineStatusAndTimelineDescription(0, installedAppVersion.InstalledAppVersionHistoryId, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "ArgoCD sync initiated.", installedAppVersion.UserId, time.Now()) + + timelines = append(timelines, ArgocdSyncInitiatedTimeline) + } + + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + impl.logger.Errorw("error in getting db connection for saving timelines", "err", err) + return nil, err + } + err = impl.pipelineStatusTimelineService.SaveTimelines(timelines, tx) + if err != nil { + impl.logger.Errorw("error in creating timeline status for deployment initiation for update of installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installedAppVersion.InstalledAppVersionHistoryId) + } + tx.Commit() + // update build history for chart for argo_cd apps + err = impl.appStoreDeploymentService.UpdateInstalledAppVersionHistoryWithGitHash(installedAppVersion, nil) + if err != nil { + impl.logger.Errorw("error on updating history for chart deployment", "error", err, "installedAppVersion", installedAppVersion) + return nil, err + } + installedAppVersion.GitHash = appStoreGitOpsResponse.GitHash + chartGitAttr.RepoUrl = appStoreGitOpsResponse.ChartGitAttribute.RepoUrl + chartGitAttr.ChartLocation = appStoreGitOpsResponse.ChartGitAttribute.ChartLocation + } else { + impl.logger.Infow("DB and GIT operation already done for this app and env, proceed for further step", "installedAppId", installedAppVersion.InstalledAppId, "existing status", installedAppVersion.Status) + environment, err := impl.environmentRepository.FindById(installedAppVersion.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching error", "err", err) + return nil, err + } + + repoUrl, err := impl.gitOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) + if err != nil { + //will allow to continue to persist status on next operation + impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) + } + + chartGitAttr.RepoUrl = repoUrl + chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) + installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) + installedAppVersion.Environment = environment + } + + if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || + installedAppVersion.Status == appStoreBean.ENQUEUED || + installedAppVersion.Status == appStoreBean.QUE_ERROR || + installedAppVersion.Status == appStoreBean.GIT_ERROR || + installedAppVersion.Status == appStoreBean.GIT_SUCCESS || + installedAppVersion.Status == appStoreBean.ACD_ERROR { + //step 3 acd operation register, sync + _, err := impl.fullModeDeploymentService.InstallApp(installedAppVersion, chartGitAttr, ctx, nil) + if err != nil { + impl.logger.Errorw("error", "chartGitAttr", chartGitAttr, "err", err) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_ERROR) + if err != nil { + impl.logger.Errorw("error", "err", err) + return nil, err + } + return nil, err + } + impl.logger.Infow("ACD SUCCESSFUL", "chartGitAttr", chartGitAttr) + _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_SUCCESS) + if err != nil { + impl.logger.Errorw("error", "err", err) + return nil, err + } + } else { + impl.logger.Infow("DB and GIT and ACD operation already done for this app and env. process has been completed", "installedAppId", installedAppVersion.InstalledAppId, "existing status", installedAppVersion.Status) + } + return installedAppVersion, nil +} diff --git a/pkg/appStore/deployment/service/InstalledAppService.go b/pkg/appStore/deployment/service/InstalledAppService.go deleted file mode 100644 index 3627794d9a..0000000000 --- a/pkg/appStore/deployment/service/InstalledAppService.go +++ /dev/null @@ -1,1106 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package service - -import ( - "bytes" - "context" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" - client "github.com/devtron-labs/devtron/api/helm-app/service" - appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" - commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" - util2 "github.com/devtron-labs/devtron/pkg/util" - - /* #nosec */ - "crypto/sha1" - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "os" - "strconv" - "strings" - "time" - - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - "github.com/devtron-labs/common-lib/pubsub-lib/model" - util4 "github.com/devtron-labs/common-lib/utils/k8s" - openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" - "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/pkg/app/status" - "github.com/devtron-labs/devtron/pkg/appStatus" - appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" - repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - "github.com/devtron-labs/devtron/pkg/appStore/values/service" - "github.com/devtron-labs/devtron/pkg/auth/user" - repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" - "github.com/devtron-labs/devtron/pkg/k8s" - application3 "github.com/devtron-labs/devtron/pkg/k8s/application" - "github.com/devtron-labs/devtron/pkg/sql" - repository4 "github.com/devtron-labs/devtron/pkg/team" - util3 "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/util/argo" - - "github.com/Pallinder/go-randomdata" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - bean2 "github.com/devtron-labs/devtron/api/bean" - application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/bean" - cluster2 "github.com/devtron-labs/devtron/pkg/cluster" - "github.com/go-pg/pg" - "go.uber.org/zap" -) - -// DB operation + chart group + nats msg consume(to be removed) -type InstalledAppService interface { - GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) - DeployBulk(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) - CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) - DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) - FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) - UpdateInstalledAppVersionStatus(application *v1alpha1.Application) (bool, error) - MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId int, envId int) error - CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) - - FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean2.AppDetailContainer) bean2.AppDetailContainer - FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean2.AppDetailsContainer, installedApp repository2.InstalledApps, helmReleaseInstallStatus string, status string) error - - //move to notes service - FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) -} - -type InstalledAppServiceImpl struct { - logger *zap.SugaredLogger - installedAppRepository repository2.InstalledAppRepository - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository5.EnvironmentRepository - teamRepository repository4.TeamRepository - appRepository app.AppRepository - acdClient application2.ServiceClient - appStoreValuesService service.AppStoreValuesService - pubSubClient *pubsub.PubSubClientServiceImpl - chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository - envService cluster2.EnvironmentService - aCDAuthConfig *util2.ACDAuthConfig - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService - installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository - argoUserService argo.ArgoUserService - helmAppClient gRPC.HelmAppClient - helmAppService client.HelmAppService - appStatusService appStatus.AppStatusService - K8sUtil *util4.K8sServiceImpl - pipelineStatusTimelineService status.PipelineStatusTimelineService - k8sCommonService k8s.K8sCommonService - k8sApplicationService application3.K8sApplicationService - acdConfig *argocdServer.ACDConfig - appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService - gitOperationService git.GitOperationService -} - -func NewInstalledAppServiceImpl(logger *zap.SugaredLogger, - installedAppRepository repository2.InstalledAppRepository, - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, - appRepository app.AppRepository, acdClient application2.ServiceClient, - appStoreValuesService service.AppStoreValuesService, pubsubClient *pubsub.PubSubClientServiceImpl, - chartGroupDeploymentRepository repository6.ChartGroupDeploymentRepository, - envService cluster2.EnvironmentService, - userService user.UserService, aCDAuthConfig *util2.ACDAuthConfig, - appStoreDeploymentService AppStoreDeploymentService, - installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, - argoUserService argo.ArgoUserService, helmAppClient gRPC.HelmAppClient, helmAppService client.HelmAppService, - appStatusService appStatus.AppStatusService, K8sUtil *util4.K8sServiceImpl, - pipelineStatusTimelineService status.PipelineStatusTimelineService, - k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, - acdConfig *argocdServer.ACDConfig, gitOperationService git.GitOperationService, - appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService) (*InstalledAppServiceImpl, error) { - impl := &InstalledAppServiceImpl{ - logger: logger, - installedAppRepository: installedAppRepository, - appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, - teamRepository: teamRepository, - appRepository: appRepository, - acdClient: acdClient, - appStoreValuesService: appStoreValuesService, - pubSubClient: pubsubClient, - chartGroupDeploymentRepository: chartGroupDeploymentRepository, - envService: envService, - aCDAuthConfig: aCDAuthConfig, - userService: userService, - appStoreDeploymentService: appStoreDeploymentService, - installedAppRepositoryHistory: installedAppRepositoryHistory, - argoUserService: argoUserService, - helmAppClient: helmAppClient, - helmAppService: helmAppService, - appStatusService: appStatusService, - K8sUtil: K8sUtil, - pipelineStatusTimelineService: pipelineStatusTimelineService, - k8sCommonService: k8sCommonService, - k8sApplicationService: k8sApplicationService, - acdConfig: acdConfig, - gitOperationService: gitOperationService, - appStoreDeploymentArgoCdService: appStoreDeploymentArgoCdService, - } - err := impl.subscribe() - if err != nil { - return nil, err - } - err = impl.subscribeHelmInstallStatus() - if err != nil { - return nil, err - } - return impl, nil -} -func (impl InstalledAppServiceImpl) subscribeHelmInstallStatus() error { - - callback := func(msg *model.PubSubMsg) { - - helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} - err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) - if err != nil { - impl.logger.Errorw("error in unmarshalling helm install status nats message", "err", err) - return - } - - installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(helmInstallNatsMessage.InstallAppVersionHistoryId) - if err != nil { - impl.logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) - return - } - if helmInstallNatsMessage.ErrorInInstallation { - installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed - } else { - installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - } - installedAppVersionHistory.HelmReleaseStatusConfig = msg.Data - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) - if err != nil { - impl.logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) - return - } - } - // add required logging here - var loggerFunc pubsub.LoggerFunc = func(msg model.PubSubMsg) (string, []interface{}) { - helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} - err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) - if err != nil { - return "error in unmarshalling helm install status nats message", []interface{}{"err", err} - } - return "got nats msg for helm chart install status", []interface{}{"InstallAppVersionHistoryId", helmInstallNatsMessage.InstallAppVersionHistoryId, "ErrorInInstallation", helmInstallNatsMessage.ErrorInInstallation, "IsReleaseInstalled", helmInstallNatsMessage.IsReleaseInstalled} - } - - err := impl.pubSubClient.Subscribe(pubsub.HELM_CHART_INSTALL_STATUS_TOPIC, callback, loggerFunc) - if err != nil { - impl.logger.Error(err) - return err - } - return nil -} - -func (impl InstalledAppServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) { - applicationType := "DEVTRON-CHART-STORE" - var clusterIdsConverted []int32 - for _, clusterId := range filter.ClusterIds { - clusterIdsConverted = append(clusterIdsConverted, int32(clusterId)) - } - installedAppsResponse := openapi.AppList{ - ApplicationType: &applicationType, - ClusterIds: &clusterIdsConverted, - } - start := time.Now() - installedApps, err := impl.installedAppRepository.GetAllInstalledApps(filter) - middleware.AppListingDuration.WithLabelValues("getAllInstalledApps", "helm").Observe(time.Since(start).Seconds()) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Error(err) - return installedAppsResponse, err - } - var helmAppsResponse []openapi.HelmApp - for _, a := range installedApps { - appLocal := a // copied data from here because value is passed as reference - if appLocal.TeamId == 0 && appLocal.AppOfferingMode != util3.SERVER_MODE_HYPERION { - //skipping entries for empty projectId for non hyperion app (as app list should return the helm apps from installedApps) - continue - } - appId := strconv.Itoa(appLocal.Id) - projectId := int32(appLocal.TeamId) - envId := int32(appLocal.EnvironmentId) - clusterId := int32(appLocal.ClusterId) - environmentDetails := openapi.AppEnvironmentDetail{ - EnvironmentName: &appLocal.EnvironmentName, - EnvironmentId: &envId, - Namespace: &appLocal.Namespace, - ClusterName: &appLocal.ClusterName, - ClusterId: &clusterId, - } - helmAppResp := openapi.HelmApp{ - AppName: &appLocal.AppName, - ChartName: &appLocal.AppStoreApplicationName, - AppId: &appId, - ProjectId: &projectId, - EnvironmentDetail: &environmentDetails, - ChartAvatar: &appLocal.Icon, - LastDeployedAt: &appLocal.UpdatedOn, - AppStatus: &appLocal.AppStatus, - } - helmAppsResponse = append(helmAppsResponse, helmAppResp) - } - installedAppsResponse.HelmApps = &helmAppsResponse - return installedAppsResponse, nil -} - -func (impl InstalledAppServiceImpl) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) { - if len(appNames) == 0 { - return nil, nil - } - var names []string - for _, appName := range appNames { - names = append(names, appName.Name) - } - - apps, err := impl.appRepository.CheckAppExists(names) - if err != nil { - return nil, err - } - existingApps := make(map[string]bool) - for _, app := range apps { - existingApps[app.AppName] = true - } - for _, appName := range appNames { - if _, ok := existingApps[appName.Name]; ok { - appName.Exists = true - appName.SuggestedName = strings.ToLower(randomdata.SillyName()) - } - } - return appNames, nil -} - -func (impl InstalledAppServiceImpl) DeployBulk(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) { - impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) - //save in db - // raise nats event - - var installAppVersionDTOList []*appStoreBean.InstallAppVersionDTO - for _, chartGroupInstall := range chartGroupInstallRequest.ChartGroupInstallChartRequest { - installAppVersionDTO, err := impl.requestBuilderForBulkDeployment(chartGroupInstall, chartGroupInstallRequest.ProjectId, chartGroupInstallRequest.UserId) - if err != nil { - impl.logger.Errorw("DeployBulk, error in request builder", "err", err) - return nil, err - } - installAppVersionDTOList = append(installAppVersionDTOList, installAppVersionDTO) - } - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return nil, err - } - var installAppVersions []*appStoreBean.InstallAppVersionDTO - // Rollback tx on error. - defer tx.Rollback() - for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) - if err != nil { - impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) - return nil, err - } - installAppVersions = append(installAppVersions, installAppVersionDTO) - } - if chartGroupInstallRequest.ChartGroupId > 0 { - groupINstallationId, err := impl.getInstallationId(installAppVersions) - if err != nil { - return nil, err - } - for _, installAppVersionDTO := range installAppVersions { - chartGroupEntry := impl.createChartGroupEntryObject(installAppVersionDTO, chartGroupInstallRequest.ChartGroupId, groupINstallationId) - err := impl.chartGroupDeploymentRepository.Save(tx, chartGroupEntry) - if err != nil { - impl.logger.Errorw("DeployBulk, error in creating ChartGroupEntryObject", "err", err) - return nil, err - } - } - } - //commit transaction - err = tx.Commit() - if err != nil { - impl.logger.Errorw("DeployBulk, error in tx commit", "err", err) - return nil, err - } - //nats event - impl.triggerDeploymentEvent(installAppVersions) - return &chartGroup.ChartGroupInstallAppRes{}, nil -} - -// generate unique installation ID using APPID -func (impl InstalledAppServiceImpl) getInstallationId(installAppVersions []*appStoreBean.InstallAppVersionDTO) (string, error) { - var buffer bytes.Buffer - for _, installAppVersionDTO := range installAppVersions { - if installAppVersionDTO.AppId == 0 { - return "", fmt.Errorf("app ID not present") - } - buffer.WriteString( - strconv.Itoa(installAppVersionDTO.AppId)) - } - /* #nosec */ - h := sha1.New() - _, err := h.Write([]byte(buffer.String())) - if err != nil { - return "", err - } - bs := h.Sum(nil) - return fmt.Sprintf("%x", bs), nil -} - -func (impl InstalledAppServiceImpl) createChartGroupEntryObject(installAppVersionDTO *appStoreBean.InstallAppVersionDTO, chartGroupId int, groupINstallationId string) *repository6.ChartGroupDeployment { - return &repository6.ChartGroupDeployment{ - ChartGroupId: chartGroupId, - ChartGroupEntryId: installAppVersionDTO.ChartGroupEntryId, - InstalledAppId: installAppVersionDTO.InstalledAppId, - Deleted: false, - GroupInstallationId: groupINstallationId, - AuditLog: sql.AuditLog{ - CreatedOn: time.Now(), - CreatedBy: installAppVersionDTO.UserId, - UpdatedOn: time.Now(), - UpdatedBy: installAppVersionDTO.UserId, - }, - } -} - -func (impl InstalledAppServiceImpl) performDeployStageOnAcd(installedAppVersion *appStoreBean.InstallAppVersionDTO, ctx context.Context, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { - installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Name) - chartGitAttr := &commonBean.ChartGitAttribute{} - if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || - installedAppVersion.Status == appStoreBean.ENQUEUED || - installedAppVersion.Status == appStoreBean.QUE_ERROR || - installedAppVersion.Status == appStoreBean.GIT_ERROR { - //step 2 git operation pull push - //TODO: save git Timeline here - appStoreGitOpsResponse, err := impl.appStoreDeploymentArgoCdService.GenerateManifestAndPerformGitOperations(installedAppVersion) - if err != nil { - impl.logger.Errorw(" error", "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_ERROR) - if err != nil { - impl.logger.Errorw(" error", "err", err) - return nil, err - } - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, - StatusDetail: fmt.Sprintf("Git commit failed - %v", err), - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installedAppVersion.UserId, - CreatedOn: time.Now(), - UpdatedBy: installedAppVersion.UserId, - UpdatedOn: time.Now(), - }, - } - _ = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) - return nil, err - } - - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, - StatusDetail: "Git commit done successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installedAppVersion.UserId, - CreatedOn: time.Now(), - UpdatedBy: installedAppVersion.UserId, - UpdatedOn: time.Now(), - }, - } - _ = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) - impl.logger.Infow("GIT SUCCESSFUL", "chartGitAttrDB", appStoreGitOpsResponse) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_SUCCESS) - if err != nil { - impl.logger.Errorw(" error", "err", err) - return nil, err - } - - GitCommitSuccessTimeline := impl.pipelineStatusTimelineService. - GetTimelineDbObjectByTimelineStatusAndTimelineDescription(0, installedAppVersion.InstalledAppVersionHistoryId, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", installedAppVersion.UserId, time.Now()) - - timelines := []*pipelineConfig.PipelineStatusTimeline{GitCommitSuccessTimeline} - if !impl.acdConfig.ArgoCDAutoSyncEnabled { - ArgocdSyncInitiatedTimeline := impl.pipelineStatusTimelineService. - GetTimelineDbObjectByTimelineStatusAndTimelineDescription(0, installedAppVersion.InstalledAppVersionHistoryId, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "ArgoCD sync initiated.", installedAppVersion.UserId, time.Now()) - - timelines = append(timelines, ArgocdSyncInitiatedTimeline) - } - - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - impl.logger.Errorw("error in getting db connection for saving timelines", "err", err) - return nil, err - } - err = impl.pipelineStatusTimelineService.SaveTimelines(timelines, tx) - if err != nil { - impl.logger.Errorw("error in creating timeline status for deployment initiation for update of installedAppVersionHistoryId", "err", err, "installedAppVersionHistoryId", installedAppVersion.InstalledAppVersionHistoryId) - } - tx.Commit() - // update build history for chart for argo_cd apps - err = impl.appStoreDeploymentService.UpdateInstalledAppVersionHistoryWithGitHash(installedAppVersion, nil) - if err != nil { - impl.logger.Errorw("error on updating history for chart deployment", "error", err, "installedAppVersion", installedAppVersion) - return nil, err - } - installedAppVersion.GitHash = appStoreGitOpsResponse.GitHash - chartGitAttr.RepoUrl = appStoreGitOpsResponse.ChartGitAttribute.RepoUrl - chartGitAttr.ChartLocation = appStoreGitOpsResponse.ChartGitAttribute.ChartLocation - } else { - impl.logger.Infow("DB and GIT operation already done for this app and env, proceed for further step", "installedAppId", installedAppVersion.InstalledAppId, "existing status", installedAppVersion.Status) - environment, err := impl.environmentRepository.FindById(installedAppVersion.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - - repoUrl, err := impl.gitOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) - if err != nil { - //will allow to continue to persist status on next operation - impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) - } - - chartGitAttr.RepoUrl = repoUrl - chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) - installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) - installedAppVersion.Environment = environment - } - - if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || - installedAppVersion.Status == appStoreBean.ENQUEUED || - installedAppVersion.Status == appStoreBean.QUE_ERROR || - installedAppVersion.Status == appStoreBean.GIT_ERROR || - installedAppVersion.Status == appStoreBean.GIT_SUCCESS || - installedAppVersion.Status == appStoreBean.ACD_ERROR { - //step 3 acd operation register, sync - _, err := impl.appStoreDeploymentArgoCdService.InstallApp(installedAppVersion, chartGitAttr, ctx, nil) - if err != nil { - impl.logger.Errorw("error", "chartGitAttr", chartGitAttr, "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_ERROR) - if err != nil { - impl.logger.Errorw("error", "err", err) - return nil, err - } - return nil, err - } - impl.logger.Infow("ACD SUCCESSFUL", "chartGitAttr", chartGitAttr) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_SUCCESS) - if err != nil { - impl.logger.Errorw("error", "err", err) - return nil, err - } - } else { - impl.logger.Infow("DB and GIT and ACD operation already done for this app and env. process has been completed", "installedAppId", installedAppVersion.InstalledAppId, "existing status", installedAppVersion.Status) - } - return installedAppVersion, nil -} - -func (impl InstalledAppServiceImpl) performDeployStage(installedAppVersionId int, installedAppVersionHistoryId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { - ctx := context.Background() - installedAppVersion, err := impl.appStoreDeploymentService.GetInstalledAppVersion(installedAppVersionId, userId) - if err != nil { - return nil, err - } - installedAppVersion.InstalledAppVersionHistoryId = installedAppVersionHistoryId - if util.IsAcdApp(installedAppVersion.DeploymentAppType) { - //this method should only call in case of argo-integration installed and git-ops has configured - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - return nil, err - } - ctx = context.WithValue(ctx, "token", acdToken) - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installedAppVersion.InstalledAppVersionHistoryId, - Status: pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, - StatusDetail: "Deployment initiated successfully.", - StatusTime: time.Now(), - AuditLog: sql.AuditLog{ - CreatedBy: installedAppVersion.UserId, - CreatedOn: time.Now(), - UpdatedBy: installedAppVersion.UserId, - UpdatedOn: time.Now(), - }, - } - err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) - if err != nil { - impl.logger.Errorw("error in creating timeline status for deployment initiation for this app store application", "err", err, "timeline", timeline) - } - _, err = impl.performDeployStageOnAcd(installedAppVersion, ctx, userId) - if err != nil { - impl.logger.Errorw("error", "err", err) - return nil, err - } - } else if util.IsHelmApp(installedAppVersion.DeploymentAppType) { - - _, err = impl.appStoreDeploymentService.InstallAppByHelm(installedAppVersion, ctx) - if err != nil { - impl.logger.Errorw("error", "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.HELM_ERROR) - if err != nil { - impl.logger.Errorw("error", "err", err) - return nil, err - } - return nil, err - } - } - - //step 4 db operation status triggered - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) - if err != nil { - impl.logger.Errorw("error", "err", err) - return nil, err - } - - return installedAppVersion, nil -} - -func (impl InstalledAppServiceImpl) requestBuilderForBulkDeployment(installRequest *chartGroup.ChartGroupInstallChartRequest, projectId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { - valYaml := installRequest.ValuesOverrideYaml - if valYaml == "" { - valVersion, err := impl.appStoreValuesService.FindValuesByIdAndKind(installRequest.ReferenceValueId, installRequest.ReferenceValueKind) - if err != nil { - return nil, err - } - valYaml = valVersion.Values - } - req := &appStoreBean.InstallAppVersionDTO{ - AppName: installRequest.AppName, - TeamId: projectId, - EnvironmentId: installRequest.EnvironmentId, - AppStoreVersion: installRequest.AppStoreVersion, - ValuesOverrideYaml: valYaml, - UserId: userId, - ReferenceValueId: installRequest.ReferenceValueId, - ReferenceValueKind: installRequest.ReferenceValueKind, - ChartGroupEntryId: installRequest.ChartGroupEntryId, - DefaultClusterComponent: installRequest.DefaultClusterComponent, - } - return req, nil -} - -//------------ nats config - -func (impl *InstalledAppServiceImpl) triggerDeploymentEvent(installAppVersions []*appStoreBean.InstallAppVersionDTO) { - - for _, versions := range installAppVersions { - var status appStoreBean.AppstoreDeploymentStatus - payload := &appStoreBean.DeployPayload{InstalledAppVersionId: versions.InstalledAppVersionId, InstalledAppVersionHistoryId: versions.InstalledAppVersionHistoryId} - data, err := json.Marshal(payload) - if err != nil { - status = appStoreBean.QUE_ERROR - } else { - err = impl.pubSubClient.Publish(pubsub.BULK_APPSTORE_DEPLOY_TOPIC, string(data)) - if err != nil { - impl.logger.Errorw("err while publishing msg for app-store bulk deploy", "msg", data, "err", err) - status = appStoreBean.QUE_ERROR - } else { - status = appStoreBean.ENQUEUED - } - - } - if versions.Status == appStoreBean.DEPLOY_INIT || versions.Status == appStoreBean.QUE_ERROR || versions.Status == appStoreBean.ENQUEUED { - impl.logger.Debugw("status for bulk app-store deploy", "status", status) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(payload.InstalledAppVersionId, status) - if err != nil { - impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) - } - } - } -} - -func (impl *InstalledAppServiceImpl) subscribe() error { - callback := func(msg *model.PubSubMsg) { - deployPayload := &appStoreBean.DeployPayload{} - err := json.Unmarshal([]byte(string(msg.Data)), &deployPayload) - if err != nil { - impl.logger.Error("Error while unmarshalling deployPayload json object", "error", err) - return - } - impl.logger.Debugw("deployPayload:", "deployPayload", deployPayload) - //using userId 1 - for system user - _, err = impl.performDeployStage(deployPayload.InstalledAppVersionId, deployPayload.InstalledAppVersionHistoryId, 1) - if err != nil { - impl.logger.Errorw("error in performing deploy stage", "deployPayload", deployPayload, "err", err) - } - } - - // add required logging here - var loggerFunc pubsub.LoggerFunc = func(msg model.PubSubMsg) (string, []interface{}) { - deployPayload := &appStoreBean.DeployPayload{} - err := json.Unmarshal([]byte(string(msg.Data)), &deployPayload) - if err != nil { - return "error while unmarshalling deployPayload json object", []interface{}{"error", err} - } - return "got message for deploy app-store apps in bulk", []interface{}{"installedAppVersionId", deployPayload.InstalledAppVersionId, "installedAppVersionHistoryId", deployPayload.InstalledAppVersionHistoryId} - } - - err := impl.pubSubClient.Subscribe(pubsub.BULK_APPSTORE_DEPLOY_TOPIC, callback, loggerFunc) - if err != nil { - impl.logger.Error("err", err) - return err - } - return nil -} - -func (impl *InstalledAppServiceImpl) DeployDefaultChartOnCluster(bean *cluster2.ClusterBean, userId int32) (bool, error) { - // STEP 1 - create environment with name "devton" - impl.logger.Infow("STEP 1", "create environment for cluster component", bean) - envName := fmt.Sprintf("%d-%s", bean.Id, appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) - env, err := impl.envService.FindOne(envName) - if err != nil && err != pg.ErrNoRows { - return false, err - } - if err == pg.ErrNoRows { - env = &cluster2.EnvironmentBean{ - Environment: envName, - ClusterId: bean.Id, - Namespace: envName, - Default: false, - Active: true, - } - _, err := impl.envService.Create(env, userId) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, error in creating environment", "data", env, "err", err) - return false, err - } - } - - // STEP 2 - create project with name "devtron" - impl.logger.Info("STEP 2", "create project for cluster components") - t, err := impl.teamRepository.FindByTeamName(appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) - if err != nil && err != pg.ErrNoRows { - return false, err - } - if err == pg.ErrNoRows { - t := &repository4.Team{ - Name: appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT, - Active: true, - AuditLog: sql.AuditLog{CreatedBy: userId, CreatedOn: time.Now(), UpdatedOn: time.Now(), UpdatedBy: userId}, - } - err = impl.teamRepository.Save(t) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, error in creating team", "data", t, "err", err) - return false, err - } - } - - // STEP 3- read the input data from env variables - impl.logger.Info("STEP 3", "read the input data from env variables") - charts := &appStoreBean.ChartComponents{} - var chartComponents []*appStoreBean.ChartComponent - if _, err := os.Stat(appStoreBean.CLUSTER_COMPONENT_DIR_PATH); os.IsNotExist(err) { - impl.logger.Infow("default cluster component directory error", "cluster", bean.ClusterName, "err", err) - return false, nil - } else { - fileInfo, err := ioutil.ReadDir(appStoreBean.CLUSTER_COMPONENT_DIR_PATH) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, err while reading directory", "err", err) - return false, err - } - for _, file := range fileInfo { - impl.logger.Infow("file", "name", file.Name()) - if strings.Contains(file.Name(), ".yaml") { - content, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", appStoreBean.CLUSTER_COMPONENT_DIR_PATH, file.Name())) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, error on reading file", "err", err) - return false, err - } - chartComponent := &appStoreBean.ChartComponent{ - Name: strings.ReplaceAll(file.Name(), ".yaml", ""), - Values: string(content), - } - chartComponents = append(chartComponents, chartComponent) - } - } - - if len(chartComponents) > 0 { - charts.ChartComponent = chartComponents - impl.logger.Info("STEP 4 - prepare a bulk request") - // STEP 4 - prepare a bulk request (unique names need to apply for deploying chart) - // STEP 4.1 - fetch chart for required name(actual chart name (app-store)) with default values - // STEP 4.2 - update all the required charts, override values.yaml with env variables. - chartGroupInstallRequest := &chartGroup.ChartGroupInstallRequest{} - chartGroupInstallRequest.ProjectId = t.Id - chartGroupInstallRequest.UserId = userId - var chartGroupInstallChartRequests []*chartGroup.ChartGroupInstallChartRequest - for _, item := range charts.ChartComponent { - appStore, err := impl.appStoreApplicationVersionRepository.FindByAppStoreName(item.Name) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, error in getting app store", "data", t, "err", err) - return false, err - } - chartGroupInstallChartRequest := &chartGroup.ChartGroupInstallChartRequest{ - AppName: fmt.Sprintf("%d-%d-%s", bean.Id, env.Id, item.Name), - EnvironmentId: env.Id, - ValuesOverrideYaml: item.Values, - AppStoreVersion: appStore.AppStoreApplicationVersionId, - ReferenceValueId: appStore.AppStoreApplicationVersionId, - ReferenceValueKind: appStoreBean.REFERENCE_TYPE_DEFAULT, - DefaultClusterComponent: true, - } - chartGroupInstallChartRequests = append(chartGroupInstallChartRequests, chartGroupInstallChartRequest) - } - chartGroupInstallRequest.ChartGroupInstallChartRequest = chartGroupInstallChartRequests - - impl.logger.Info("STEP 5 - deploy bulk initiated") - // STEP 5 - deploy - _, err = impl.DeployDefaultComponent(chartGroupInstallRequest) - if err != nil { - impl.logger.Errorw("DeployDefaultChartOnCluster, error on bulk deploy", "err", err) - return false, err - } - } - } - return true, nil -} - -func (impl InstalledAppServiceImpl) DeployDefaultComponent(chartGroupInstallRequest *chartGroup.ChartGroupInstallRequest) (*chartGroup.ChartGroupInstallAppRes, error) { - impl.logger.Debugw("bulk app install request", "req", chartGroupInstallRequest) - //save in db - // raise nats event - - var installAppVersionDTOList []*appStoreBean.InstallAppVersionDTO - for _, installRequest := range chartGroupInstallRequest.ChartGroupInstallChartRequest { - installAppVersionDTO, err := impl.requestBuilderForBulkDeployment(installRequest, chartGroupInstallRequest.ProjectId, chartGroupInstallRequest.UserId) - if err != nil { - impl.logger.Errorw("DeployBulk, error in request builder", "err", err) - return nil, err - } - installAppVersionDTOList = append(installAppVersionDTOList, installAppVersionDTO) - } - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return nil, err - } - var installAppVersions []*appStoreBean.InstallAppVersionDTO - // Rollback tx on error. - defer tx.Rollback() - for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) - if err != nil { - impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) - return nil, err - } - installAppVersions = append(installAppVersions, installAppVersionDTO) - } - if chartGroupInstallRequest.ChartGroupId > 0 { - groupINstallationId, err := impl.getInstallationId(installAppVersions) - if err != nil { - return nil, err - } - for _, installAppVersionDTO := range installAppVersions { - chartGroupEntry := impl.createChartGroupEntryObject(installAppVersionDTO, chartGroupInstallRequest.ChartGroupId, groupINstallationId) - err := impl.chartGroupDeploymentRepository.Save(tx, chartGroupEntry) - if err != nil { - impl.logger.Errorw("DeployBulk, error in creating ChartGroupEntryObject", "err", err) - return nil, err - } - } - } - //commit transaction - err = tx.Commit() - if err != nil { - impl.logger.Errorw("DeployBulk, error in tx commit", "err", err) - return nil, err - } - //nats event - - for _, versions := range installAppVersions { - _, err := impl.performDeployStage(versions.InstalledAppVersionId, versions.InstalledAppVersionHistoryId, chartGroupInstallRequest.UserId) - if err != nil { - impl.logger.Errorw("error in performing deploy stage", "deployPayload", versions, "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(versions.InstalledAppVersionId, appStoreBean.QUE_ERROR) - if err != nil { - impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) - } - } - } - - return &chartGroup.ChartGroupInstallAppRes{}, nil -} - -func (impl *InstalledAppServiceImpl) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) { - installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) - if err != nil { - impl.logger.Error(err) - return bean2.AppDetailContainer{}, err - } - helmReleaseInstallStatus, status, err := impl.installedAppRepository.GetHelmReleaseStatusConfigByInstalledAppId(installedAppVerison.InstalledAppId) - if err != nil { - impl.logger.Errorw("error in getting helm release status from db", "err", err) - return bean2.AppDetailContainer{}, err - } - var chartName string - if installedAppVerison.AppStoreApplicationVersion.AppStore.ChartRepoId != 0 { - chartName = installedAppVerison.AppStoreApplicationVersion.AppStore.ChartRepo.Name - } else { - chartName = installedAppVerison.AppStoreApplicationVersion.AppStore.DockerArtifactStore.Id - } - deploymentContainer := bean2.DeploymentDetailContainer{ - InstalledAppId: installedAppVerison.InstalledApp.Id, - AppId: installedAppVerison.InstalledApp.App.Id, - AppStoreInstalledAppVersionId: installedAppVerison.Id, - EnvironmentId: installedAppVerison.InstalledApp.EnvironmentId, - AppName: installedAppVerison.InstalledApp.App.AppName, - AppStoreChartName: chartName, - AppStoreChartId: installedAppVerison.AppStoreApplicationVersion.AppStore.Id, - AppStoreAppName: installedAppVerison.AppStoreApplicationVersion.Name, - AppStoreAppVersion: installedAppVerison.AppStoreApplicationVersion.Version, - EnvironmentName: installedAppVerison.InstalledApp.Environment.Name, - LastDeployedTime: installedAppVerison.UpdatedOn.Format(bean.LayoutRFC3339), - Namespace: installedAppVerison.InstalledApp.Environment.Namespace, - Deprecated: installedAppVerison.AppStoreApplicationVersion.Deprecated, - ClusterId: installedAppVerison.InstalledApp.Environment.ClusterId, - DeploymentAppType: installedAppVerison.InstalledApp.DeploymentAppType, - DeploymentAppDeleteRequest: installedAppVerison.InstalledApp.DeploymentAppDeleteRequest, - IsVirtualEnvironment: installedAppVerison.InstalledApp.Environment.IsVirtualEnvironment, - HelmReleaseInstallStatus: helmReleaseInstallStatus, - Status: status, - } - userInfo, err := impl.userService.GetByIdIncludeDeleted(installedAppVerison.AuditLog.UpdatedBy) - if err != nil { - impl.logger.Errorw("error fetching user info", "err", err) - return bean2.AppDetailContainer{}, err - } - deploymentContainer.LastDeployedBy = userInfo.EmailId - appDetail := bean2.AppDetailContainer{ - DeploymentDetailContainer: deploymentContainer, - } - return appDetail, nil -} - -func (impl InstalledAppServiceImpl) GetInstalledAppVersionHistory(installedAppId int) (*appStoreBean.InstallAppVersionHistoryDto, error) { - result := &appStoreBean.InstallAppVersionHistoryDto{} - var history []*appStoreBean.IAVHistory - //TODO - response setup - - installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdMeta(installedAppId) - if err != nil { - impl.logger.Errorw("error while fetching installed version", "error", err) - return result, err - } - for _, installedAppVersionModel := range installedAppVersions { - versionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistoryByVersionId(installedAppVersionModel.Id) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error while fetching installed version history", "error", err) - return result, err - } - for _, updateHistory := range versionHistory { - history = append(history, &appStoreBean.IAVHistory{ - ChartMetaData: appStoreBean.IAVHistoryChartMetaData{ - ChartName: installedAppVersionModel.AppStoreApplicationVersion.AppStore.Name, - ChartVersion: installedAppVersionModel.AppStoreApplicationVersion.Version, - Description: installedAppVersionModel.AppStoreApplicationVersion.Description, - Home: installedAppVersionModel.AppStoreApplicationVersion.Home, - Sources: []string{installedAppVersionModel.AppStoreApplicationVersion.Source}, - }, - DockerImages: []string{installedAppVersionModel.AppStoreApplicationVersion.AppVersion}, - DeployedAt: appStoreBean.IAVHistoryDeployedAt{ - Nanos: updateHistory.CreatedOn.Nanosecond(), - Seconds: updateHistory.CreatedOn.Unix(), - }, - Version: updateHistory.Id, - InstalledAppVersionId: installedAppVersionModel.Id, - }) - } - } - - if len(history) == 0 { - history = make([]*appStoreBean.IAVHistory, 0) - } - result.IAVHistory = history - installedApp, err := impl.installedAppRepository.GetInstalledApp(installedAppId) - if err != nil { - impl.logger.Errorw("error while fetching installed version", "error", err) - return result, err - } - result.InstalledAppInfo = &appStoreBean.InstalledAppDto{ - AppId: installedApp.AppId, - EnvironmentName: installedApp.Environment.Name, - AppOfferingMode: installedApp.App.AppOfferingMode, - InstalledAppId: installedApp.Id, - ClusterId: installedApp.Environment.ClusterId, - EnvironmentId: installedApp.EnvironmentId, - } - return result, err -} - -func (impl InstalledAppServiceImpl) UpdateInstalledAppVersionStatus(application *v1alpha1.Application) (bool, error) { - isHealthy := false - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return isHealthy, err - } - // Rollback tx on error. - defer tx.Rollback() - gitHash := "" - if application.Operation != nil && application.Operation.Sync != nil { - gitHash = application.Operation.Sync.Revision - } else if application.Status.OperationState != nil && application.Status.OperationState.Operation.Sync != nil { - gitHash = application.Status.OperationState.Operation.Sync.Revision - } - versionHistory, err := impl.installedAppRepositoryHistory.GetLatestInstalledAppVersionHistoryByGitHash(gitHash) - if err != nil { - impl.logger.Errorw("error while fetching installed version history", "error", err) - return isHealthy, err - } - if versionHistory.Status != (application2.Healthy) { - versionHistory.Status = string(application.Status.Health.Status) - versionHistory.UpdatedOn = time.Now() - versionHistory.UpdatedBy = 1 - impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(versionHistory, tx) - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while committing transaction to db", "error", err) - return isHealthy, err - } - - appId, envId, err := impl.installedAppRepositoryHistory.GetAppIdAndEnvIdWithInstalledAppVersionId(versionHistory.InstalledAppVersionId) - if err == nil { - err = impl.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, string(application.Status.Health.Status)) - if err != nil { - impl.logger.Errorw("error while updating app status in app_status table", "error", err, "appId", appId, "envId", envId) - } - } - return true, nil -} - -func (impl InstalledAppServiceImpl) GetInstalledAppVersionHistoryValues(installedAppVersionHistoryId int) (*appStoreBean.IAVHistoryValues, error) { - values := &appStoreBean.IAVHistoryValues{} - versionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installedAppVersionHistoryId) - if err != nil { - impl.logger.Errorw("error while fetching installed version history", "error", err) - return nil, err - } - values.ValuesYaml = versionHistory.ValuesYamlRaw - return values, err -} - -func (impl InstalledAppServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *gRPC.ReleaseStatus { - //release status is sent in resource tree call and is shown on UI as helm config apply status - releaseStatus := &gRPC.ReleaseStatus{} - if len(helmReleaseInstallStatus) > 0 { - helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} - err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) - if err != nil { - impl.logger.Errorw("error in unmarshalling helm release install status") - return releaseStatus - } - if status == appStoreBean.HELM_RELEASE_STATUS_FAILED { - releaseStatus.Status = status - releaseStatus.Description = helmInstallStatus.Message - releaseStatus.Message = "Release install/upgrade failed" - } else if status == appStoreBean.HELM_RELEASE_STATUS_PROGRESSING { - releaseStatus.Status = status - releaseStatus.Description = helmInstallStatus.Message - releaseStatus.Message = helmInstallStatus.Message - } else { - // there can be a case when helm release is created but we are not able to fetch it - releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN - releaseStatus.Description = "Unable to fetch release for app" - releaseStatus.Message = "Unable to fetch release for app" - } - } else { - releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN - releaseStatus.Description = "Release not found" - releaseStatus.Message = "Release not found " - } - return releaseStatus -} - -// TODO fix me next -func (impl InstalledAppServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId int, envId int) error { - apiError := &util.ApiError{} - installedApp, err := impl.installedAppRepository.GetGitOpsInstalledAppsWhereArgoAppDeletedIsTrue(installedAppId, envId) - if err != nil { - impl.logger.Errorw("error in fetching partially deleted argoCd apps from installed app repo", "err", err) - apiError.HttpStatusCode = http.StatusInternalServerError - apiError.InternalMessage = "error in fetching partially deleted argoCd apps from installed app repo" - return apiError - } - // TODO refactoring: move the below logic to AppStoreDeploymentArgoCdService.go - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - apiError.HttpStatusCode = http.StatusInternalServerError - apiError.InternalMessage = "error in getting acd token" - return apiError - } - - ctx := context.Background() - ctx = context.WithValue(ctx, "token", acdToken) - - acdAppName := fmt.Sprintf("%s-%s", installedApp.App.AppName, installedApp.Environment.Name) - _, err = impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) - - if err == nil { - apiError.HttpStatusCode = http.StatusInternalServerError - apiError.InternalMessage = "App Exist in argo, error in fetching resource tree" - return apiError - } - - impl.logger.Warnw("app not found in argo, deleting from db ", "err", err) - //make call to delete it from pipeline DB - deleteRequest := &appStoreBean.InstallAppVersionDTO{} - deleteRequest.ForceDelete = false - deleteRequest.NonCascadeDelete = false - deleteRequest.AcdPartialDelete = false - deleteRequest.InstalledAppId = installedApp.Id - deleteRequest.AppId = installedApp.AppId - deleteRequest.AppName = installedApp.App.AppName - deleteRequest.Namespace = installedApp.Environment.Namespace - deleteRequest.ClusterId = installedApp.Environment.ClusterId - deleteRequest.EnvironmentId = installedApp.EnvironmentId - deleteRequest.AppOfferingMode = installedApp.App.AppOfferingMode - deleteRequest.UserId = 1 - _, err = impl.appStoreDeploymentService.DeleteInstalledApp(context.Background(), deleteRequest) - if err != nil { - impl.logger.Errorw("error in deleting installed app", "err", err) - apiError.HttpStatusCode = http.StatusNotFound - apiError.InternalMessage = "error in deleting installed app" - return apiError - } - apiError.HttpStatusCode = http.StatusNotFound - return apiError -} - -func (impl InstalledAppServiceImpl) CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) { - installedApp, err := impl.installedAppRepository.GetInstalledApp(installedAppId) - if err != nil { - return nil, err - } - return installedApp, err -} diff --git a/pkg/appStore/deployment/service/InstalledAppService_test.go b/pkg/appStore/deployment/service/InstalledAppService_test.go deleted file mode 100644 index 206b4c35ab..0000000000 --- a/pkg/appStore/deployment/service/InstalledAppService_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package service - -import ( - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" - "testing" - - pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" - repository5 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" - "github.com/devtron-labs/devtron/pkg/appStore/values/service" - "github.com/devtron-labs/devtron/pkg/auth/user" - "github.com/devtron-labs/devtron/pkg/cluster" - "github.com/devtron-labs/devtron/pkg/cluster/repository" - "github.com/devtron-labs/devtron/pkg/team" - util2 "github.com/devtron-labs/devtron/pkg/util" - "go.uber.org/zap" -) - -func TestInstalledAppServiceImpl_DeployDefaultChartOnCluster(t *testing.T) { - type fields struct { - logger *zap.SugaredLogger - installedAppRepository repository4.InstalledAppRepository - chartTemplateService util.ChartTemplateService - appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository.EnvironmentRepository - teamRepository team.TeamRepository - appRepository app.AppRepository - acdClient application.ServiceClient - appStoreValuesService service.AppStoreValuesService - pubsubClient *pubsub.PubSubClientServiceImpl - chartGroupDeploymentRepository repository5.ChartGroupDeploymentRepository - envService cluster.EnvironmentService - gitFactory *git.GitFactory - aCDAuthConfig *util2.ACDAuthConfig - userService user.UserService - appStoreDeploymentService AppStoreDeploymentService - } - type args struct { - bean *cluster.ClusterBean - userId int32 - } - tests := []struct { - name string - fields fields - args args - want bool - wantErr bool - }{ - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - impl := &InstalledAppServiceImpl{ - logger: tt.fields.logger, - installedAppRepository: tt.fields.installedAppRepository, - appStoreApplicationVersionRepository: tt.fields.appStoreApplicationVersionRepository, - environmentRepository: tt.fields.environmentRepository, - teamRepository: tt.fields.teamRepository, - appRepository: tt.fields.appRepository, - acdClient: tt.fields.acdClient, - appStoreValuesService: tt.fields.appStoreValuesService, - pubSubClient: tt.fields.pubsubClient, - chartGroupDeploymentRepository: tt.fields.chartGroupDeploymentRepository, - envService: tt.fields.envService, - aCDAuthConfig: tt.fields.aCDAuthConfig, - userService: tt.fields.userService, - appStoreDeploymentService: tt.fields.appStoreDeploymentService, - } - got, err := impl.DeployDefaultChartOnCluster(tt.args.bean, tt.args.userId) - if (err != nil) != tt.wantErr { - t.Errorf("DeployDefaultChartOnCluster() error = %v, wantErr %v", err, tt.wantErr) - return - } - if got != tt.want { - t.Errorf("DeployDefaultChartOnCluster() got = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/appStore/deployment/adapter/Adapter.go b/pkg/appStore/installedApp/adapter/Adapter.go similarity index 100% rename from pkg/appStore/deployment/adapter/Adapter.go rename to pkg/appStore/installedApp/adapter/Adapter.go diff --git a/pkg/appStore/deployment/repository/ClusterInstalledAppsRepository.go b/pkg/appStore/installedApp/repository/ClusterInstalledAppsRepository.go similarity index 100% rename from pkg/appStore/deployment/repository/ClusterInstalledAppsRepository.go rename to pkg/appStore/installedApp/repository/ClusterInstalledAppsRepository.go diff --git a/pkg/appStore/deployment/repository/InstalledAppModels.go b/pkg/appStore/installedApp/repository/InstalledAppModels.go similarity index 100% rename from pkg/appStore/deployment/repository/InstalledAppModels.go rename to pkg/appStore/installedApp/repository/InstalledAppModels.go diff --git a/pkg/appStore/deployment/repository/InstalledAppRepository.go b/pkg/appStore/installedApp/repository/InstalledAppRepository.go similarity index 100% rename from pkg/appStore/deployment/repository/InstalledAppRepository.go rename to pkg/appStore/installedApp/repository/InstalledAppRepository.go diff --git a/pkg/appStore/deployment/repository/InstalledAppVersionHistory.go b/pkg/appStore/installedApp/repository/InstalledAppVersionHistory.go similarity index 100% rename from pkg/appStore/deployment/repository/InstalledAppVersionHistory.go rename to pkg/appStore/installedApp/repository/InstalledAppVersionHistory.go diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go similarity index 78% rename from pkg/appStore/deployment/service/AppStoreDeploymentDBService.go rename to pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index dba9e489a8..513bbe1f7e 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -12,7 +12,7 @@ import ( "net/http" ) -func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { var isInternalUse = impl.deploymentTypeConfig.IsInternalUse @@ -148,7 +148,7 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVe return installAppVersionRequest, nil } -func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { +func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -174,35 +174,3 @@ func (impl AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(in } return true, nil } - -func (impl AppStoreDeploymentServiceImpl) GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) { - installedApp, err := impl.installedAppRepository.GetInstalledApplicationByClusterIdAndNamespaceAndAppName(clusterId, namespace, appName) - if err != nil { - if err == pg.ErrNoRows { - impl.logger.Warnw("no installed apps found", "clusterId", clusterId) - return nil, nil - } else { - impl.logger.Errorw("error while fetching installed apps", "clusterId", clusterId, "error", err) - return nil, err - } - } - - if installedApp.Id > 0 { - installedAppVersion, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedApp.Id, installedApp.EnvironmentId) - if err != nil { - return nil, err - } - return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil - } - - return nil, nil -} - -func (impl AppStoreDeploymentServiceImpl) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) { - installedAppVersion, err := impl.installedAppRepository.GetActiveInstalledAppVersionByInstalledAppId(installedAppId) - if err != nil { - return nil, err - } - installedApp := &installedAppVersion.InstalledApp - return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil -} diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go similarity index 81% rename from pkg/appStore/deployment/service/AppStoreDeploymentService.go rename to pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 8cf1a5344c..a752b112f3 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -37,17 +37,17 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository3 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - appStoreDeploymentTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" - bean2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + bean2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -78,9 +78,7 @@ type AppStoreDeploymentService interface { UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error - - GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) - GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) + MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error } type DeploymentServiceTypeConfig struct { @@ -102,8 +100,8 @@ type AppStoreDeploymentServiceImpl struct { environmentRepository clusterRepository.EnvironmentRepository clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository appRepository app.AppRepository - appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService - appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService + eaModeDeploymentService EAMode.EAModeDeploymentService + fullModeDeploymentService deployment.FullModeDeploymentService environmentService cluster.EnvironmentService clusterService cluster.ClusterService helmAppService service.HelmAppService @@ -112,21 +110,18 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - gitOperationService git.GitOperationService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository clusterRepository.EnvironmentRepository, clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, - appStoreDeploymentHelmService appStoreDeploymentTool.AppStoreDeploymentHelmService, - appStoreDeploymentArgoCdService appStoreDeploymentTool.AppStoreDeploymentArgoCdService, environmentService cluster.EnvironmentService, + eaModeDeploymentService EAMode.EAModeDeploymentService, + fullModeDeploymentService deployment.FullModeDeploymentService, environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService service.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService, - gitOperationService git.GitOperationService) *AppStoreDeploymentServiceImpl { - - appStoreDeploymentServiceImpl := &AppStoreDeploymentServiceImpl{ + gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { + return &AppStoreDeploymentServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, chartGroupDeploymentRepository: chartGroupDeploymentRepository, @@ -134,8 +129,8 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep environmentRepository: environmentRepository, clusterInstalledAppsRepository: clusterInstalledAppsRepository, appRepository: appRepository, - appStoreDeploymentHelmService: appStoreDeploymentHelmService, - appStoreDeploymentArgoCdService: appStoreDeploymentArgoCdService, + eaModeDeploymentService: eaModeDeploymentService, + fullModeDeploymentService: fullModeDeploymentService, environmentService: environmentService, clusterService: clusterService, helmAppService: helmAppService, @@ -144,9 +139,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep deploymentTypeConfig: deploymentTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, - gitOperationService: gitOperationService, } - return appStoreDeploymentServiceImpl } func (impl *AppStoreDeploymentServiceImpl) IsChartRepoActive(appStoreVersionId int) (bool, error) { @@ -163,7 +156,7 @@ func (impl *AppStoreDeploymentServiceImpl) IsChartRepoActive(appStoreVersionId i return false, nil } -func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() @@ -181,32 +174,32 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a installedAppDeploymentAction := adapter.NewInstalledAppDeploymentAction(installAppVersionRequest.DeploymentAppType) if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) || util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) } if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) } var gitOpsResponse *bean2.AppStoreGitOpsResponse if installedAppDeploymentAction.PerformGitOps { - manifest, err := impl.appStoreDeploymentArgoCdService.GenerateManifest(installAppVersionRequest) + manifest, err := impl.fullModeDeploymentService.GenerateManifest(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in performing manifest and git operations", "err", err) return nil, err } - gitOpsResponse, err = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) + gitOpsResponse, err = impl.fullModeDeploymentService.GitOpsOperations(manifest, installAppVersionRequest) if err != nil { impl.logger.Errorw("error in doing gitops operation", "err", err) if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) } return nil, err } if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) if !impl.aCDConfig.ArgoCDAutoSyncEnabled { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "argocd sync initiated.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "argocd sync initiated.", time.Now(), tx) } } installAppVersionRequest.GitHash = gitOpsResponse.GitHash @@ -220,12 +213,12 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a } if util2.IsBaseStack() || util2.IsHelmApp(installAppVersionRequest.AppOfferingMode) || util.IsHelmApp(installAppVersionRequest.DeploymentAppType) { - installAppVersionRequest, err = impl.appStoreDeploymentHelmService.InstallApp(installAppVersionRequest, nil, ctx, tx) + installAppVersionRequest, err = impl.eaModeDeploymentService.InstallApp(installAppVersionRequest, nil, ctx, tx) } else if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { if gitOpsResponse == nil && gitOpsResponse.ChartGitAttribute != nil { return nil, errors.New("service err, Error in git operations") } - installAppVersionRequest, err = impl.appStoreDeploymentArgoCdService.InstallApp(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, ctx, tx) + installAppVersionRequest, err = impl.fullModeDeploymentService.InstallApp(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, ctx, tx) } if err != nil { return nil, err @@ -240,7 +233,7 @@ func (impl AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *a return installAppVersionRequest, nil } -func (impl AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string) error { +func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string) error { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -264,7 +257,7 @@ func (impl AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryStatus return nil } -func (impl AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistory(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*repository.InstalledAppVersionHistory, error) { +func (impl *AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistory(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*repository.InstalledAppVersionHistory, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -294,7 +287,8 @@ func (impl AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistory(install } return installedAppVersionHistory, nil } -func (impl AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryWithGitHash(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) error { + +func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryWithGitHash(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) error { savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) savedInstalledAppVersionHistory.GitHash = installAppVersionRequest.GitHash savedInstalledAppVersionHistory.UpdatedOn = time.Now() @@ -307,7 +301,7 @@ func (impl AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryWithGi return nil } -func (impl AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string, skipAppCreation bool) (*bean.CreateAppDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string, skipAppCreation bool) (*bean.CreateAppDTO, error) { app1, err := impl.appRepository.FindActiveByName(createRequest.AppName) if err != nil && err != pg.ErrNoRows { return nil, err @@ -372,7 +366,7 @@ func (impl AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *be return createRequest, nil } -func (impl AppStoreDeploymentServiceImpl) GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) { app, err := impl.installedAppRepository.GetInstalledApp(id) if err != nil { impl.logger.Errorw("error while fetching from db", "error", err) @@ -382,7 +376,7 @@ func (impl AppStoreDeploymentServiceImpl) GetInstalledApp(id int) (*appStoreBean return chartTemplate, nil } -func (impl AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) { +func (impl *AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) { installedApps, err := impl.installedAppRepository.GetAllInstalledAppsByAppStoreId(appStoreId) if err != nil && !util.IsErrNoRows(err) { impl.logger.Error(err) @@ -420,7 +414,7 @@ func (impl AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http return installedAppsEnvResponse, nil } -func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest.InstalledAppDeleteResponse = &appStoreBean.InstalledAppDeleteResponseDTO{ DeleteInitiated: false, ClusterReachable: true, @@ -464,7 +458,7 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context return installAppVersionRequest, nil } } - err = impl.appStoreDeploymentArgoCdService.DeleteDeploymentApp(ctx, app.AppName, environment.Name, installAppVersionRequest) + err = impl.fullModeDeploymentService.DeleteACDAppObject(ctx, app.AppName, environment.Name, installAppVersionRequest) } if err != nil { impl.logger.Errorw("error on delete installed app", "err", err) @@ -535,9 +529,9 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context // there might be a case if helm release gets uninstalled from helm cli. //in this case on deleting the app from API, it should not give error as it should get deleted from db, otherwise due to delete error, db does not get clean // so in helm, we need to check first if the release exists or not, if exists then only delete - err = impl.appStoreDeploymentHelmService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) + err = impl.eaModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) } else { - err = impl.appStoreDeploymentArgoCdService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) + err = impl.fullModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) } if err != nil { impl.logger.Errorw("error on delete installed app", "err", err) @@ -553,7 +547,7 @@ func (impl AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context return installAppVersionRequest, nil } -func (impl AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, +func (impl *AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, appIdentifier *service.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) { impl.logger.Infow("Linking helm application to chart store", "appId", request.GetAppId()) @@ -606,7 +600,7 @@ func (impl AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx co return res, isChartRepoActive, nil } -func (impl AppStoreDeploymentServiceImpl) createEnvironmentIfNotExists(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (int, error) { +func (impl *AppStoreDeploymentServiceImpl) createEnvironmentIfNotExists(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (int, error) { clusterId := installAppVersionRequest.ClusterId namespace := installAppVersionRequest.Namespace env, err := impl.environmentRepository.FindOneByNamespaceAndClusterId(namespace, clusterId) @@ -640,7 +634,7 @@ func (impl AppStoreDeploymentServiceImpl) createEnvironmentIfNotExists(installAp return envCreateRes.Id, nil } -func (impl AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Context, request *openapi2.RollbackReleaseRequest, +func (impl *AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Context, request *openapi2.RollbackReleaseRequest, installedApp *appStoreBean.InstallAppVersionDTO, userId int32) (bool, error) { triggeredAt := time.Now() dbConnection := impl.installedAppRepository.GetConnection() @@ -654,13 +648,13 @@ func (impl AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Contex // Rollback starts var success bool if util2.IsHelmApp(installedApp.AppOfferingMode) { - installedApp, success, err = impl.appStoreDeploymentHelmService.RollbackRelease(ctx, installedApp, request.GetVersion(), tx) + installedApp, success, err = impl.eaModeDeploymentService.RollbackRelease(ctx, installedApp, request.GetVersion(), tx) if err != nil { impl.logger.Errorw("error while rollback helm release", "error", err) return false, err } } else { - installedApp, success, err = impl.appStoreDeploymentArgoCdService.RollbackRelease(ctx, installedApp, request.GetVersion(), tx) + installedApp, success, err = impl.fullModeDeploymentService.RollbackRelease(ctx, installedApp, request.GetVersion(), tx) if err != nil { impl.logger.Errorw("error while rollback helm release", "error", err) return false, err @@ -703,7 +697,7 @@ func (impl AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Contex return success, nil } -func (impl AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*openapi.UpdateReleaseResponse, error) { +func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*openapi.UpdateReleaseResponse, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -774,7 +768,7 @@ func (impl AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(instal return res, nil } -func (impl AppStoreDeploymentServiceImpl) installAppPostDbOperation(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *AppStoreDeploymentServiceImpl) installAppPostDbOperation(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { //step 4 db operation status update to deploy success _, err := impl.AppStoreDeployOperationStatusUpdate(installAppVersionRequest.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) if err != nil { @@ -793,7 +787,7 @@ func (impl AppStoreDeploymentServiceImpl) installAppPostDbOperation(installAppVe return nil } -func (impl AppStoreDeploymentServiceImpl) updateInstalledAppVersionHistoryWithSync(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *AppStoreDeploymentServiceImpl) updateInstalledAppVersionHistoryWithSync(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { if installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD { err := impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowSucceeded) if err != nil { @@ -829,18 +823,19 @@ func (impl AppStoreDeploymentServiceImpl) updateInstalledAppVersionHistoryWithSy } return nil } -func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) { + +func (impl *AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) { result := &bean3.DeploymentHistoryAndInstalledAppInfo{} var err error if util2.IsHelmApp(installedApp.AppOfferingMode) { - deploymentHistory, err := impl.appStoreDeploymentHelmService.GetDeploymentHistory(ctx, installedApp) + deploymentHistory, err := impl.eaModeDeploymentService.GetDeploymentHistory(ctx, installedApp) if err != nil { impl.logger.Errorw("error while getting deployment history", "error", err) return nil, err } result.DeploymentHistory = deploymentHistory.GetDeploymentHistory() } else { - deploymentHistory, err := impl.appStoreDeploymentArgoCdService.GetDeploymentHistory(ctx, installedApp) + deploymentHistory, err := impl.fullModeDeploymentService.GetDeploymentHistory(ctx, installedApp) if err != nil { impl.logger.Errorw("error while getting deployment history", "error", err) return nil, err @@ -865,21 +860,21 @@ func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Conte return result, err } -func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int) (*openapi.HelmAppDeploymentManifestDetail, error) { +func (impl *AppStoreDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int) (*openapi.HelmAppDeploymentManifestDetail, error) { //var result interface{} result := &openapi.HelmAppDeploymentManifestDetail{} var err error if util2.IsHelmApp(installedApp.AppOfferingMode) { - _, span := otel.Tracer("orchestrator").Start(ctx, "appStoreDeploymentHelmService.GetDeploymentHistoryInfo") - result, err = impl.appStoreDeploymentHelmService.GetDeploymentHistoryInfo(ctx, installedApp, int32(version)) + _, span := otel.Tracer("orchestrator").Start(ctx, "eaModeDeploymentService.GetDeploymentHistoryInfo") + result, err = impl.eaModeDeploymentService.GetDeploymentHistoryInfo(ctx, installedApp, int32(version)) span.End() if err != nil { impl.logger.Errorw("error while getting deployment history info", "error", err) return nil, err } } else { - _, span := otel.Tracer("orchestrator").Start(ctx, "appStoreDeploymentArgoCdService.GetDeploymentHistoryInfo") - result, err = impl.appStoreDeploymentArgoCdService.GetDeploymentHistoryInfo(ctx, installedApp, int32(version)) + _, span := otel.Tracer("orchestrator").Start(ctx, "fullModeDeploymentService.GetDeploymentHistoryInfo") + result, err = impl.fullModeDeploymentService.GetDeploymentHistoryInfo(ctx, installedApp, int32(version)) span.End() if err != nil { impl.logger.Errorw("error while getting deployment history info", "error", err) @@ -889,7 +884,7 @@ func (impl AppStoreDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.C return result, err } -func (impl AppStoreDeploymentServiceImpl) updateInstalledAppVersion(installedAppVersion *repository.InstalledAppVersions, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, installedApp *repository.InstalledApps) (*repository.InstalledAppVersions, *appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) updateInstalledAppVersion(installedAppVersion *repository.InstalledAppVersions, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, installedApp *repository.InstalledApps) (*repository.InstalledAppVersions, *appStoreBean.InstallAppVersionDTO, error) { var err error if installAppVersionRequest.Id == 0 { installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installAppVersionRequest.InstalledAppId) @@ -1042,7 +1037,7 @@ func (impl *AppStoreDeploymentServiceImpl) CheckIfMonoRepoMigrationRequired(inst gitOpsRepoName := installedApp.GitOpsRepoName if len(gitOpsRepoName) == 0 { if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) + gitOpsRepoName, err = impl.fullModeDeploymentService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) if err != nil { return false } @@ -1163,17 +1158,17 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex return nil, err } installAppVersionRequest.InstalledAppVersionHistoryId = installedAppVersionHistory.Id - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, "Deployment initiated successfully.", time.Now(), tx) if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_DESCRIPTION_MANIFEST_GENERATED, "Manifest generated successfully.", time.Now(), tx) } // gitOps operation monoRepoMigrationRequired := false gitOpsResponse := &bean2.AppStoreGitOpsResponse{} if installedAppDeploymentAction.PerformGitOps { - manifest, err := impl.appStoreDeploymentArgoCdService.GenerateManifest(installAppVersionRequest) + manifest, err := impl.fullModeDeploymentService.GenerateManifest(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in generating manifest for helm apps", "err", err) _ = impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowFailed) @@ -1183,7 +1178,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex gitOpsRepoName := installedApp.GitOpsRepoName if len(gitOpsRepoName) == 0 { if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - gitOpsRepoName, err = impl.appStoreDeploymentArgoCdService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) + gitOpsRepoName, err = impl.fullModeDeploymentService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) if err != nil { return nil, err } @@ -1209,28 +1204,28 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex // TODO refactoring: move this logic to AppStoreDeploymentGitService.go if monoRepoMigrationRequired { // create new git repo if repo name changed - gitOpsResponse, createRepoErr = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) + gitOpsResponse, createRepoErr = impl.fullModeDeploymentService.GitOpsOperations(manifest, installAppVersionRequest) gitHash = gitOpsResponse.GitHash } else if isChartChanged || isVersionChanged { // update dependency if chart or chart version is changed - _, _, requirementsCommitErr = impl.gitOperationService.CommitValues(manifest.RequirementsConfig) - gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) + _, _, requirementsCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.RequirementsConfig) + gitHash, _, valuesCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.ValuesConfig) } else { // only values are changed in update, so commit values config - gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) + gitHash, _, valuesCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.ValuesConfig) } if valuesCommitErr != nil || requirementsCommitErr != nil { - noTargetFoundForValues, _ := impl.appStoreDeploymentArgoCdService.ParseGitRepoErrorResponse(valuesCommitErr) - noTargetFoundForRequirements, _ := impl.appStoreDeploymentArgoCdService.ParseGitRepoErrorResponse(requirementsCommitErr) + noTargetFoundForValues, _ := impl.fullModeDeploymentService.ParseGitRepoErrorResponse(valuesCommitErr) + noTargetFoundForRequirements, _ := impl.fullModeDeploymentService.ParseGitRepoErrorResponse(requirementsCommitErr) if noTargetFoundForRequirements || noTargetFoundForValues { //create repo again and try again - auto fix monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required - gitOpsResponse, createRepoErr = impl.appStoreDeploymentArgoCdService.GitOpsOperations(manifest, installAppVersionRequest) + gitOpsResponse, createRepoErr = impl.fullModeDeploymentService.GitOpsOperations(manifest, installAppVersionRequest) gitHash = gitOpsResponse.GitHash } @@ -1238,15 +1233,15 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex if createRepoErr != nil || requirementsCommitErr != nil || valuesCommitErr != nil { impl.logger.Errorw("error in doing gitops operation", "err", err) - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) // TODO refactoring: return proper err object return nil, err } installAppVersionRequest.GitHash = gitHash - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) if !impl.aCDConfig.ArgoCDAutoSyncEnabled { - _ = impl.appStoreDeploymentArgoCdService.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "Argocd sync initiated", time.Now(), tx) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "Argocd sync initiated", time.Now(), tx) } installedAppVersionHistory.GitHash = gitHash _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, tx) @@ -1258,13 +1253,13 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex if installedAppDeploymentAction.PerformACDDeployment { // refresh update repo details on ArgoCD if repo is changed - err = impl.appStoreDeploymentArgoCdService.UpdateAndSyncACDApps(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, monoRepoMigrationRequired, ctx, tx) + err = impl.fullModeDeploymentService.UpdateAndSyncACDApps(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, monoRepoMigrationRequired, ctx, tx) if err != nil { impl.logger.Errorw("error in acd patch request", "err", err) return nil, err } } else if installedAppDeploymentAction.PerformHelmDeployment { - err = impl.appStoreDeploymentHelmService.UpdateChartInfo(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, installAppVersionRequest.InstalledAppVersionHistoryId, ctx) + err = impl.eaModeDeploymentService.UpgradeDeployment(installAppVersionRequest, gitOpsResponse.ChartGitAttribute, installAppVersionRequest.InstalledAppVersionHistoryId, ctx) if err != nil { if err != nil { impl.logger.Errorw("error in helm update request", "err", err) @@ -1304,7 +1299,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex return installAppVersionRequest, nil } -func (impl AppStoreDeploymentServiceImpl) GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { app, err := impl.installedAppRepository.GetInstalledAppVersion(id) if err != nil { if err == pg.ErrNoRows { @@ -1341,8 +1336,8 @@ func (impl AppStoreDeploymentServiceImpl) GetInstalledAppVersion(id int, userId return installAppVersion, err } -func (impl AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { - installAppVersionRequest, err := impl.appStoreDeploymentHelmService.InstallApp(installAppVersionRequest, nil, ctx, nil) +func (impl *AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { + installAppVersionRequest, err := impl.eaModeDeploymentService.InstallApp(installAppVersionRequest, nil, ctx, nil) if err != nil { impl.logger.Errorw("error while installing app via helm", "error", err) return installAppVersionRequest, err @@ -1357,7 +1352,7 @@ func (impl AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionRequ return installAppVersionRequest, nil } -func (impl AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error { +func (impl *AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error { appIdSplitted := strings.Split(updateAppRequest.AppId, "|") @@ -1421,12 +1416,12 @@ func (impl AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest } -func (impl AppStoreDeploymentServiceImpl) UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { +func (impl *AppStoreDeploymentServiceImpl) UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { //creating pipeline status timeline for deployment failed if !util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { return nil } - err1 := impl.appStoreDeploymentArgoCdService.UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest, triggeredAt, err) + err1 := impl.fullModeDeploymentService.UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest, triggeredAt, err) if err1 != nil { impl.logger.Errorw("error in updating previous deployment status for appStore", "err", err1, "installAppVersionRequest", installAppVersionRequest) return err1 @@ -1434,7 +1429,7 @@ func (impl AppStoreDeploymentServiceImpl) UpdatePreviousDeploymentStatusForAppSt return nil } -func (impl AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error { +func (impl *AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -1456,3 +1451,56 @@ func (impl AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistoryStatus(i } return nil } + +func (impl *AppStoreDeploymentServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error { + apiError := &util.ApiError{} + installedApp, err := impl.installedAppRepository.GetGitOpsInstalledAppsWhereArgoAppDeletedIsTrue(installedAppId, envId) + if err != nil { + impl.logger.Errorw("error in fetching partially deleted argoCd apps from installed app repo", "err", err) + apiError.HttpStatusCode = http.StatusInternalServerError + apiError.InternalMessage = "error in fetching partially deleted argoCd apps from installed app repo" + return apiError + } + if !util.IsAcdApp(installedApp.DeploymentAppType) || !installedApp.DeploymentAppDeleteRequest { + return nil + } + // Operates for ArgoCd apps only + acdAppName := fmt.Sprintf("%s-%s", installedApp.App.AppName, installedApp.Environment.Name) + isFound, err := impl.fullModeDeploymentService.CheckIfArgoAppExists(acdAppName) + if err != nil { + impl.logger.Errorw("error in CheckIfArgoAppExists", "err", err) + apiError.HttpStatusCode = http.StatusInternalServerError + apiError.InternalMessage = err.Error() + return apiError + } + + if isFound { + apiError.HttpStatusCode = http.StatusInternalServerError + apiError.InternalMessage = "App Exist in argo, error in fetching resource tree" + return apiError + } + + impl.logger.Warnw("app not found in argo, deleting from db ", "err", err) + //make call to delete it from pipeline DB + deleteRequest := &appStoreBean.InstallAppVersionDTO{} + deleteRequest.ForceDelete = false + deleteRequest.NonCascadeDelete = false + deleteRequest.AcdPartialDelete = false + deleteRequest.InstalledAppId = installedApp.Id + deleteRequest.AppId = installedApp.AppId + deleteRequest.AppName = installedApp.App.AppName + deleteRequest.Namespace = installedApp.Environment.Namespace + deleteRequest.ClusterId = installedApp.Environment.ClusterId + deleteRequest.EnvironmentId = installedApp.EnvironmentId + deleteRequest.AppOfferingMode = installedApp.App.AppOfferingMode + deleteRequest.UserId = 1 + _, err = impl.DeleteInstalledApp(context.Background(), deleteRequest) + if err != nil { + impl.logger.Errorw("error in deleting installed app", "err", err) + apiError.HttpStatusCode = http.StatusNotFound + apiError.InternalMessage = "error in deleting installed app" + return apiError + } + apiError.HttpStatusCode = http.StatusNotFound + return apiError +} diff --git a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go similarity index 99% rename from pkg/appStore/deployment/service/AppStoreDeploymentService_test.go rename to pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go index 81eae67783..912d80a659 100644 --- a/pkg/appStore/deployment/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go @@ -10,8 +10,8 @@ import ( "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + repository3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" repository5 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go similarity index 76% rename from pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go rename to pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 4f4d28c7a8..583ade35d1 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentHelmService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -1,4 +1,4 @@ -package appStoreDeploymentTool +package EAMode import ( "context" @@ -7,32 +7,32 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "time" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/go-pg/pg" "go.opentelemetry.io/otel" "go.uber.org/zap" "sigs.k8s.io/yaml" ) -type AppStoreDeploymentHelmService interface { +type EAModeDeploymentService interface { InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error - UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error + UpgradeDeployment(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error } -type AppStoreDeploymentHelmServiceImpl struct { +type EAModeDeploymentServiceImpl struct { Logger *zap.SugaredLogger helmAppService client.HelmAppService appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository @@ -42,12 +42,12 @@ type AppStoreDeploymentHelmServiceImpl struct { OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository } -func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, +func NewEAModeDeploymentServiceImpl(logger *zap.SugaredLogger, helmAppService client.HelmAppService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, helmAppClient gRPC.HelmAppClient, installedAppRepository repository.InstalledAppRepository, - OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *AppStoreDeploymentHelmServiceImpl { - return &AppStoreDeploymentHelmServiceImpl{ + OCIRegistryConfigRepository repository2.OCIRegistryConfigRepository) *EAModeDeploymentServiceImpl { + return &EAModeDeploymentServiceImpl{ Logger: logger, helmAppService: helmAppService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, @@ -57,7 +57,7 @@ func NewAppStoreDeploymentHelmServiceImpl(logger *zap.SugaredLogger, helmAppServ } } -func (impl AppStoreDeploymentHelmServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { +func (impl *EAModeDeploymentServiceImpl) UpgradeDeployment(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { err := impl.updateApplicationWithChartInfo(ctx, installAppVersionRequest.InstalledAppId, installAppVersionRequest.AppStoreVersion, installAppVersionRequest.ValuesOverrideYaml, installedAppVersionHistoryId) if err != nil { impl.Logger.Errorw("error in updating helm app", "err", err) @@ -66,7 +66,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) UpdateChartInfo(installAppVersionR return nil } -func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { @@ -131,7 +131,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) InstallApp(installAppVersionReques return installAppVersionRequest, nil } -func (impl AppStoreDeploymentHelmServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { +func (impl *EAModeDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { if installAppVersionRequest.ForceDelete { return nil } @@ -162,7 +162,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) DeleteInstalledApp(ctx context.Con } // returns - valuesYamlStr, success, error -func (impl AppStoreDeploymentHelmServiceImpl) RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) { +func (impl *EAModeDeploymentServiceImpl) RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) { // TODO : fetch values yaml from DB instead of fetching from helm cli // TODO Dependency : on updating helm APP, DB is not being updated. values yaml is sent directly to helm cli. After DB updatation development, we can fetch values yaml from DB, not from CLI. @@ -195,7 +195,7 @@ func (impl AppStoreDeploymentHelmServiceImpl) RollbackRelease(ctx context.Contex return installedApp, success, nil } -func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { +func (impl *EAModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { helmAppIdentifier := &client.AppIdentifier{ ClusterId: installedApp.ClusterId, Namespace: installedApp.Namespace, @@ -205,7 +205,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistory(ctx context. return history, err } -func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) { +func (impl *EAModeDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) { helmAppIdeltifier := &client.AppIdentifier{ ClusterId: installedApp.ClusterId, Namespace: installedApp.Namespace, @@ -241,7 +241,7 @@ func (impl *AppStoreDeploymentHelmServiceImpl) GetDeploymentHistoryInfo(ctx cont return response, nil } -func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ctx context.Context, installedAppId int, appStoreApplicationVersionId int, valuesOverrideYaml string, installAppVersionHistoryId int) error { +func (impl *EAModeDeploymentServiceImpl) updateApplicationWithChartInfo(ctx context.Context, installedAppId int, appStoreApplicationVersionId int, valuesOverrideYaml string, installAppVersionHistoryId int) error { installedApp, err := impl.installedAppRepository.GetInstalledApp(installedAppId) if err != nil { impl.Logger.Errorw("error in getting in installedApp", "installedAppId", installedAppId, "err", err) @@ -317,45 +317,53 @@ func (impl *AppStoreDeploymentHelmServiceImpl) updateApplicationWithChartInfo(ct return nil } -func (impl *AppStoreDeploymentHelmServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { +func (impl *EAModeDeploymentServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { return "", errors.New("method GetGitOpsRepoName not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *EAModeDeploymentServiceImpl) DeleteACDAppObject(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { return errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error { +func (impl *EAModeDeploymentServiceImpl) SaveTimelineForHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error { return errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { +func (impl *EAModeDeploymentServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { return errors.New("this is not implemented") } // TODO: Need to refactor this,refer below reason // This is being done as in ea mode wire argocd service is being binded to helmServiceImpl due to which we are restricted to implement this here. // RefreshAndUpdateACDApp this will update chart info in acd app if required in case of mono repo migration and will refresh argo app -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { +func (impl *EAModeDeploymentServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { return errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) UpdateValuesDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *EAModeDeploymentServiceImpl) UpdateValuesDependencies(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { return errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { +func (impl *EAModeDeploymentServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { return false, errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { +func (impl *EAModeDeploymentServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { return nil, errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { +func (impl *EAModeDeploymentServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { return nil, errors.New("this is not implemented") } -func (impl *AppStoreDeploymentHelmServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { +func (impl *EAModeDeploymentServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { return nil, errors.New("this is not implemented") } + +func (impl *EAModeDeploymentServiceImpl) CheckIfArgoAppExists(acdAppName string) (isFound bool, err error) { + return isFound, errors.New("this is not implemented") +} + +func (impl *EAModeDeploymentServiceImpl) CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) { + return commitHash, commitTime, errors.New("this is not implemented") +} diff --git a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go new file mode 100644 index 0000000000..8f61cdcc7f --- /dev/null +++ b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package EAMode + +import ( + "github.com/devtron-labs/devtron/pkg/appStore/adapter" + "strconv" + "strings" + "time" + + "github.com/Pallinder/go-randomdata" + bean2 "github.com/devtron-labs/devtron/api/bean" + openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" + "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internal/util" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/auth/user" + "github.com/devtron-labs/devtron/pkg/bean" + util3 "github.com/devtron-labs/devtron/util" + "github.com/go-pg/pg" + "go.uber.org/zap" +) + +type InstalledAppDBService interface { + GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) + CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) + FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) + CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) + GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) + GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) +} + +type InstalledAppDBServiceImpl struct { + Logger *zap.SugaredLogger + InstalledAppRepository repository2.InstalledAppRepository + AppRepository app.AppRepository + UserService user.UserService + InstalledAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository +} + +func NewInstalledAppDBServiceImpl(logger *zap.SugaredLogger, + installedAppRepository repository2.InstalledAppRepository, + appRepository app.AppRepository, + userService user.UserService, + installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository) *InstalledAppDBServiceImpl { + return &InstalledAppDBServiceImpl{ + Logger: logger, + InstalledAppRepository: installedAppRepository, + AppRepository: appRepository, + UserService: userService, + InstalledAppRepositoryHistory: installedAppRepositoryHistory, + } +} + +func (impl *InstalledAppDBServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) { + applicationType := "DEVTRON-CHART-STORE" + var clusterIdsConverted []int32 + for _, clusterId := range filter.ClusterIds { + clusterIdsConverted = append(clusterIdsConverted, int32(clusterId)) + } + installedAppsResponse := openapi.AppList{ + ApplicationType: &applicationType, + ClusterIds: &clusterIdsConverted, + } + start := time.Now() + installedApps, err := impl.InstalledAppRepository.GetAllInstalledApps(filter) + middleware.AppListingDuration.WithLabelValues("getAllInstalledApps", "helm").Observe(time.Since(start).Seconds()) + if err != nil && !util.IsErrNoRows(err) { + impl.Logger.Error(err) + return installedAppsResponse, err + } + var helmAppsResponse []openapi.HelmApp + for _, a := range installedApps { + appLocal := a // copied data from here because value is passed as reference + if appLocal.TeamId == 0 && appLocal.AppOfferingMode != util3.SERVER_MODE_HYPERION { + //skipping entries for empty projectId for non hyperion app (as app list should return the helm apps from installedApps) + continue + } + appId := strconv.Itoa(appLocal.Id) + projectId := int32(appLocal.TeamId) + envId := int32(appLocal.EnvironmentId) + clusterId := int32(appLocal.ClusterId) + environmentDetails := openapi.AppEnvironmentDetail{ + EnvironmentName: &appLocal.EnvironmentName, + EnvironmentId: &envId, + Namespace: &appLocal.Namespace, + ClusterName: &appLocal.ClusterName, + ClusterId: &clusterId, + } + helmAppResp := openapi.HelmApp{ + AppName: &appLocal.AppName, + ChartName: &appLocal.AppStoreApplicationName, + AppId: &appId, + ProjectId: &projectId, + EnvironmentDetail: &environmentDetails, + ChartAvatar: &appLocal.Icon, + LastDeployedAt: &appLocal.UpdatedOn, + AppStatus: &appLocal.AppStatus, + } + helmAppsResponse = append(helmAppsResponse, helmAppResp) + } + installedAppsResponse.HelmApps = &helmAppsResponse + return installedAppsResponse, nil +} + +func (impl *InstalledAppDBServiceImpl) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) { + if len(appNames) == 0 { + return nil, nil + } + var names []string + for _, appName := range appNames { + names = append(names, appName.Name) + } + + apps, err := impl.AppRepository.CheckAppExists(names) + if err != nil { + return nil, err + } + existingApps := make(map[string]bool) + for _, app := range apps { + existingApps[app.AppName] = true + } + for _, appName := range appNames { + if _, ok := existingApps[appName.Name]; ok { + appName.Exists = true + appName.SuggestedName = strings.ToLower(randomdata.SillyName()) + } + } + return appNames, nil +} + +func (impl *InstalledAppDBServiceImpl) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) { + installedAppVerison, err := impl.InstalledAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) + if err != nil { + impl.Logger.Error(err) + return bean2.AppDetailContainer{}, err + } + helmReleaseInstallStatus, status, err := impl.InstalledAppRepository.GetHelmReleaseStatusConfigByInstalledAppId(installedAppVerison.InstalledAppId) + if err != nil { + impl.Logger.Errorw("error in getting helm release status from db", "err", err) + return bean2.AppDetailContainer{}, err + } + var chartName string + if installedAppVerison.AppStoreApplicationVersion.AppStore.ChartRepoId != 0 { + chartName = installedAppVerison.AppStoreApplicationVersion.AppStore.ChartRepo.Name + } else { + chartName = installedAppVerison.AppStoreApplicationVersion.AppStore.DockerArtifactStore.Id + } + deploymentContainer := bean2.DeploymentDetailContainer{ + InstalledAppId: installedAppVerison.InstalledApp.Id, + AppId: installedAppVerison.InstalledApp.App.Id, + AppStoreInstalledAppVersionId: installedAppVerison.Id, + EnvironmentId: installedAppVerison.InstalledApp.EnvironmentId, + AppName: installedAppVerison.InstalledApp.App.AppName, + AppStoreChartName: chartName, + AppStoreChartId: installedAppVerison.AppStoreApplicationVersion.AppStore.Id, + AppStoreAppName: installedAppVerison.AppStoreApplicationVersion.Name, + AppStoreAppVersion: installedAppVerison.AppStoreApplicationVersion.Version, + EnvironmentName: installedAppVerison.InstalledApp.Environment.Name, + LastDeployedTime: installedAppVerison.UpdatedOn.Format(bean.LayoutRFC3339), + Namespace: installedAppVerison.InstalledApp.Environment.Namespace, + Deprecated: installedAppVerison.AppStoreApplicationVersion.Deprecated, + ClusterId: installedAppVerison.InstalledApp.Environment.ClusterId, + DeploymentAppType: installedAppVerison.InstalledApp.DeploymentAppType, + DeploymentAppDeleteRequest: installedAppVerison.InstalledApp.DeploymentAppDeleteRequest, + IsVirtualEnvironment: installedAppVerison.InstalledApp.Environment.IsVirtualEnvironment, + HelmReleaseInstallStatus: helmReleaseInstallStatus, + Status: status, + } + userInfo, err := impl.UserService.GetByIdIncludeDeleted(installedAppVerison.AuditLog.UpdatedBy) + if err != nil { + impl.Logger.Errorw("error fetching user info", "err", err) + return bean2.AppDetailContainer{}, err + } + deploymentContainer.LastDeployedBy = userInfo.EmailId + appDetail := bean2.AppDetailContainer{ + DeploymentDetailContainer: deploymentContainer, + } + return appDetail, nil +} + +func (impl *InstalledAppDBServiceImpl) CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) { + installedApp, err := impl.InstalledAppRepository.GetInstalledApp(installedAppId) + if err != nil { + return nil, err + } + return installedApp, err +} + +func (impl *InstalledAppDBServiceImpl) GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) { + installedApp, err := impl.InstalledAppRepository.GetInstalledApplicationByClusterIdAndNamespaceAndAppName(clusterId, namespace, appName) + if err != nil { + if err == pg.ErrNoRows { + impl.Logger.Warnw("no installed apps found", "clusterId", clusterId) + return nil, nil + } else { + impl.Logger.Errorw("error while fetching installed apps", "clusterId", clusterId, "error", err) + return nil, err + } + } + + if installedApp.Id > 0 { + installedAppVersion, err := impl.InstalledAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedApp.Id, installedApp.EnvironmentId) + if err != nil { + return nil, err + } + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil + } + + return nil, nil +} + +func (impl *InstalledAppDBServiceImpl) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) { + installedAppVersion, err := impl.InstalledAppRepository.GetActiveInstalledAppVersionByInstalledAppId(installedAppId) + if err != nil { + return nil, err + } + installedApp := &installedAppVersion.InstalledApp + return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil +} diff --git a/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go new file mode 100644 index 0000000000..34d7310b20 --- /dev/null +++ b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package FullMode + +import ( + "encoding/json" + pubsub "github.com/devtron-labs/common-lib/pubsub-lib" + "github.com/devtron-labs/common-lib/pubsub-lib/model" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "time" + + "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + application2 "github.com/devtron-labs/devtron/client/argocdServer/application" + "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/pkg/appStatus" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/auth/user" + "go.uber.org/zap" +) + +type InstalledAppDBExtendedService interface { + EAMode.InstalledAppDBService + UpdateInstalledAppVersionStatus(application *v1alpha1.Application) (bool, error) +} + +type InstalledAppDBExtendedServiceImpl struct { + *EAMode.InstalledAppDBServiceImpl + appStatusService appStatus.AppStatusService + pubSubClient *pubsub.PubSubClientServiceImpl +} + +func NewInstalledAppDBExtendedServiceImpl(logger *zap.SugaredLogger, + installedAppRepository repository2.InstalledAppRepository, + appRepository app.AppRepository, + userService user.UserService, + installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository, + appStatusService appStatus.AppStatusService, + pubSubClient *pubsub.PubSubClientServiceImpl) (*InstalledAppDBExtendedServiceImpl, error) { + impl := &InstalledAppDBExtendedServiceImpl{ + InstalledAppDBServiceImpl: &EAMode.InstalledAppDBServiceImpl{ + Logger: logger, + InstalledAppRepository: installedAppRepository, + AppRepository: appRepository, + UserService: userService, + InstalledAppRepositoryHistory: installedAppRepositoryHistory, + }, + appStatusService: appStatusService, + pubSubClient: pubSubClient, + } + err := impl.subscribeHelmInstallStatus() + if err != nil { + return nil, err + } + return impl, nil +} + +func (impl *InstalledAppDBExtendedServiceImpl) subscribeHelmInstallStatus() error { + + callback := func(msg *model.PubSubMsg) { + + helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} + err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) + if err != nil { + impl.Logger.Errorw("error in unmarshalling helm install status nats message", "err", err) + return + } + + installedAppVersionHistory, err := impl.InstalledAppRepositoryHistory.GetInstalledAppVersionHistory(helmInstallNatsMessage.InstallAppVersionHistoryId) + if err != nil { + impl.Logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) + return + } + if helmInstallNatsMessage.ErrorInInstallation { + installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed + } else { + installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded + } + installedAppVersionHistory.HelmReleaseStatusConfig = msg.Data + _, err = impl.InstalledAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) + if err != nil { + impl.Logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) + return + } + } + // add required logging here + var loggerFunc pubsub.LoggerFunc = func(msg model.PubSubMsg) (string, []interface{}) { + helmInstallNatsMessage := &appStoreBean.HelmReleaseStatusConfig{} + err := json.Unmarshal([]byte(msg.Data), helmInstallNatsMessage) + if err != nil { + return "error in unmarshalling helm install status nats message", []interface{}{"err", err} + } + return "got nats msg for helm chart install status", []interface{}{"InstallAppVersionHistoryId", helmInstallNatsMessage.InstallAppVersionHistoryId, "ErrorInInstallation", helmInstallNatsMessage.ErrorInInstallation, "IsReleaseInstalled", helmInstallNatsMessage.IsReleaseInstalled} + } + + err := impl.pubSubClient.Subscribe(pubsub.HELM_CHART_INSTALL_STATUS_TOPIC, callback, loggerFunc) + if err != nil { + impl.Logger.Error(err) + return err + } + return nil +} + +func (impl *InstalledAppDBExtendedServiceImpl) UpdateInstalledAppVersionStatus(application *v1alpha1.Application) (bool, error) { + isHealthy := false + dbConnection := impl.InstalledAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return isHealthy, err + } + // Rollback tx on error. + defer tx.Rollback() + gitHash := "" + if application.Operation != nil && application.Operation.Sync != nil { + gitHash = application.Operation.Sync.Revision + } else if application.Status.OperationState != nil && application.Status.OperationState.Operation.Sync != nil { + gitHash = application.Status.OperationState.Operation.Sync.Revision + } + versionHistory, err := impl.InstalledAppRepositoryHistory.GetLatestInstalledAppVersionHistoryByGitHash(gitHash) + if err != nil { + impl.Logger.Errorw("error while fetching installed version history", "error", err) + return isHealthy, err + } + if versionHistory.Status != (application2.Healthy) { + versionHistory.Status = string(application.Status.Health.Status) + versionHistory.UpdatedOn = time.Now() + versionHistory.UpdatedBy = 1 + impl.InstalledAppRepositoryHistory.UpdateInstalledAppVersionHistory(versionHistory, tx) + } + err = tx.Commit() + if err != nil { + impl.Logger.Errorw("error while committing transaction to db", "error", err) + return isHealthy, err + } + + appId, envId, err := impl.InstalledAppRepositoryHistory.GetAppIdAndEnvIdWithInstalledAppVersionId(versionHistory.InstalledAppVersionId) + if err == nil { + err = impl.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, string(application.Status.Health.Status)) + if err != nil { + impl.Logger.Errorw("error while updating app status in app_status table", "error", err, "appId", appId, "envId", envId) + } + } + return true, nil +} diff --git a/pkg/appStore/deployment/tool/DeploymentStatusService.go b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go similarity index 75% rename from pkg/appStore/deployment/tool/DeploymentStatusService.go rename to pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go index fe2de9c816..1b48cd3cad 100644 --- a/pkg/appStore/deployment/tool/DeploymentStatusService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go @@ -1,15 +1,49 @@ -package appStoreDeploymentTool +package deployment import ( "fmt" "github.com/devtron-labs/common-lib/utils/k8s/health" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/sql" + "github.com/go-pg/pg" "time" ) -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { +type DeploymentStatusService interface { + // TODO refactoring: Move to DB service + SaveTimelineForHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error + // UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus updates failed status in pipelineConfig.PipelineStatusTimeline table + UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error +} + +func (impl *FullModeDeploymentServiceImpl) SaveTimelineForHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error { + + if !util.IsAcdApp(installAppVersionRequest.DeploymentAppType) && !util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { + return nil + } + + timeline := &pipelineConfig.PipelineStatusTimeline{ + InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, + Status: status, + StatusDetail: statusDetail, + StatusTime: statusTime, + AuditLog: sql.AuditLog{ + CreatedBy: installAppVersionRequest.UserId, + CreatedOn: time.Now(), + UpdatedBy: installAppVersionRequest.UserId, + UpdatedOn: time.Now(), + }, + } + timelineErr := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) + if timelineErr != nil { + impl.Logger.Errorw("error in creating timeline status for git commit", "err", timelineErr, "timeline", timeline) + } + return timelineErr +} + +func (impl *FullModeDeploymentServiceImpl) UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { if err != nil { terminalStatusExists, timelineErr := impl.pipelineStatusTimelineRepository.CheckIfTerminalStatusTimelinePresentByInstalledAppVersionHistoryId(installAppVersionRequest.InstalledAppVersionHistoryId) if timelineErr != nil { diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go similarity index 64% rename from pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go rename to pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go index ca1525a7a9..b31cdffcdc 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentArgoCdService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go @@ -1,4 +1,4 @@ -package appStoreDeploymentTool +package deployment import ( "context" @@ -7,18 +7,15 @@ import ( "fmt" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" util2 "github.com/devtron-labs/devtron/pkg/util" "net/http" - "strings" "time" - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" @@ -29,9 +26,8 @@ import ( "github.com/devtron-labs/devtron/pkg/appStatus" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository2 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/util/argo" @@ -42,9 +38,9 @@ import ( "k8s.io/utils/pointer" ) -// creating duplicates because cannot use - -type AppStoreDeploymentArgoCdService interface { +// FullModeDeploymentService TODO refactoring: Use extended binding over EAMode.EAModeDeploymentService +// Currently creating duplicate methods in EAMode.EAModeDeploymentService +type FullModeDeploymentService interface { // ArgoCd Services --------------------------------- // InstallApp will register git repo in Argo, create and sync the Argo App and finally update deployment status @@ -57,31 +53,13 @@ type AppStoreDeploymentArgoCdService interface { GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) // GetDeploymentHistoryInfo will return openapi.HelmAppDeploymentManifestDetail for the given appStoreBean.InstallAppVersionDTO GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - // GetAcdAppGitOpsRepoName will return the Git Repo used in the ACD app object - GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) - // DeleteDeploymentApp will delete the app object from ACD - DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error - SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error - UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error - - // Deployment Status Services ---------------------- - - // UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus updates failed status in pipelineConfig.PipelineStatusTimeline table - UpdateInstalledAppAndPipelineStatusForFailedDeploymentStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error - - // Git Operation Services -------------------------- - - // ParseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) - ParseGitRepoErrorResponse(err error) (bool, error) - // GitOpsOperations performs git operations specific to helm app deployments - GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) - // GenerateManifest returns bean.AppStoreManifestResponse required in GitOps - GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) - // GenerateManifestAndPerformGitOperations is a wrapper function for both GenerateManifest and GitOpsOperations - GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) + + InstalledAppArgoCdService + DeploymentStatusService + InstalledAppGitOpsService } -type AppStoreDeploymentArgoCdServiceImpl struct { +type FullModeDeploymentServiceImpl struct { Logger *zap.SugaredLogger acdClient application2.ServiceClient argoK8sClient argocdServer.ArgoK8sClient @@ -104,7 +82,7 @@ type AppStoreDeploymentArgoCdServiceImpl struct { environmentRepository repository5.EnvironmentRepository } -func NewAppStoreDeploymentArgoCdServiceImpl( +func NewFullModeDeploymentServiceImpl( logger *zap.SugaredLogger, acdClient application2.ServiceClient, argoK8sClient argocdServer.ArgoK8sClient, @@ -124,8 +102,8 @@ func NewAppStoreDeploymentArgoCdServiceImpl( acdConfig *argocdServer.ACDConfig, gitOperationService git.GitOperationService, gitOpsConfigReadService config.GitOpsConfigReadService, - environmentRepository repository5.EnvironmentRepository) *AppStoreDeploymentArgoCdServiceImpl { - return &AppStoreDeploymentArgoCdServiceImpl{ + environmentRepository repository5.EnvironmentRepository) *FullModeDeploymentServiceImpl { + return &FullModeDeploymentServiceImpl{ Logger: logger, acdClient: acdClient, argoK8sClient: argoK8sClient, @@ -149,79 +127,7 @@ func NewAppStoreDeploymentArgoCdServiceImpl( } } -// UpdateAndSyncACDApps this will update chart info in acd app if required in case of mono repo migration and will refresh argo app -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { - if isMonoRepoMigrationRequired { - // update repo details on ArgoCD as repo is changed - err := impl.UpdateChartInfo(installAppVersionRequest, ChartGitAttribute, 0, ctx) - if err != nil { - impl.Logger.Errorw("error in acd patch request", "err", err) - return err - } - } - acdAppName := installAppVersionRequest.ACDAppName - argoApplication, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) - if err != nil { - impl.Logger.Errorw("Service err:UpdateAndSyncACDApps - error in acd app by name", "acdAppName", acdAppName, "err", err) - return err - } - - err = impl.argoClientWrapperService.UpdateArgoCDSyncModeIfNeeded(ctx, argoApplication) - if err != nil { - impl.Logger.Errorw("error in updating argocd sync mode", "err", err) - return err - } - syncTime := time.Now() - err = impl.argoClientWrapperService.SyncArgoCDApplicationIfNeededAndRefresh(ctx, acdAppName) - if err != nil { - impl.Logger.Errorw("error in getting argocd application with normal refresh", "err", err, "argoAppName", installAppVersionRequest.ACDAppName) - return err - } - if !impl.acdConfig.ArgoCDAutoSyncEnabled { - err = impl.SaveTimelineForACDHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_COMPLETED, "argocd sync completed", syncTime, tx) - if err != nil { - impl.Logger.Errorw("error in saving timeline for acd helm apps", "err", err) - return err - } - } - return nil -} - -// UpdateChartInfo this will update chart info in acd app, needed when repo for an app is changed -func (impl AppStoreDeploymentArgoCdServiceImpl) UpdateChartInfo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { - installAppVersionRequest, err := impl.patchAcdApp(ctx, installAppVersionRequest, ChartGitAttribute) - if err != nil { - return err - } - return nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) SaveTimelineForACDHelmApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string, statusDetail string, statusTime time.Time, tx *pg.Tx) error { - - if !util.IsAcdApp(installAppVersionRequest.DeploymentAppType) && !util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { - return nil - } - - timeline := &pipelineConfig.PipelineStatusTimeline{ - InstalledAppVersionHistoryId: installAppVersionRequest.InstalledAppVersionHistoryId, - Status: status, - StatusDetail: statusDetail, - StatusTime: statusTime, - AuditLog: sql.AuditLog{ - CreatedBy: installAppVersionRequest.UserId, - CreatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - }, - } - timelineErr := impl.pipelineStatusTimelineService.SaveTimeline(timeline, tx, true) - if timelineErr != nil { - impl.Logger.Errorw("error in creating timeline status for git commit", "err", timelineErr, "timeline", timeline) - } - return timelineErr -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *FullModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) defer cancel() //STEP 4: registerInArgo @@ -268,7 +174,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) InstallApp(installAppVersionRequ return installAppVersionRequest, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { +func (impl *FullModeDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error { err := impl.appStatusService.DeleteWithAppIdEnvId(dbTransaction, installedApps.AppId, installedApps.EnvironmentId) if err != nil && err != pg.ErrNoRows { @@ -297,7 +203,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteInstalledApp(ctx context.C return nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistoryId int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) { +func (impl *FullModeDeploymentServiceImpl) RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistoryId int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) { //request version id for versionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(int(installedAppVersionHistoryId)) if err != nil { @@ -429,7 +335,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) RollbackRelease(ctx context.Cont return installedApp, true, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { +func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { result := &gRPC.HelmAppDeploymentHistory{} var history []*gRPC.HelmAppDeploymentDetail //TODO - response setup @@ -492,7 +398,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistory(ctx context } // TODO refactoring: use InstalledAppVersionHistoryId from appStoreBean.InstallAppVersionDTO instead of version int32 -func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) { +func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) { values := &openapi.HelmAppDeploymentManifestDetail{} _, span := otel.Tracer("orchestrator").Start(ctx, "installedAppRepositoryHistory.GetInstalledAppVersionHistory") versionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(int(version)) @@ -531,73 +437,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GetDeploymentHistoryInfo(ctx con return values, err } -func (impl AppStoreDeploymentArgoCdServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { - gitOpsRepoName := "" - //this method should only call in case of argo-integration and gitops configured - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.Logger.Errorw("error in getting acd token", "err", err) - return "", err - } - ctx := context.Background() - ctx = context.WithValue(ctx, "token", acdToken) - acdAppName := fmt.Sprintf("%s-%s", appName, environmentName) - acdApplication, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) - if err != nil { - impl.Logger.Errorw("no argo app exists", "acdAppName", acdAppName, "err", err) - return "", err - } - if acdApplication != nil { - gitOpsRepoUrl := acdApplication.Spec.Source.RepoURL - gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) - } - return gitOpsRepoName, nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) DeleteDeploymentApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { - acdAppName := appName + "-" + environmentName - var err error - err = impl.deleteACD(acdAppName, ctx, installAppVersionRequest.NonCascadeDelete) - if err != nil { - impl.Logger.Errorw("error in deleting ACD ", "name", acdAppName, "err", err) - if installAppVersionRequest.ForceDelete { - impl.Logger.Warnw("error while deletion of app in acd, continue to delete in db as this operation is force delete", "error", err) - } else { - //statusError, _ := err.(*errors2.StatusError) - if !installAppVersionRequest.NonCascadeDelete && strings.Contains(err.Error(), "code = NotFound") { - err = &util.ApiError{ - UserMessage: "Could not delete as application not found in argocd", - InternalMessage: err.Error(), - } - } else { - err = &util.ApiError{ - UserMessage: "Could not delete application", - InternalMessage: err.Error(), - } - } - return err - } - } - return nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) deleteACD(acdAppName string, ctx context.Context, isNonCascade bool) error { - req := new(application.ApplicationDeleteRequest) - req.Name = &acdAppName - cascadeDelete := !isNonCascade - req.Cascade = &cascadeDelete - if ctx == nil { - impl.Logger.Errorw("err in delete ACD for AppStore, ctx is NULL", "acdAppName", acdAppName) - return fmt.Errorf("context is null") - } - if _, err := impl.acdClient.Delete(ctx, req); err != nil { - impl.Logger.Errorw("err in delete ACD for AppStore", "acdAppName", acdAppName, "err", err) - return err - } - return nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) getSourcesFromManifest(chartYaml string) ([]string, error) { +func (impl *FullModeDeploymentServiceImpl) getSourcesFromManifest(chartYaml string) ([]string, error) { var b map[string]interface{} var sources []string err := json.Unmarshal([]byte(chartYaml), &b) @@ -613,54 +453,3 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) getSourcesFromManifest(chartYaml } return sources, nil } - -func (impl AppStoreDeploymentArgoCdServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, envModel repository5.Environment, argocdAppName string) error { - appNamespace := envModel.Namespace - if appNamespace == "" { - appNamespace = "default" - } - appreq := &argocdServer.AppTemplate{ - ApplicationName: argocdAppName, - Namespace: impl.aCDAuthConfig.ACDConfigMapNamespace, - TargetNamespace: appNamespace, - TargetServer: envModel.Cluster.ServerUrl, - Project: "default", - ValuesFile: fmt.Sprintf("values.yaml"), - RepoPath: chartGitAttribute.ChartLocation, - RepoUrl: chartGitAttribute.RepoUrl, - AutoSyncEnabled: impl.acdConfig.ArgoCDAutoSyncEnabled, - } - _, err := impl.argoK8sClient.CreateAcdApp(appreq, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) - //create - if err != nil { - impl.Logger.Errorw("error in creating argo cd app ", "err", err) - return err - } - return nil -} - -func (impl AppStoreDeploymentArgoCdServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute) (*appStoreBean.InstallAppVersionDTO, error) { - ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) - defer cancel() - //registerInArgo - err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) - if err != nil { - impl.Logger.Errorw("error in argo registry", "err", err) - return nil, err - } - // update acd app - patchReq := v1alpha1.Application{Spec: v1alpha1.ApplicationSpec{Source: &v1alpha1.ApplicationSource{Path: chartGitAttr.ChartLocation, RepoURL: chartGitAttr.RepoUrl, TargetRevision: "master"}}} - reqbyte, err := json.Marshal(patchReq) - if err != nil { - impl.Logger.Errorw("error in creating patch", "err", err) - } - reqString := string(reqbyte) - patchType := "merge" - _, err = impl.acdClient.Patch(ctx, &application.ApplicationPatchRequest{Patch: &reqString, Name: &installAppVersionRequest.ACDAppName, PatchType: &patchType}) - if err != nil { - impl.Logger.Errorw("error in creating argo app ", "name", installAppVersionRequest.ACDAppName, "patch", string(reqbyte), "err", err) - return nil, err - } - //impl.appStoreDeploymentFullModeService.SyncACD(installAppVersionRequest.ACDAppName, ctx) - return installAppVersionRequest, nil -} diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go new file mode 100644 index 0000000000..02b098b425 --- /dev/null +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go @@ -0,0 +1,208 @@ +package deployment + +import ( + "context" + "encoding/json" + "fmt" + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + "github.com/devtron-labs/devtron/client/argocdServer" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" + "github.com/go-pg/pg" + "strings" + "time" +) + +type InstalledAppArgoCdService interface { + // GetAcdAppGitOpsRepoName will return the Git Repo used in the ACD app object + GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) + // DeleteACDAppObject will delete the app object from ACD + DeleteACDAppObject(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error + // CheckIfArgoAppExists will return- isFound: if Argo app object exists; err: if any err found + CheckIfArgoAppExists(acdAppName string) (isFound bool, err error) + // UpdateAndSyncACDApps this will update chart info in acd app if required in case of mono repo migration and will refresh argo app + UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error +} + +func (impl *FullModeDeploymentServiceImpl) GetAcdAppGitOpsRepoName(appName string, environmentName string) (string, error) { + gitOpsRepoName := "" + //this method should only call in case of argo-integration and gitops configured + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.Logger.Errorw("error in getting acd token", "err", err) + return "", err + } + ctx := context.Background() + ctx = context.WithValue(ctx, "token", acdToken) + acdAppName := fmt.Sprintf("%s-%s", appName, environmentName) + acdApplication, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) + if err != nil { + impl.Logger.Errorw("no argo app exists", "acdAppName", acdAppName, "err", err) + return "", err + } + if acdApplication != nil { + gitOpsRepoUrl := acdApplication.Spec.Source.RepoURL + gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoNameFromUrl(gitOpsRepoUrl) + } + return gitOpsRepoName, nil +} + +func (impl *FullModeDeploymentServiceImpl) DeleteACDAppObject(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { + acdAppName := appName + "-" + environmentName + var err error + err = impl.deleteACD(acdAppName, ctx, installAppVersionRequest.NonCascadeDelete) + if err != nil { + impl.Logger.Errorw("error in deleting ACD ", "name", acdAppName, "err", err) + if installAppVersionRequest.ForceDelete { + impl.Logger.Warnw("error while deletion of app in acd, continue to delete in db as this operation is force delete", "error", err) + } else { + //statusError, _ := err.(*errors2.StatusError) + if !installAppVersionRequest.NonCascadeDelete && strings.Contains(err.Error(), "code = NotFound") { + err = &util.ApiError{ + UserMessage: "Could not delete as application not found in argocd", + InternalMessage: err.Error(), + } + } else { + err = &util.ApiError{ + UserMessage: "Could not delete application", + InternalMessage: err.Error(), + } + } + return err + } + } + return nil +} + +func (impl *FullModeDeploymentServiceImpl) CheckIfArgoAppExists(acdAppName string) (isFound bool, err error) { + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.Logger.Errorw("error in getting acd token", "err", err) + return isFound, fmt.Errorf("error in getting acd token") + } + + ctx := context.Background() + ctx = context.WithValue(ctx, "token", acdToken) + + _, acdAppGetErr := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) + isFound = acdAppGetErr == nil + return isFound, nil +} + +func (impl *FullModeDeploymentServiceImpl) UpdateAndSyncACDApps(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, isMonoRepoMigrationRequired bool, ctx context.Context, tx *pg.Tx) error { + if isMonoRepoMigrationRequired { + // update repo details on ArgoCD as repo is changed + err := impl.UpgradeDeployment(installAppVersionRequest, ChartGitAttribute, 0, ctx) + if err != nil { + return err + } + } + acdAppName := installAppVersionRequest.ACDAppName + argoApplication, err := impl.acdClient.Get(ctx, &application.ApplicationQuery{Name: &acdAppName}) + if err != nil { + impl.Logger.Errorw("Service err:UpdateAndSyncACDApps - error in acd app by name", "acdAppName", acdAppName, "err", err) + return err + } + + err = impl.argoClientWrapperService.UpdateArgoCDSyncModeIfNeeded(ctx, argoApplication) + if err != nil { + impl.Logger.Errorw("error in updating argocd sync mode", "err", err) + return err + } + syncTime := time.Now() + err = impl.argoClientWrapperService.SyncArgoCDApplicationIfNeededAndRefresh(ctx, acdAppName) + if err != nil { + impl.Logger.Errorw("error in getting argocd application with normal refresh", "err", err, "argoAppName", installAppVersionRequest.ACDAppName) + return err + } + if !impl.acdConfig.ArgoCDAutoSyncEnabled { + err = impl.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_COMPLETED, "argocd sync completed", syncTime, tx) + if err != nil { + impl.Logger.Errorw("error in saving timeline for acd helm apps", "err", err) + return err + } + } + return nil +} + +// UpgradeDeployment this will update chart info in acd app, needed when repo for an app is changed +func (impl *FullModeDeploymentServiceImpl) UpgradeDeployment(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error { + if !util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { + return nil + } + err := impl.patchAcdApp(ctx, installAppVersionRequest, ChartGitAttribute) + if err != nil { + impl.Logger.Errorw("error in acd patch request", "err", err) + } + return err +} + +func (impl *FullModeDeploymentServiceImpl) deleteACD(acdAppName string, ctx context.Context, isNonCascade bool) error { + req := new(application.ApplicationDeleteRequest) + req.Name = &acdAppName + cascadeDelete := !isNonCascade + req.Cascade = &cascadeDelete + if ctx == nil { + impl.Logger.Errorw("err in delete ACD for AppStore, ctx is NULL", "acdAppName", acdAppName) + return fmt.Errorf("context is null") + } + if _, err := impl.acdClient.Delete(ctx, req); err != nil { + impl.Logger.Errorw("err in delete ACD for AppStore", "acdAppName", acdAppName, "err", err) + return err + } + return nil +} + +func (impl *FullModeDeploymentServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, envModel repository5.Environment, argocdAppName string) error { + appNamespace := envModel.Namespace + if appNamespace == "" { + appNamespace = "default" + } + appreq := &argocdServer.AppTemplate{ + ApplicationName: argocdAppName, + Namespace: impl.aCDAuthConfig.ACDConfigMapNamespace, + TargetNamespace: appNamespace, + TargetServer: envModel.Cluster.ServerUrl, + Project: "default", + ValuesFile: fmt.Sprintf("values.yaml"), + RepoPath: chartGitAttribute.ChartLocation, + RepoUrl: chartGitAttribute.RepoUrl, + AutoSyncEnabled: impl.acdConfig.ArgoCDAutoSyncEnabled, + } + _, err := impl.argoK8sClient.CreateAcdApp(appreq, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) + //create + if err != nil { + impl.Logger.Errorw("error in creating argo cd app ", "err", err) + return err + } + return nil +} + +func (impl *FullModeDeploymentServiceImpl) patchAcdApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute) error { + ctx, cancel := context.WithTimeout(ctx, 1*time.Minute) + defer cancel() + //registerInArgo + err := impl.argoClientWrapperService.RegisterGitOpsRepoInArgo(ctx, chartGitAttr.RepoUrl) + if err != nil { + impl.Logger.Errorw("error in argo registry", "err", err) + return err + } + // update acd app + patchReq := v1alpha1.Application{Spec: v1alpha1.ApplicationSpec{Source: &v1alpha1.ApplicationSource{Path: chartGitAttr.ChartLocation, RepoURL: chartGitAttr.RepoUrl, TargetRevision: "master"}}} + reqbyte, err := json.Marshal(patchReq) + if err != nil { + impl.Logger.Errorw("error in creating patch", "err", err) + } + reqString := string(reqbyte) + patchType := "merge" + _, err = impl.acdClient.Patch(ctx, &application.ApplicationPatchRequest{Patch: &reqString, Name: &installAppVersionRequest.ACDAppName, PatchType: &patchType}) + if err != nil { + impl.Logger.Errorw("error in creating argo app ", "name", installAppVersionRequest.ACDAppName, "patch", string(reqbyte), "err", err) + return err + } + return nil +} diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go similarity index 76% rename from pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go rename to pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go index 70f90401c9..80111b4f6d 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go @@ -1,4 +1,4 @@ -package appStoreDeploymentTool +package deployment import ( "errors" @@ -7,9 +7,9 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/adapter" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/adapter" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/google/go-github/github" @@ -18,9 +18,27 @@ import ( "net/http" "path" "regexp" + "time" ) -func (impl AppStoreDeploymentArgoCdServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { +type InstalledAppGitOpsService interface { + // CommitValues will commit git.ChartConfig and returns commitHash + CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) + // ParseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) + ParseGitRepoErrorResponse(err error) (bool, error) + // GitOpsOperations performs git operations specific to helm app deployments + GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) + // GenerateManifest returns bean.AppStoreManifestResponse required in GitOps + GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) + // GenerateManifestAndPerformGitOperations is a wrapper function for both GenerateManifest and GitOpsOperations + GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) +} + +func (impl *FullModeDeploymentServiceImpl) CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) { + return impl.gitOperationService.CommitValues(chartGitAttr) +} + +func (impl *FullModeDeploymentServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { //update values yaml in chart noTargetFound := false if err != nil { @@ -48,7 +66,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) ParseGitRepoErrorResponse(err er return noTargetFound, err } -func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { +func (impl *FullModeDeploymentServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} manifest, err := impl.GenerateManifest(installAppVersionRequest) if err != nil { @@ -66,7 +84,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifestAndPerformGitOpe } // GitOpsOperations handles all git operations for Helm App -func (impl AppStoreDeploymentArgoCdServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { +func (impl *FullModeDeploymentServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} chartGitAttribute, isNew, githash, err := impl.createGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) if err != nil { @@ -90,7 +108,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GitOpsOperations(manifestRespons return appStoreGitOpsResponse, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { +func (impl *FullModeDeploymentServiceImpl) GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) { manifestResponse = &bean.AppStoreManifestResponse{} @@ -113,7 +131,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) GenerateManifest(installAppVersi } // createGitOpsRepoAndPushChart is a wrapper for creating GitOps repo and pushing chart to created repo -func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { +func (impl *FullModeDeploymentServiceImpl) createGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { repoURL, isNew, err := impl.createGitOpsRepo(installAppVersionRequest) if err != nil { impl.Logger.Errorw("Error in creating gitops repo for ", "appName", installAppVersionRequest.AppName, "err", err) @@ -129,7 +147,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepoAndPushChart(ins } // createGitOpsRepo creates a gitOps repo with readme -func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { +func (impl *FullModeDeploymentServiceImpl) createGitOpsRepo(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, bool, error) { if len(installAppVersionRequest.GitOpsRepoName) == 0 { //here gitops repo will be the app name, to breaking the mono repo structure gitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) @@ -155,7 +173,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) createGitOpsRepo(installAppVersi return repoUrl, isNew, err } -func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { +func (impl *FullModeDeploymentServiceImpl) updateValuesYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { valuesString, err := impl.appStoreDeploymentCommonService.GetValuesString(installAppVersionRequest.AppStoreName, installAppVersionRequest.ValuesOverrideYaml) if err != nil { impl.Logger.Errorw("error in getting values string", "err", err) @@ -177,7 +195,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) updateValuesYamlInGit(installApp return installAppVersionRequest, nil } -func (impl AppStoreDeploymentArgoCdServiceImpl) updateRequirementYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { +func (impl *FullModeDeploymentServiceImpl) updateRequirementYamlInGit(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, appStoreAppVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) error { requirementsString, err := impl.appStoreDeploymentCommonService.GetRequirementsString(appStoreAppVersion.Id) if err != nil { impl.Logger.Errorw("error in getting requirements string", "err", err) @@ -200,7 +218,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) updateRequirementYamlInGit(insta } // createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml -func (impl AppStoreDeploymentArgoCdServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { +func (impl *FullModeDeploymentServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { template := appStoreBean.CHART_PROXY_TEMPLATE chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest, chartPath) @@ -214,7 +232,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) createChartProxyAndGetPath(insta } // getGitCommitConfig will return util.ChartConfig (git commit config) for GitOps -func (impl AppStoreDeploymentArgoCdServiceImpl) getGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*git.ChartConfig, error) { +func (impl *FullModeDeploymentServiceImpl) getGitCommitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, fileString string, filename string) (*git.ChartConfig, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { impl.Logger.Errorw("fetching error", "err", err) @@ -243,7 +261,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) getGitCommitConfig(installAppVer } // getValuesAndRequirementForGitConfig will return chart values(*util.ChartConfig) and requirements(*util.ChartConfig) for git commit -func (impl AppStoreDeploymentArgoCdServiceImpl) getValuesAndRequirementForGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*git.ChartConfig, *git.ChartConfig, error) { +func (impl *FullModeDeploymentServiceImpl) getValuesAndRequirementForGitConfig(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*git.ChartConfig, *git.ChartConfig, error) { appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { impl.Logger.Errorw("fetching error", "err", err) diff --git a/pkg/appStore/deployment/service/Notes.go b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go similarity index 92% rename from pkg/appStore/deployment/service/Notes.go rename to pkg/appStore/installedApp/service/FullMode/resource/NotesService.go index 8252202a16..09347511e6 100644 --- a/pkg/appStore/deployment/service/Notes.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go @@ -1,4 +1,4 @@ -package service +package resource import ( "context" @@ -10,7 +10,7 @@ import ( "regexp" ) -func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { +func (impl *InstalledAppResourceServiceImpl) FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) { //check notes.txt in db installedApp, err := impl.installedAppRepository.FetchNotes(installedAppId) if err != nil && err != pg.ErrNoRows { @@ -61,7 +61,7 @@ func (impl *InstalledAppServiceImpl) FetchChartNotes(installedAppId int, envId i return installedApp.Notes, nil } -func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, envId int) (string, string, error) { +func (impl *InstalledAppResourceServiceImpl) findNotesForArgoApplication(installedAppId, envId int) (string, string, error) { installedAppVerison, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdAndEnvId(installedAppId, envId) if err != nil { impl.logger.Errorw("error fetching installed app version in installed app service", "err", err) @@ -123,7 +123,7 @@ func (impl *InstalledAppServiceImpl) findNotesForArgoApplication(installedAppId, } // updateNotesForInstalledApp will update the notes in repository.InstalledApps table -func (impl *InstalledAppServiceImpl) updateNotesForInstalledApp(installAppId int, notes string) (bool, error) { +func (impl *InstalledAppResourceServiceImpl) updateNotesForInstalledApp(installAppId int, notes string) (bool, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { diff --git a/pkg/appStore/deployment/service/ResourceTree.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go similarity index 64% rename from pkg/appStore/deployment/service/ResourceTree.go rename to pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 3d0e36b617..38359016a5 100644 --- a/pkg/appStore/deployment/service/ResourceTree.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -1,21 +1,30 @@ -package service +package resource import ( "context" "encoding/json" "fmt" "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + util4 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean" - bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client "github.com/devtron-labs/devtron/api/helm-app/service" + application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/k8s" + application3 "github.com/devtron-labs/devtron/pkg/k8s/application" + util3 "github.com/devtron-labs/devtron/pkg/util" util2 "github.com/devtron-labs/devtron/util" + "github.com/devtron-labs/devtron/util/argo" "github.com/tidwall/gjson" + "go.uber.org/zap" "net/http" "strconv" "strings" @@ -24,7 +33,55 @@ import ( "time" ) -func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error { +type InstalledAppResourceService interface { + FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer + FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error + FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) +} + +type InstalledAppResourceServiceImpl struct { + logger *zap.SugaredLogger + installedAppRepository repository.InstalledAppRepository + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository + acdClient application2.ServiceClient + aCDAuthConfig *util3.ACDAuthConfig + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository + argoUserService argo.ArgoUserService + helmAppClient gRPC.HelmAppClient + helmAppService client.HelmAppService + appStatusService appStatus.AppStatusService + K8sUtil *util4.K8sServiceImpl + k8sCommonService k8s.K8sCommonService + k8sApplicationService application3.K8sApplicationService +} + +func NewInstalledAppResourceServiceImpl(logger *zap.SugaredLogger, + installedAppRepository repository.InstalledAppRepository, + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, + acdClient application2.ServiceClient, + aCDAuthConfig *util3.ACDAuthConfig, + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, + argoUserService argo.ArgoUserService, helmAppClient gRPC.HelmAppClient, helmAppService client.HelmAppService, + appStatusService appStatus.AppStatusService, K8sUtil *util4.K8sServiceImpl, + k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService) *InstalledAppResourceServiceImpl { + return &InstalledAppResourceServiceImpl{ + logger: logger, + installedAppRepository: installedAppRepository, + appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, + acdClient: acdClient, + aCDAuthConfig: aCDAuthConfig, + installedAppRepositoryHistory: installedAppRepositoryHistory, + argoUserService: argoUserService, + helmAppClient: helmAppClient, + helmAppService: helmAppService, + appStatusService: appStatusService, + K8sUtil: K8sUtil, + k8sCommonService: k8sCommonService, + k8sApplicationService: k8sApplicationService, + } +} + +func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, helmReleaseInstallStatus string, status string) error { var err error var resourceTree map[string]interface{} deploymentAppName := fmt.Sprintf("%s-%s", installedApp.App.AppName, installedApp.Environment.Name) @@ -35,7 +92,7 @@ func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn h if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) } - req := &bean2.AppDetailRequest{ + req := &gRPC.AppDetailRequest{ ClusterConfig: config, Namespace: installedApp.Environment.Namespace, ReleaseName: installedApp.App.AppName, @@ -101,7 +158,38 @@ func (impl InstalledAppServiceImpl) FetchResourceTree(rctx context.Context, cn h return err } -func (impl InstalledAppServiceImpl) fetchResourceTreeForACD(rctx context.Context, cn http.CloseNotifier, appId int, envId, clusterId int, deploymentAppName, namespace string) (map[string]interface{}, error) { +func (impl *InstalledAppResourceServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer { + ctx, cancel := context.WithCancel(rctx) + if cn != nil { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() + if err != nil { + impl.logger.Errorw("error in getting acd token", "err", err) + return *appDetail + } + ctx = context.WithValue(ctx, "token", acdToken) + defer cancel() + deploymentAppName := fmt.Sprintf("%s-%s", appDetail.AppName, appDetail.EnvironmentName) + resourceTree, err := impl.fetchResourceTreeForACD(rctx, cn, appDetail.InstalledAppId, appDetail.EnvironmentId, appDetail.ClusterId, deploymentAppName, appDetail.Namespace) + appDetail.ResourceTree = resourceTree + if err != nil { + return *appDetail + } + if appDetail.ResourceTree["nodes"] == nil { + return *appDetail + } + appDetail.ResourceTree, _ = impl.checkHibernate(appDetail.ResourceTree, deploymentAppName, ctx) + return *appDetail +} + +func (impl *InstalledAppResourceServiceImpl) fetchResourceTreeForACD(rctx context.Context, cn http.CloseNotifier, appId int, envId, clusterId int, deploymentAppName, namespace string) (map[string]interface{}, error) { var resourceTree map[string]interface{} query := &application.ResourcesQuery{ ApplicationName: &deploymentAppName, @@ -181,38 +269,7 @@ func (impl InstalledAppServiceImpl) fetchResourceTreeForACD(rctx context.Context return newResourceTree, err } -func (impl InstalledAppServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer { - ctx, cancel := context.WithCancel(rctx) - if cn != nil { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - return *appDetail - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - deploymentAppName := fmt.Sprintf("%s-%s", appDetail.AppName, appDetail.EnvironmentName) - resourceTree, err := impl.fetchResourceTreeForACD(rctx, cn, appDetail.InstalledAppId, appDetail.EnvironmentId, appDetail.ClusterId, deploymentAppName, appDetail.Namespace) - appDetail.ResourceTree = resourceTree - if err != nil { - return *appDetail - } - if appDetail.ResourceTree["nodes"] == nil { - return *appDetail - } - appDetail.ResourceTree, _ = impl.checkHibernate(appDetail.ResourceTree, deploymentAppName, ctx) - return *appDetail -} - -func (impl InstalledAppServiceImpl) checkHibernate(resp map[string]interface{}, deploymentAppName string, ctx context.Context) (map[string]interface{}, string) { +func (impl *InstalledAppResourceServiceImpl) checkHibernate(resp map[string]interface{}, deploymentAppName string, ctx context.Context) (map[string]interface{}, string) { if resp == nil { return resp, "" @@ -263,7 +320,7 @@ func (impl InstalledAppServiceImpl) checkHibernate(resp map[string]interface{}, return responseTree, status } -func (impl InstalledAppServiceImpl) processReplicaNodeForHibernation(node interface{}, deploymentAppName string, ctx context.Context) (bool, bool) { +func (impl *InstalledAppResourceServiceImpl) processReplicaNodeForHibernation(node interface{}, deploymentAppName string, ctx context.Context) (bool, bool) { currNode := node.(interface{}).(map[string]interface{}) resName := util2.InterfaceToString(currNode["name"]) resKind := util2.InterfaceToString(currNode["kind"]) @@ -287,7 +344,7 @@ func (impl InstalledAppServiceImpl) processReplicaNodeForHibernation(node interf return canBeHibernatedFlag, alreadyHibernated } -func (impl InstalledAppServiceImpl) checkForHibernation(ctx context.Context, rQuery *application.ApplicationResourceRequest, currNode map[string]interface{}) (bool, bool) { +func (impl *InstalledAppResourceServiceImpl) checkForHibernation(ctx context.Context, rQuery *application.ApplicationResourceRequest, currNode map[string]interface{}) (bool, bool) { t0 := time.Now() canBeHibernated := false alreadyHibernated := false @@ -318,7 +375,7 @@ func (impl InstalledAppServiceImpl) checkForHibernation(ctx context.Context, rQu return canBeHibernated, alreadyHibernated } -func (impl InstalledAppServiceImpl) filterOutReplicaNodes(responseTreeNodes interface{}) []interface{} { +func (impl *InstalledAppResourceServiceImpl) filterOutReplicaNodes(responseTreeNodes interface{}) []interface{} { resourceListForReplicas := impl.aCDAuthConfig.ResourceListForReplicas entries := strings.Split(resourceListForReplicas, ",") resourceListMap := util2.ConvertStringSliceToMap(entries) @@ -332,3 +389,35 @@ func (impl InstalledAppServiceImpl) filterOutReplicaNodes(responseTreeNodes inte } return replicaNodes } + +func (impl *InstalledAppResourceServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *gRPC.ReleaseStatus { + //release status is sent in resource tree call and is shown on UI as helm config apply status + releaseStatus := &gRPC.ReleaseStatus{} + if len(helmReleaseInstallStatus) > 0 { + helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} + err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) + if err != nil { + impl.logger.Errorw("error in unmarshalling helm release install status") + return releaseStatus + } + if status == appStoreBean.HELM_RELEASE_STATUS_FAILED { + releaseStatus.Status = status + releaseStatus.Description = helmInstallStatus.Message + releaseStatus.Message = "Release install/upgrade failed" + } else if status == appStoreBean.HELM_RELEASE_STATUS_PROGRESSING { + releaseStatus.Status = status + releaseStatus.Description = helmInstallStatus.Message + releaseStatus.Message = helmInstallStatus.Message + } else { + // there can be a case when helm release is created but we are not able to fetch it + releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN + releaseStatus.Description = "Unable to fetch release for app" + releaseStatus.Message = "Unable to fetch release for app" + } + } else { + releaseStatus.Status = appStoreBean.HELM_RELEASE_STATUS_UNKNOWN + releaseStatus.Description = "Release not found" + releaseStatus.Message = "Release not found " + } + return releaseStatus +} diff --git a/pkg/appStore/deployment/tool/bean/bean.go b/pkg/appStore/installedApp/service/bean/bean.go similarity index 100% rename from pkg/appStore/deployment/tool/bean/bean.go rename to pkg/appStore/installedApp/service/bean/bean.go diff --git a/pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go b/pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go similarity index 100% rename from pkg/appStore/deployment/common/AppStoreDeploymentCommonService.go rename to pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go diff --git a/pkg/appStore/values/service/AppStoreValuesService.go b/pkg/appStore/values/service/AppStoreValuesService.go index 4dcbaef4b1..94d5e51195 100644 --- a/pkg/appStore/values/service/AppStoreValuesService.go +++ b/pkg/appStore/values/service/AppStoreValuesService.go @@ -23,8 +23,8 @@ import ( "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" appStoreValuesRepository "github.com/devtron-labs/devtron/pkg/appStore/values/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "go.uber.org/zap" diff --git a/pkg/cluster/ClusterServiceExtended.go b/pkg/cluster/ClusterServiceExtended.go index 0982b9b9f4..70f356e8fc 100644 --- a/pkg/cluster/ClusterServiceExtended.go +++ b/pkg/cluster/ClusterServiceExtended.go @@ -19,7 +19,7 @@ import ( "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" "go.uber.org/zap" ) diff --git a/pkg/delete/DeleteService.go b/pkg/delete/DeleteService.go index 38b3c18fc3..9c353f73e7 100644 --- a/pkg/delete/DeleteService.go +++ b/pkg/delete/DeleteService.go @@ -3,7 +3,7 @@ package delete import ( "fmt" dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/pipeline" diff --git a/pkg/delete/DeleteServiceExtended.go b/pkg/delete/DeleteServiceExtended.go index 9485e799a3..8f6c302c56 100644 --- a/pkg/delete/DeleteServiceExtended.go +++ b/pkg/delete/DeleteServiceExtended.go @@ -6,7 +6,7 @@ import ( dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go index 7c2df27271..9fe42f9de3 100644 --- a/pkg/deployment/gitOps/wire_gitOps.go +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -17,3 +17,11 @@ var GitOpsWireSet = wire.NewSet( git.NewGitOperationServiceImpl, wire.Bind(new(git.GitOperationService), new(*git.GitOperationServiceImpl)), ) + +var GitOpsEAWireSet = wire.NewSet( + repository.NewGitOpsConfigRepositoryImpl, + wire.Bind(new(repository.GitOpsConfigRepository), new(*repository.GitOpsConfigRepositoryImpl)), + + config.NewGitOpsConfigReadServiceImpl, + wire.Bind(new(config.GitOpsConfigReadService), new(*config.GitOpsConfigReadServiceImpl)), +) diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 0e4ea796fc..5c133b9007 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -46,7 +46,7 @@ import ( "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" app_status "github.com/devtron-labs/devtron/pkg/appStatus" - repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index c62ed46d83..bb890e832a 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -187,18 +187,18 @@ type WorkflowDagExecutorImpl struct { configMapHistoryRepository repository3.ConfigMapHistoryRepository helmAppService client2.HelmAppService //TODO fix me next - helmAppClient gRPC.HelmAppClient //TODO refactoring: use helm app service instead - environmentConfigRepository chartConfig.EnvConfigOverrideRepository - mergeUtil *util.MergeUtil - acdClient application2.ServiceClient - argoClientWrapperService argocdServer.ArgoClientWrapperService - customTagService CustomTagService - ACDConfig *argocdServer.ACDConfig - deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService - chartRefService chartRef.ChartRefService - gitOpsConfigReadService config.GitOpsConfigReadService - gitOperationService git.GitOperationService - imageDigestPolicyService imageDigestPolicy.ImageDigestPolicyService + helmAppClient gRPC.HelmAppClient //TODO refactoring: use helm app service instead + environmentConfigRepository chartConfig.EnvConfigOverrideRepository + mergeUtil *util.MergeUtil + acdClient application2.ServiceClient + argoClientWrapperService argocdServer.ArgoClientWrapperService + customTagService CustomTagService + ACDConfig *argocdServer.ACDConfig + deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService + chartRefService chartRef.ChartRefService + gitOpsConfigReadService config.GitOpsConfigReadService + gitOperationService git.GitOperationService + imageDigestPolicyService imageDigestPolicy.ImageDigestPolicyService } const kedaAutoscaling = "kedaAutoscaling" @@ -2489,7 +2489,7 @@ func (impl *WorkflowDagExecutorImpl) ManualCdTrigger(triggerContext TriggerConte overrideRequest.CdWorkflowId = cdWorkflowId // creating cd pipeline status timeline for deployment initialisation timeline := impl.pipelineStatusTimelineService.GetTimelineDbObjectByTimelineStatusAndTimelineDescription(savedWfr.Id, 0, pipelineConfig.TIMELINE_STATUS_DEPLOYMENT_INITIATED, pipelineConfig.TIMELINE_DESCRIPTION_DEPLOYMENT_INITIATED, overrideRequest.UserId, time.Now()) - _, span = otel.Tracer("orchestrator").Start(ctx, "cdPipelineStatusTimelineRepo.SaveTimelineForACDHelmApps") + _, span = otel.Tracer("orchestrator").Start(ctx, "cdPipelineStatusTimelineRepo.SaveTimelineForHelmApps") err = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, false) span.End() diff --git a/util/rbac/EnforcerUtilHelm.go b/util/rbac/EnforcerUtilHelm.go index 099c14a9e1..2203f2b976 100644 --- a/util/rbac/EnforcerUtilHelm.go +++ b/util/rbac/EnforcerUtilHelm.go @@ -3,7 +3,7 @@ package rbac import ( "fmt" "github.com/devtron-labs/devtron/internal/sql/repository/app" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" + repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/team" "github.com/go-pg/pg" diff --git a/wire_gen.go b/wire_gen.go index e232c9c7ec..1b7bb8d3e5 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -26,7 +26,7 @@ import ( cluster3 "github.com/devtron-labs/devtron/api/cluster" "github.com/devtron-labs/devtron/api/connector" "github.com/devtron-labs/devtron/api/dashboardEvent" - "github.com/devtron-labs/devtron/api/deployment" + deployment2 "github.com/devtron-labs/devtron/api/deployment" externalLink2 "github.com/devtron-labs/devtron/api/externalLink" client3 "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/helm-app/gRPC" @@ -79,16 +79,19 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone/batch" appStatus2 "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" - repository15 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + repository16 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" - repository3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository" - service3 "github.com/devtron-labs/devtron/pkg/appStore/deployment/service" - "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service4 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" + repository3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" - service2 "github.com/devtron-labs/devtron/pkg/appStore/values/service" + service3 "github.com/devtron-labs/devtron/pkg/appStore/values/service" appWorkflow2 "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authentication" @@ -127,7 +130,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository16 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository15 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -536,23 +539,15 @@ func InitializeApp() (*App, error) { pipelineHistoryRestHandlerImpl := restHandler.NewPipelineHistoryRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, pipelineStrategyHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, prePostCdScriptHistoryServiceImpl, enforcerUtilImpl, deployedConfigurationHistoryServiceImpl) pipelineStatusTimelineRestHandlerImpl := restHandler.NewPipelineStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) pipelineConfigRouterImpl := router.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, appWorkflowRestHandlerImpl, webhookDataRestHandlerImpl, pipelineHistoryRestHandlerImpl, pipelineStatusTimelineRestHandlerImpl) - appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) - appStoreValuesServiceImpl := service2.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) - chartGroupDeploymentRepositoryImpl := repository15.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - acdAuthConfig, err := util3.GetACDAuthConfig() + installedAppDBExtendedServiceImpl, err := FullMode.NewInstalledAppDBExtendedServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl, appStatusServiceImpl, pubSubClientServiceImpl) if err != nil { return nil, err } - clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) - appStoreDeploymentHelmServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentHelmServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) - appStoreDeploymentArgoCdServiceImpl := appStoreDeploymentTool.NewAppStoreDeploymentArgoCdServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - serviceDeploymentServiceTypeConfig, err := service3.GetDeploymentServiceTypeConfig() + acdAuthConfig, err := util3.GetACDAuthConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service3.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, appStoreDeploymentHelmServiceImpl, appStoreDeploymentArgoCdServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) - k8sResourceHistoryRepositoryImpl := repository16.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) @@ -561,12 +556,10 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - installedAppServiceImpl, err := service3.NewInstalledAppServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, applicationServiceClientImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, chartGroupDeploymentRepositoryImpl, environmentServiceImpl, userServiceImpl, acdAuthConfig, appStoreDeploymentServiceImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, pipelineStatusTimelineServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, acdConfig, gitOperationServiceImpl, appStoreDeploymentArgoCdServiceImpl) - if err != nil { - return nil, err - } - cdApplicationStatusUpdateHandlerImpl := cron2.NewCdApplicationStatusUpdateHandlerImpl(sugaredLogger, appServiceImpl, workflowDagExecutorImpl, installedAppServiceImpl, cdHandlerImpl, appServiceConfig, pubSubClientServiceImpl, pipelineStatusTimelineRepositoryImpl, eventRESTClientImpl, appListingRepositoryImpl, cdWorkflowRepositoryImpl, pipelineRepositoryImpl, installedAppVersionHistoryRepositoryImpl, installedAppRepositoryImpl, cronLoggerImpl) - appListingRestHandlerImpl := restHandler.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, clusterServiceImplExtended, helmAppServiceImpl, argoUserServiceImpl, k8sCommonServiceImpl, installedAppServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, environmentServiceImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, deploymentTemplateServiceImpl) + installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl) + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) + cdApplicationStatusUpdateHandlerImpl := cron2.NewCdApplicationStatusUpdateHandlerImpl(sugaredLogger, appServiceImpl, workflowDagExecutorImpl, installedAppDBServiceImpl, cdHandlerImpl, appServiceConfig, pubSubClientServiceImpl, pipelineStatusTimelineRepositoryImpl, eventRESTClientImpl, appListingRepositoryImpl, cdWorkflowRepositoryImpl, pipelineRepositoryImpl, installedAppVersionHistoryRepositoryImpl, installedAppRepositoryImpl, cronLoggerImpl) + appListingRestHandlerImpl := restHandler.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, clusterServiceImplExtended, helmAppServiceImpl, argoUserServiceImpl, k8sCommonServiceImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, environmentServiceImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, deploymentTemplateServiceImpl) appListingRouterImpl := router.NewAppListingRouterImpl(appListingRestHandlerImpl) chartRepositoryServiceImpl := chartRepo.NewChartRepositoryServiceImpl(sugaredLogger, chartRepoRepositoryImpl, k8sServiceImpl, clusterServiceImplExtended, acdAuthConfig, httpClient, serverEnvConfigServerEnvConfig) deleteServiceExtendedImpl := delete2.NewDeleteServiceExtendedImpl(sugaredLogger, teamServiceImpl, clusterServiceImplExtended, environmentServiceImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, chartRepositoryServiceImpl, installedAppRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) @@ -637,7 +630,17 @@ func InitializeApp() (*App, error) { teamRouterImpl := team2.NewTeamRouterImpl(teamRestHandlerImpl) gitWebhookHandlerImpl := pubsub.NewGitWebhookHandler(sugaredLogger, pubSubClientServiceImpl, gitWebhookServiceImpl) workflowStatusUpdateHandlerImpl := pubsub.NewWorkflowStatusUpdateHandlerImpl(sugaredLogger, pubSubClientServiceImpl, ciHandlerImpl, cdHandlerImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cdWorkflowRepositoryImpl) - applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl) + chartGroupDeploymentRepositoryImpl := repository16.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) + eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) + appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) + fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) + serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() + if err != nil { + return nil, err + } + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) + applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) userRouterImpl := user2.NewUserRouterImpl(userRestHandlerImpl) @@ -645,7 +648,15 @@ func InitializeApp() (*App, error) { chartRefRouterImpl := router.NewChartRefRouterImpl(chartRefRestHandlerImpl) configMapRestHandlerImpl := restHandler.NewConfigMapRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, pipelineRepositoryImpl, enforcerUtilImpl, configMapServiceImpl) configMapRouterImpl := router.NewConfigMapRouterImpl(configMapRestHandlerImpl) - installedAppRestHandlerImpl := appStore.NewInstalledAppRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, installedAppServiceImpl, validate, clusterServiceImplExtended, applicationServiceClientImpl, appStoreDeploymentServiceImpl, helmAppClientImpl, argoUserServiceImpl, cdApplicationStatusUpdateHandlerImpl, installedAppRepositoryImpl, appCrudOperationServiceImpl) + chartGroupEntriesRepositoryImpl := repository16.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) + chartGroupReposotoryImpl := repository16.NewChartGroupReposotoryImpl(db, sugaredLogger) + appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) + appStoreValuesServiceImpl := service3.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) + chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, environmentServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl) + if err != nil { + return nil, err + } + installedAppRestHandlerImpl := appStore.NewInstalledAppRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, chartGroupServiceImpl, validate, clusterServiceImplExtended, applicationServiceClientImpl, appStoreDeploymentServiceImpl, helmAppClientImpl, argoUserServiceImpl, cdApplicationStatusUpdateHandlerImpl, installedAppRepositoryImpl, appCrudOperationServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) appStoreServiceImpl := service4.NewAppStoreServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl) @@ -679,9 +690,6 @@ func InitializeApp() (*App, error) { workflowActionImpl := batch.NewWorkflowActionImpl(sugaredLogger, appRepositoryImpl, appWorkflowServiceImpl, buildActionImpl, deploymentActionImpl) batchOperationRestHandlerImpl := restHandler.NewBatchOperationRestHandlerImpl(userServiceImpl, enforcerImpl, workflowActionImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, argoUserServiceImpl) batchOperationRouterImpl := router.NewBatchOperationRouterImpl(batchOperationRestHandlerImpl, sugaredLogger) - chartGroupEntriesRepositoryImpl := repository15.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) - chartGroupReposotoryImpl := repository15.NewChartGroupReposotoryImpl(db, sugaredLogger) - chartGroupServiceImpl := chartGroup.NewChartGroupServiceImpl(chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, sugaredLogger, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl) chartGroupRestHandlerImpl := chartGroup2.NewChartGroupRestHandlerImpl(chartGroupServiceImpl, sugaredLogger, userServiceImpl, enforcerImpl, validate) chartGroupRouterImpl := chartGroup2.NewChartGroupRouterImpl(chartGroupRestHandlerImpl) scanToolExecutionHistoryMappingRepositoryImpl := security.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) @@ -740,17 +748,17 @@ func InitializeApp() (*App, error) { appRouterImpl := router.NewAppRouterImpl(sugaredLogger, appRestHandlerImpl) coreAppRestHandlerImpl := restHandler.NewCoreAppRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, appCrudOperationServiceImpl, pipelineBuilderImpl, gitRegistryConfigImpl, chartServiceImpl, configMapServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, gitProviderRepositoryImpl, appWorkflowRepositoryImpl, environmentRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, teamServiceImpl, argoUserServiceImpl, pipelineStageServiceImpl, ciPipelineRepositoryImpl) coreAppRouterImpl := router.NewCoreAppRouterImpl(coreAppRestHandlerImpl) - helmAppRestHandlerImpl := client3.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImplExtended, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) + helmAppRestHandlerImpl := client3.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImplExtended, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client3.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sApplicationRestHandlerImpl := application3.NewK8sApplicationRestHandlerImpl(sugaredLogger, k8sApplicationServiceImpl, pumpImpl, terminalSessionHandlerImpl, enforcerImpl, enforcerUtilHelmImpl, enforcerUtilImpl, helmAppServiceImpl, userServiceImpl, k8sCommonServiceImpl, validate) k8sApplicationRouterImpl := application3.NewK8sApplicationRouterImpl(k8sApplicationRestHandlerImpl) pProfRestHandlerImpl := restHandler.NewPProfRestHandler(userServiceImpl, enforcerImpl) pProfRouterImpl := router.NewPProfRouter(sugaredLogger, pProfRestHandlerImpl) - deploymentConfigRestHandlerImpl := deployment.NewDeploymentConfigRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, chartServiceImpl, chartRefServiceImpl) - deploymentConfigRouterImpl := deployment.NewDeploymentRouterImpl(deploymentConfigRestHandlerImpl) + deploymentConfigRestHandlerImpl := deployment2.NewDeploymentConfigRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, chartServiceImpl, chartRefServiceImpl) + deploymentConfigRouterImpl := deployment2.NewDeploymentRouterImpl(deploymentConfigRestHandlerImpl) dashboardTelemetryRestHandlerImpl := dashboardEvent.NewDashboardTelemetryRestHandlerImpl(sugaredLogger, telemetryEventClientImplExtended) dashboardTelemetryRouterImpl := dashboardEvent.NewDashboardTelemetryRouterImpl(dashboardTelemetryRestHandlerImpl) - commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, argoUserServiceImpl) + commonDeploymentRestHandlerImpl := appStoreDeployment.NewCommonDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, validate, helmAppServiceImpl, helmAppRestHandlerImpl, argoUserServiceImpl) commonDeploymentRouterImpl := appStoreDeployment.NewCommonDeploymentRouterImpl(commonDeploymentRestHandlerImpl) externalLinkMonitoringToolRepositoryImpl := externalLink.NewExternalLinkMonitoringToolRepositoryImpl(db) externalLinkIdentifierMappingRepositoryImpl := externalLink.NewExternalLinkIdentifierMappingRepositoryImpl(db) From 93e635b9ab65a9b26f7f33fabd791b7f6a22e40d Mon Sep 17 00:00:00 2001 From: Asutosh Das Date: Tue, 30 Jan 2024 18:20:38 +0530 Subject: [PATCH 48/83] chore: dead code removal and app router & rest handler restructuring (#4595) (#4608) * prom code removal * removed test suites * chore: removed support for unused Prometheus and ArgoCd APIs * chore: app router and rest handler restructuring * removed redundant routings * fixed: sub path * Updated alias and added queries to AppList group router --------- Co-authored-by: nishant --- Wire.go | 104 ++- api/connector/Connector.go | 194 +---- api/restHandler/ArgoApplicationRestHandler.go | 811 ----------------- api/restHandler/CDRestHandler.go | 73 -- api/restHandler/CoreAppRestHandler.go | 3 +- api/restHandler/ExternalCiRestHandler.go | 3 +- .../PipelineStatusTimelineRestHandler.go | 84 -- .../appInfo/AppInfoRestHandler.go} | 26 +- .../app/appList/AppFilteringRestHandler.go | 207 +++++ .../appList}/AppListingRestHandler.go | 431 ++------- .../{ => pipeline}/AutoCompleteRestHandler.go | 60 +- .../configure}/BuildPipelineRestHandler.go | 2 +- .../BuildPipelineRestHandler_test.go | 2 +- .../DeploymentPipelineRestHandler.go | 2 +- .../configure}/PipelineConfigRestHandler.go | 12 +- .../history}/PipelineHistoryRestHandler.go | 2 +- .../PipelineStatusTimelineRestHandler.go | 140 +++ .../trigger}/PipelineTriggerRestHandler.go | 2 +- .../webhook}/WebhookDataRestHandler.go | 2 +- .../workflow}/AppWorkflowRestHandler.go | 2 +- api/router/AppListingRouter.go | 103 --- api/router/ApplicationRouter.go | 112 --- api/router/CDRouter.go | 65 -- api/router/JobsRouter.go | 10 +- api/router/ResourceGroupingRouter.go | 11 +- api/router/WebhookRouter.go | 6 +- api/router/app/AppRouter.go | 158 ++++ api/router/app/AppRouterEAMode.go | 47 + .../appInfo/AppInfoRouter.go} | 18 +- api/router/app/appList/AppFilteringRouter.go | 43 + api/router/app/appList/AppListingRouter.go | 54 ++ .../pipeline/DevtronAppAutoCompleteRouter.go | 46 + .../configure}/PipelineConfigRouter.go | 76 +- .../pipeline/history/PipelineHistoryRouter.go | 58 ++ .../pipeline/status/PipelineStatusRouter.go | 46 + .../trigger}/PipelineTriggerRouter.go | 12 +- api/router/app/workflow/AppWorkflowRouter.go | 56 ++ api/router/router.go | 31 +- api/util/apiHeader.go | 10 + .../argocdServer/application/Application.go | 782 +---------------- .../application/ApplicationUtil.go | 513 +++++++++++ .../application/Application_test.go | 9 +- client/argocdServer/bean/bean.go | 60 ++ client/argocdServer/repository/Repository.go | 14 +- cmd/external-app/router.go | 9 +- cmd/external-app/wire.go | 21 +- cmd/external-app/wire_gen.go | 14 +- .../sql/repository/AppListingRepository.go | 4 +- .../chartConfig/PipelineOverrideRepository.go | 5 +- .../pipelineConfig/CdWorfkflowRepository.go | 4 +- internal/util/ArgoUtil/ApplicationService.go | 68 -- internal/util/ArgoUtil/ArgoClient.go | 139 --- internal/util/ArgoUtil/ClusterService.go | 105 --- internal/util/ArgoUtil/ClusterService_test.go | 52 -- internal/util/ArgoUtil/RepositoryService.go | 45 - internal/util/ArgoUtil/ResourceService.go | 84 -- internal/util/ArgoUtil/TestUtil.go | 27 - pkg/app/AppListingService.go | 824 +----------------- pkg/app/AppService.go | 5 +- pkg/app/DeploymentEventHandler.go | 4 +- .../FullMode/InstalledAppDBExtendedService.go | 4 +- pkg/bulkAction/BulkUpdateService.go | 6 +- pkg/pipeline/AppArtifactManager.go | 10 +- pkg/pipeline/WorkflowDagExecutor.go | 4 +- pkg/prometheus/prometheus_client.go | 63 -- wire_gen.go | 463 +++++----- 66 files changed, 2022 insertions(+), 4440 deletions(-) delete mode 100644 api/restHandler/ArgoApplicationRestHandler.go delete mode 100644 api/restHandler/CDRestHandler.go delete mode 100644 api/restHandler/PipelineStatusTimelineRestHandler.go rename api/restHandler/{AppRestHandler.go => app/appInfo/AppInfoRestHandler.go} (93%) create mode 100644 api/restHandler/app/appList/AppFilteringRestHandler.go rename api/restHandler/{ => app/appList}/AppListingRestHandler.go (80%) rename api/restHandler/app/{ => pipeline}/AutoCompleteRestHandler.go (77%) rename api/restHandler/app/{ => pipeline/configure}/BuildPipelineRestHandler.go (99%) rename api/restHandler/app/{ => pipeline/configure}/BuildPipelineRestHandler_test.go (99%) rename api/restHandler/app/{ => pipeline/configure}/DeploymentPipelineRestHandler.go (99%) rename api/restHandler/app/{ => pipeline/configure}/PipelineConfigRestHandler.go (98%) rename api/restHandler/{ => app/pipeline/history}/PipelineHistoryRestHandler.go (99%) create mode 100644 api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go rename api/restHandler/{ => app/pipeline/trigger}/PipelineTriggerRestHandler.go (99%) rename api/restHandler/{ => app/pipeline/webhook}/WebhookDataRestHandler.go (99%) rename api/restHandler/{ => app/workflow}/AppWorkflowRestHandler.go (99%) delete mode 100644 api/router/AppListingRouter.go delete mode 100644 api/router/ApplicationRouter.go delete mode 100644 api/router/CDRouter.go create mode 100644 api/router/app/AppRouter.go create mode 100644 api/router/app/AppRouterEAMode.go rename api/router/{AppRouter.go => app/appInfo/AppInfoRouter.go} (76%) create mode 100644 api/router/app/appList/AppFilteringRouter.go create mode 100644 api/router/app/appList/AppListingRouter.go create mode 100644 api/router/app/pipeline/DevtronAppAutoCompleteRouter.go rename api/router/{ => app/pipeline/configure}/PipelineConfigRouter.go (73%) create mode 100644 api/router/app/pipeline/history/PipelineHistoryRouter.go create mode 100644 api/router/app/pipeline/status/PipelineStatusRouter.go rename api/router/{ => app/pipeline/trigger}/PipelineTriggerRouter.go (86%) create mode 100644 api/router/app/workflow/AppWorkflowRouter.go create mode 100644 api/util/apiHeader.go create mode 100644 client/argocdServer/application/ApplicationUtil.go delete mode 100644 internal/util/ArgoUtil/ApplicationService.go delete mode 100644 internal/util/ArgoUtil/ArgoClient.go delete mode 100644 internal/util/ArgoUtil/ClusterService.go delete mode 100644 internal/util/ArgoUtil/ClusterService_test.go delete mode 100644 internal/util/ArgoUtil/RepositoryService.go delete mode 100644 internal/util/ArgoUtil/ResourceService.go delete mode 100644 internal/util/ArgoUtil/TestUtil.go delete mode 100644 pkg/prometheus/prometheus_client.go diff --git a/Wire.go b/Wire.go index 7edecf73b9..dce534c9ff 100644 --- a/Wire.go +++ b/Wire.go @@ -44,9 +44,26 @@ import ( "github.com/devtron-labs/devtron/api/k8s" "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler" - pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" + pipeline3 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline" + pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history" + status2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook" + "github.com/devtron-labs/devtron/api/restHandler/app/workflow" "github.com/devtron-labs/devtron/api/restHandler/scopedVariable" "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + "github.com/devtron-labs/devtron/api/router/app/appList" + pipeline5 "github.com/devtron-labs/devtron/api/router/app/pipeline" + pipeline4 "github.com/devtron-labs/devtron/api/router/app/pipeline/configure" + history2 "github.com/devtron-labs/devtron/api/router/app/pipeline/history" + status3 "github.com/devtron-labs/devtron/api/router/app/pipeline/status" + trigger2 "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger" + workflow2 "github.com/devtron-labs/devtron/api/router/app/workflow" "github.com/devtron-labs/devtron/api/router/pubsub" "github.com/devtron-labs/devtron/api/server" "github.com/devtron-labs/devtron/api/sse" @@ -81,7 +98,6 @@ import ( resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/internal/util/ArgoUtil" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appClone" @@ -184,8 +200,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(session2.ServiceClient), new(*middleware.LoginService)), sse.NewSSE, - router.NewPipelineTriggerRouter, - wire.Bind(new(router.PipelineTriggerRouter), new(*router.PipelineTriggerRouterImpl)), + trigger2.NewPipelineTriggerRouter, + wire.Bind(new(trigger2.PipelineTriggerRouter), new(*trigger2.PipelineTriggerRouterImpl)), //---- pprof start ---- restHandler.NewPProfRestHandler, @@ -195,8 +211,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(router.PProfRouter), new(*router.PProfRouterImpl)), //---- pprof end ---- - restHandler.NewPipelineRestHandler, - wire.Bind(new(restHandler.PipelineTriggerRestHandler), new(*restHandler.PipelineTriggerRestHandlerImpl)), + trigger.NewPipelineRestHandler, + wire.Bind(new(trigger.PipelineTriggerRestHandler), new(*trigger.PipelineTriggerRestHandlerImpl)), app.GetAppServiceConfig, app.NewAppService, wire.Bind(new(app.AppService), new(*app.AppServiceImpl)), @@ -250,13 +266,25 @@ func InitializeApp() (*App, error) { wire.Bind(new(pipeline.CdPipelineConfigService), new(*pipeline.CdPipelineConfigServiceImpl)), pipeline.NewDevtronAppConfigServiceImpl, wire.Bind(new(pipeline.DevtronAppConfigService), new(*pipeline.DevtronAppConfigServiceImpl)), + pipeline3.NewDevtronAppAutoCompleteRestHandlerImpl, + wire.Bind(new(pipeline3.DevtronAppAutoCompleteRestHandler), new(*pipeline3.DevtronAppAutoCompleteRestHandlerImpl)), util5.NewLoggingMiddlewareImpl, wire.Bind(new(util5.LoggingMiddleware), new(*util5.LoggingMiddlewareImpl)), pipeline2.NewPipelineRestHandlerImpl, wire.Bind(new(pipeline2.PipelineConfigRestHandler), new(*pipeline2.PipelineConfigRestHandlerImpl)), - router.NewPipelineRouterImpl, - wire.Bind(new(router.PipelineConfigRouter), new(*router.PipelineConfigRouterImpl)), + + pipeline4.NewPipelineRouterImpl, + wire.Bind(new(pipeline4.PipelineConfigRouter), new(*pipeline4.PipelineConfigRouterImpl)), + history2.NewPipelineHistoryRouterImpl, + wire.Bind(new(history2.PipelineHistoryRouter), new(*history2.PipelineHistoryRouterImpl)), + status3.NewPipelineStatusRouterImpl, + wire.Bind(new(status3.PipelineStatusRouter), new(*status3.PipelineStatusRouterImpl)), + pipeline5.NewDevtronAppAutoCompleteRouterImpl, + wire.Bind(new(pipeline5.DevtronAppAutoCompleteRouter), new(*pipeline5.DevtronAppAutoCompleteRouterImpl)), + workflow2.NewAppWorkflowRouterImpl, + wire.Bind(new(workflow2.AppWorkflowRouter), new(*workflow2.AppWorkflowRouterImpl)), + pipeline.NewCiCdPipelineOrchestrator, wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)), pipelineConfig.NewMaterialRepositoryImpl, @@ -305,10 +333,15 @@ func InitializeApp() (*App, error) { pipeline.NewGitRegistryConfigImpl, wire.Bind(new(pipeline.GitRegistryConfig), new(*pipeline.GitRegistryConfigImpl)), - router.NewAppListingRouterImpl, - wire.Bind(new(router.AppListingRouter), new(*router.AppListingRouterImpl)), - restHandler.NewAppListingRestHandlerImpl, - wire.Bind(new(restHandler.AppListingRestHandler), new(*restHandler.AppListingRestHandlerImpl)), + appList.NewAppFilteringRouterImpl, + wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), + appList2.NewAppFilteringRestHandlerImpl, + wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), + + appList.NewAppListingRouterImpl, + wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)), + appList2.NewAppListingRestHandlerImpl, + wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)), app.NewAppListingServiceImpl, wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)), repository.NewAppListingRepositoryImpl, @@ -358,28 +391,9 @@ func InitializeApp() (*App, error) { repository2.NewServiceClientImpl, wire.Bind(new(repository2.ServiceClient), new(*repository2.ServiceClientImpl)), wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), - restHandler.NewArgoApplicationRestHandlerImpl, - wire.Bind(new(restHandler.ArgoApplicationRestHandler), new(*restHandler.ArgoApplicationRestHandlerImpl)), - router.NewApplicationRouterImpl, - wire.Bind(new(router.ApplicationRouter), new(*router.ApplicationRouterImpl)), + //app.GetConfig, - router.NewCDRouterImpl, - wire.Bind(new(router.CDRouter), new(*router.CDRouterImpl)), - restHandler.NewCDRestHandlerImpl, - wire.Bind(new(restHandler.CDRestHandler), new(*restHandler.CDRestHandlerImpl)), - - ArgoUtil.GetArgoConfig, - ArgoUtil.NewArgoSession, - ArgoUtil.NewResourceServiceImpl, - wire.Bind(new(ArgoUtil.ResourceService), new(*ArgoUtil.ResourceServiceImpl)), - //ArgoUtil.NewApplicationServiceImpl, - //wire.Bind(new(ArgoUtil.ApplicationService), new(ArgoUtil.ApplicationServiceImpl)), - //ArgoUtil.NewRepositoryService, - //wire.Bind(new(ArgoUtil.RepositoryService), new(ArgoUtil.RepositoryServiceImpl)), - - //ArgoUtil.NewClusterServiceImpl, - //wire.Bind(new(ArgoUtil.ClusterService), new(ArgoUtil.ClusterServiceImpl)), pipeline.GetEcrConfig, //otel.NewOtelTracingServiceImpl, //wire.Bind(new(otel.OtelTracingService), new(*otel.OtelTracingServiceImpl)), @@ -513,8 +527,8 @@ func InitializeApp() (*App, error) { appStoreRestHandler.NewAppStoreRouterImpl, wire.Bind(new(appStoreRestHandler.AppStoreRouter), new(*appStoreRestHandler.AppStoreRouterImpl)), - restHandler.NewAppWorkflowRestHandlerImpl, - wire.Bind(new(restHandler.AppWorkflowRestHandler), new(*restHandler.AppWorkflowRestHandlerImpl)), + workflow.NewAppWorkflowRestHandlerImpl, + wire.Bind(new(workflow.AppWorkflowRestHandler), new(*workflow.AppWorkflowRestHandlerImpl)), appWorkflow.NewAppWorkflowServiceImpl, wire.Bind(new(appWorkflow.AppWorkflowService), new(*appWorkflow.AppWorkflowServiceImpl)), @@ -704,13 +718,15 @@ func InitializeApp() (*App, error) { wire.Bind(new(repository.WebhookEventDataRepository), new(*repository.WebhookEventDataRepositoryImpl)), pipeline.NewWebhookEventDataConfigImpl, wire.Bind(new(pipeline.WebhookEventDataConfig), new(*pipeline.WebhookEventDataConfigImpl)), - restHandler.NewWebhookDataRestHandlerImpl, - wire.Bind(new(restHandler.WebhookDataRestHandler), new(*restHandler.WebhookDataRestHandlerImpl)), + webhook.NewWebhookDataRestHandlerImpl, + wire.Bind(new(webhook.WebhookDataRestHandler), new(*webhook.WebhookDataRestHandlerImpl)), - router.NewAppRouterImpl, - wire.Bind(new(router.AppRouter), new(*router.AppRouterImpl)), - restHandler.NewAppRestHandlerImpl, - wire.Bind(new(restHandler.AppRestHandler), new(*restHandler.AppRestHandlerImpl)), + app3.NewAppRouterImpl, + wire.Bind(new(app3.AppRouter), new(*app3.AppRouterImpl)), + appInfo2.NewAppInfoRouterImpl, + wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), + appInfo.NewAppInfoRestHandlerImpl, + wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), app.NewAppCrudOperationServiceImpl, wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), @@ -727,8 +743,8 @@ func InitializeApp() (*App, error) { // util2.NewGoJsonSchemaCustomFormatChecker, //history starts - restHandler.NewPipelineHistoryRestHandlerImpl, - wire.Bind(new(restHandler.PipelineHistoryRestHandler), new(*restHandler.PipelineHistoryRestHandlerImpl)), + history.NewPipelineHistoryRestHandlerImpl, + wire.Bind(new(history.PipelineHistoryRestHandler), new(*history.PipelineHistoryRestHandlerImpl)), repository3.NewConfigMapHistoryRepositoryImpl, wire.Bind(new(repository3.ConfigMapHistoryRepository), new(*repository3.ConfigMapHistoryRepositoryImpl)), @@ -817,8 +833,8 @@ func InitializeApp() (*App, error) { cron.NewCiTriggerCronImpl, wire.Bind(new(cron.CiTriggerCron), new(*cron.CiTriggerCronImpl)), - restHandler.NewPipelineStatusTimelineRestHandlerImpl, - wire.Bind(new(restHandler.PipelineStatusTimelineRestHandler), new(*restHandler.PipelineStatusTimelineRestHandlerImpl)), + status2.NewPipelineStatusTimelineRestHandlerImpl, + wire.Bind(new(status2.PipelineStatusTimelineRestHandler), new(*status2.PipelineStatusTimelineRestHandlerImpl)), status.NewPipelineStatusTimelineServiceImpl, wire.Bind(new(status.PipelineStatusTimelineService), new(*status.PipelineStatusTimelineServiceImpl)), diff --git a/api/connector/Connector.go b/api/connector/Connector.go index 5e5d0d6310..56d61c590b 100644 --- a/api/connector/Connector.go +++ b/api/connector/Connector.go @@ -21,7 +21,6 @@ import ( "bufio" "encoding/json" "fmt" - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/devtron/api/bean" "github.com/gogo/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -41,9 +40,6 @@ import ( var delimiter = []byte("\n\n") type Pump interface { - StartStream(w http.ResponseWriter, recv func() (proto.Message, error), err error) - StartStreamWithHeartBeat(w http.ResponseWriter, isReconnect bool, recv func() (*application.LogEntry, error), err error) - StartMessage(w http.ResponseWriter, resp proto.Message, perr error) StartStreamWithTransformer(w http.ResponseWriter, recv func() (proto.Message, error), err error, transformer func(interface{}) interface{}) StartK8sStreamWithHeartBeat(w http.ResponseWriter, isReconnect bool, stream io.ReadCloser, err error) } @@ -148,7 +144,7 @@ func (impl PumpImpl) StartK8sStreamWithHeartBeat(w http.ResponseWriter, isReconn // heartbeat end } -func (impl PumpImpl) StartStreamWithHeartBeat(w http.ResponseWriter, isReconnect bool, recv func() (*application.LogEntry, error), err error) { +func (impl PumpImpl) StartStreamWithTransformer(w http.ResponseWriter, recv func() (proto.Message, error), err error, transformer func(interface{}) interface{}) { f, ok := w.(http.Flusher) if !ok { http.Error(w, "unexpected server doesnt support streaming", http.StatusInternalServerError) @@ -162,41 +158,6 @@ func (impl PumpImpl) StartStreamWithHeartBeat(w http.ResponseWriter, isReconnect w.Header().Set("X-Content-Type-Options", "nosniff") var wroteHeader bool - if isReconnect { - err := impl.sendEvent(nil, []byte("RECONNECT_STREAM"), []byte("RECONNECT_STREAM"), w) - if err != nil { - impl.logger.Errorw("error in writing data over sse", "err", err) - return - } - } - // heartbeat start - ticker := time.NewTicker(30 * time.Second) - done := make(chan bool) - var mux sync.Mutex - go func() error { - for { - select { - case <-done: - return nil - case t := <-ticker.C: - mux.Lock() - err := impl.sendEvent(nil, []byte("PING"), []byte(t.String()), w) - mux.Unlock() - if err != nil { - impl.logger.Errorw("error in writing PING over sse", "err", err) - return err - } - f.Flush() - } - } - }() - defer func() { - ticker.Stop() - done <- true - }() - - // heartbeat end - for { resp, err := recv() if err == io.EOF { @@ -208,20 +169,18 @@ func (impl PumpImpl) StartStreamWithHeartBeat(w http.ResponseWriter, isReconnect return } response := bean.Response{} - response.Result = resp + response.Result = transformer(resp) buf, err := json.Marshal(response) - if err != nil { - impl.logger.Errorw("error in marshaling data", "err", err) + data := "data: " + string(buf) + if _, err = w.Write([]byte(data)); err != nil { + impl.logger.Errorf("Failed to send response chunk: %v", err) return } - mux.Lock() - err = impl.sendEvent([]byte(strconv.FormatInt(resp.GetTimeStamp().UnixNano(), 10)), nil, buf, w) - mux.Unlock() - if err != nil { - impl.logger.Errorw("error in writing data over sse", "err", err) + wroteHeader = true + if _, err = w.Write(delimiter); err != nil { + impl.logger.Errorf("Failed to send delimiter chunk: %v", err) return } - wroteHeader = true f.Flush() } } @@ -251,88 +210,6 @@ func (impl *PumpImpl) sendEvent(eventId []byte, eventName []byte, payload []byte return nil } -func (impl PumpImpl) StartStream(w http.ResponseWriter, recv func() (proto.Message, error), err error) { - f, ok := w.(http.Flusher) - if !ok { - http.Error(w, "unexpected server doesnt support streaming", http.StatusInternalServerError) - } - if err != nil { - http.Error(w, errors.Details(err), http.StatusInternalServerError) - } - w.Header().Set("Transfer-Encoding", "chunked") - w.Header().Set("Content-Type", "text/event-stream") - w.Header().Set("X-Accel-Buffering", "no") - w.Header().Set("X-Content-Type-Options", "nosniff") - - var wroteHeader bool - for { - resp, err := recv() - if err == io.EOF { - return - } - if err != nil { - impl.logger.Errorf("Error occurred while reading data from argocd %+v\n", err) - impl.handleForwardResponseStreamError(wroteHeader, w, err) - return - } - response := bean.Response{} - response.Result = resp - buf, err := json.Marshal(response) - data := "data: " + string(buf) - if _, err = w.Write([]byte(data)); err != nil { - impl.logger.Errorf("Failed to send response chunk: %v", err) - return - } - wroteHeader = true - if _, err = w.Write(delimiter); err != nil { - impl.logger.Errorf("Failed to send delimiter chunk: %v", err) - return - } - f.Flush() - } -} - -func (impl PumpImpl) StartStreamWithTransformer(w http.ResponseWriter, recv func() (proto.Message, error), err error, transformer func(interface{}) interface{}) { - f, ok := w.(http.Flusher) - if !ok { - http.Error(w, "unexpected server doesnt support streaming", http.StatusInternalServerError) - } - if err != nil { - http.Error(w, errors.Details(err), http.StatusInternalServerError) - } - w.Header().Set("Transfer-Encoding", "chunked") - w.Header().Set("Content-Type", "text/event-stream") - w.Header().Set("X-Accel-Buffering", "no") - w.Header().Set("X-Content-Type-Options", "nosniff") - - var wroteHeader bool - for { - resp, err := recv() - if err == io.EOF { - return - } - if err != nil { - impl.logger.Errorf("Error occurred while reading data from argocd %+v\n", err) - impl.handleForwardResponseStreamError(wroteHeader, w, err) - return - } - response := bean.Response{} - response.Result = transformer(resp) - buf, err := json.Marshal(response) - data := "data: " + string(buf) - if _, err = w.Write([]byte(data)); err != nil { - impl.logger.Errorf("Failed to send response chunk: %v", err) - return - } - wroteHeader = true - if _, err = w.Write(delimiter); err != nil { - impl.logger.Errorf("Failed to send delimiter chunk: %v", err) - return - } - f.Flush() - } -} - func (impl PumpImpl) handleForwardResponseStreamError(wroteHeader bool, w http.ResponseWriter, err error) { code := "000" if !wroteHeader { @@ -357,58 +234,3 @@ func (impl PumpImpl) handleForwardResponseStreamError(wroteHeader bool, w http.R return } } - -func (impl PumpImpl) StartMessage(w http.ResponseWriter, resp proto.Message, perr error) { - //w.Header().Set("Transfer-Encoding", "chunked") - w.Header().Set("Content-Type", "application/json") - - response := bean.Response{} - if perr != nil { - impl.handleForwardResponseMessageError(w, perr) - return - } - var buf []byte - var err error - if rb, ok := resp.(responseBody); ok { - response.Result = rb.XXX_ResponseBody() - buf, err = json.Marshal(response) - } else { - response.Result = resp - buf, err = json.Marshal(response) - } - if err != nil { - impl.logger.Errorf("Marshal error: %v", err) - return - } - - if _, err = w.Write(buf); err != nil { - impl.logger.Errorf("Failed to write response: %v", err) - } -} - -func (impl PumpImpl) handleForwardResponseMessageError(w http.ResponseWriter, err error) { - code := "000" - s, ok := status.FromError(err) - if !ok { - s = status.New(codes.Unknown, err.Error()) - } - w.WriteHeader(runtime.HTTPStatusFromCode(s.Code())) - code = fmt.Sprint(s.Code()) - response := bean.Response{} - apiErr := bean.ApiError{} - apiErr.Code = code // 000=unknown - apiErr.InternalMessage = errors.Details(err) - response.Errors = []bean.ApiError{apiErr} - buf, merr := json.Marshal(response) - if merr != nil { - impl.logger.Errorf("Failed to marshal response %+v\n", merr) - } - if _, werr := w.Write(buf); werr != nil { - impl.logger.Errorf("Failed to notify error to client: %v", werr) - return - } -} - -type responseBody interface { - XXX_ResponseBody() interface{} -} diff --git a/api/restHandler/ArgoApplicationRestHandler.go b/api/restHandler/ArgoApplicationRestHandler.go deleted file mode 100644 index 8672538739..0000000000 --- a/api/restHandler/ArgoApplicationRestHandler.go +++ /dev/null @@ -1,811 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package restHandler - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strconv" - "strings" - - application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - "github.com/devtron-labs/devtron/api/connector" - "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" - "github.com/devtron-labs/devtron/pkg/auth/user" - "github.com/devtron-labs/devtron/pkg/cluster" - "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - "github.com/devtron-labs/devtron/pkg/team" - "github.com/devtron-labs/devtron/pkg/terminal" - "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/util/argo" - "github.com/devtron-labs/devtron/util/rbac" - - "github.com/gogo/protobuf/proto" - "github.com/gorilla/mux" - "go.uber.org/zap" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -type ArgoApplicationRestHandler interface { - GetPodLogs(w http.ResponseWriter, r *http.Request) - GetResourceTree(w http.ResponseWriter, r *http.Request) - ListResourceEvents(w http.ResponseWriter, r *http.Request) - GetResource(w http.ResponseWriter, r *http.Request) - List(w http.ResponseWriter, r *http.Request) - Watch(w http.ResponseWriter, r *http.Request) - ManagedResources(w http.ResponseWriter, r *http.Request) - Rollback(w http.ResponseWriter, r *http.Request) - GetManifests(w http.ResponseWriter, r *http.Request) - Get(w http.ResponseWriter, r *http.Request) - - TerminateOperation(w http.ResponseWriter, r *http.Request) - PatchResource(w http.ResponseWriter, r *http.Request) - DeleteResource(w http.ResponseWriter, r *http.Request) - - GetServiceLink(w http.ResponseWriter, r *http.Request) - GetTerminalSession(w http.ResponseWriter, r *http.Request) -} - -type ArgoApplicationRestHandlerImpl struct { - client application.ServiceClient - logger *zap.SugaredLogger - pump connector.Pump - enforcer casbin.Enforcer - teamService team.TeamService - environmentService cluster.EnvironmentService - enforcerUtil rbac.EnforcerUtil - terminalSessionHandler terminal.TerminalSessionHandler - argoUserService argo.ArgoUserService - K8sResourceHistoryService kubernetesResourceAuditLogs.K8sResourceHistoryService - userService user.UserService -} - -func NewArgoApplicationRestHandlerImpl(client application.ServiceClient, - pump connector.Pump, - enforcer casbin.Enforcer, - teamService team.TeamService, - environmentService cluster.EnvironmentService, - logger *zap.SugaredLogger, - enforcerUtil rbac.EnforcerUtil, - terminalSessionHandler terminal.TerminalSessionHandler, - argoUserService argo.ArgoUserService, - K8sResourceHistoryService kubernetesResourceAuditLogs.K8sResourceHistoryService, - userService user.UserService) *ArgoApplicationRestHandlerImpl { - return &ArgoApplicationRestHandlerImpl{ - client: client, - logger: logger, - pump: pump, - enforcer: enforcer, - teamService: teamService, - environmentService: environmentService, - enforcerUtil: enforcerUtil, - terminalSessionHandler: terminalSessionHandler, - argoUserService: argoUserService, - K8sResourceHistoryService: K8sResourceHistoryService, - userService: userService, - } -} - -func (impl ArgoApplicationRestHandlerImpl) GetTerminalSession(w http.ResponseWriter, r *http.Request) { - token := r.Header.Get("token") - userId, err := impl.userService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - request := &terminal.TerminalSessionRequest{} - vars := mux.Vars(r) - request.ContainerName = vars["container"] - request.Namespace = vars["namespace"] - request.PodName = vars["pod"] - request.Shell = vars["shell"] - appId := vars["appId"] - envId := vars["environmentId"] - //---------auth - id, err := strconv.Atoi(appId) - if err != nil { - common.WriteJsonResp(w, fmt.Errorf("appId is not integer"), nil, http.StatusBadRequest) - return - } - eId, err := strconv.Atoi(envId) - if err != nil { - common.WriteJsonResp(w, fmt.Errorf("envId is not integer"), nil, http.StatusBadRequest) - return - } - request.AppId = id - //below method is for getting new object, i.e. team/env/app for new trigger policy - teamEnvRbacObject := impl.enforcerUtil.GetTeamEnvRBACNameByAppId(id, eId) - if teamEnvRbacObject == "" { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - //below methods are for getting old objects for old policies (admin, manager roles) - appRbacObject := impl.enforcerUtil.GetAppRBACNameByAppId(id) - if appRbacObject == "" { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - envRbacObject := impl.enforcerUtil.GetEnvRBACNameByAppId(id, eId) - if envRbacObject == "" { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusBadRequest) - return - } - request.EnvironmentId = eId - valid := false - - //checking if the user has access of terminal with new trigger policy, if not then will check old rbac - if ok := impl.enforcer.Enforce(token, casbin.ResourceTerminal, casbin.ActionExec, teamEnvRbacObject); !ok { - appRbacOk := impl.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, appRbacObject) - envRbacOk := impl.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionCreate, envRbacObject) - if appRbacOk && envRbacOk { - valid = true - } - } else { - valid = true - } - //checking rbac for charts - if ok := impl.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionCreate, teamEnvRbacObject); ok { - valid = true - } - //if both the new rbac(trigger access) and old rbac fails then user is forbidden to access terminal - if !valid { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - //---------auth end - //TODO apply validation - request.UserId = userId - status, message, err := impl.terminalSessionHandler.GetTerminalSession(request) - common.WriteJsonResp(w, err, message, status) -} - -func (impl ArgoApplicationRestHandlerImpl) Watch(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - query := application2.ApplicationQuery{Name: &name} - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - app, conn, err := impl.client.Watch(ctx, &query) - defer util.Close(conn, impl.logger) - impl.pump.StartStream(w, func() (proto.Message, error) { return app.Recv() }, err) -} - -func (impl ArgoApplicationRestHandlerImpl) GetPodLogs(w http.ResponseWriter, r *http.Request) { - v := r.URL.Query() - vars := mux.Vars(r) - name := vars["name"] - podName := vars["podName"] - containerName := v.Get("container") - namespace := v.Get("namespace") - sinceSeconds, err := strconv.ParseInt(v.Get("sinceSeconds"), 10, 64) - if err != nil { - sinceSeconds = 0 - } - follow, err := strconv.ParseBool(v.Get("follow")) - if err != nil { - follow = false - } - tailLines, err := strconv.ParseInt(v.Get("tailLines"), 10, 64) - if err != nil { - tailLines = 0 - } - query := application2.ApplicationPodLogsQuery{ - Name: &name, - PodName: &podName, - Container: &containerName, - Namespace: &namespace, - TailLines: &tailLines, - Follow: &follow, - SinceSeconds: &sinceSeconds, - } - lastEventId := r.Header.Get("Last-Event-ID") - isReconnect := false - if len(lastEventId) > 0 { - lastSeenMsgId, err := strconv.ParseInt(lastEventId, 10, 64) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - lastSeenMsgId = lastSeenMsgId + 1 //increased by one ns to avoid duplicate //FIXME still not fixed - t := v1.Unix(0, lastSeenMsgId) - query.SinceTime = &t - //set this ti zero since its reconnect request - var sinceSecondsForReconnectRequest int64 = 0 - query.SinceSeconds = &sinceSecondsForReconnectRequest - isReconnect = true - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - logs, conn, err := impl.client.PodLogs(ctx, &query) - defer util.Close(conn, impl.logger) - impl.pump.StartStreamWithHeartBeat(w, isReconnect, func() (*application2.LogEntry, error) { return logs.Recv() }, err) -} - -func (impl ArgoApplicationRestHandlerImpl) GetResourceTree(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - query := application2.ResourcesQuery{ - ApplicationName: &name, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.ResourceTree(ctx, &query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) ListResourceEvents(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - v := r.URL.Query() - resourceNameSpace := v.Get("resourceNamespace") - resourceUID := v.Get("resourceUID") - resourceName := v.Get("resourceName") - query := &application2.ApplicationResourceEventsQuery{ - Name: &name, - ResourceNamespace: &resourceNameSpace, - ResourceUID: &resourceUID, - ResourceName: &resourceName, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.ListResourceEvents(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) GetResource(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - v := r.URL.Query() - nameSpace := v.Get("namespace") - version := v.Get("version") - group := v.Get("group") - kind := v.Get("kind") - resourceName := v.Get("resourceName") - query := &application2.ApplicationResourceRequest{ - Name: &name, - Version: &version, - Group: &group, - Kind: &kind, - ResourceName: &resourceName, - Namespace: &nameSpace, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.GetResource(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) List(w http.ResponseWriter, r *http.Request) { - v := r.URL.Query() - name := v.Get("name") - refresh := v.Get("refresh") - project := v.Get("project") - projects := make([]string, 0) - if len(project) > 0 { - projects = strings.Split(project, ",") - } - query := &application2.ApplicationQuery{ - Name: &name, - Projects: projects, - Refresh: &refresh, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.List(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) ManagedResources(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - applicationName := vars["applicationName"] - query := &application2.ResourcesQuery{ - ApplicationName: &applicationName, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.ManagedResources(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) Rollback(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - decoder := json.NewDecoder(r.Body) - query := new(application2.ApplicationRollbackRequest) - err := decoder.Decode(query) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - query.Name = &name - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.Rollback(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) GetManifests(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - v := r.URL.Query() - revision := v.Get("revision") - query := &application2.ApplicationManifestQuery{ - Name: &name, - Revision: &revision, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.GetManifests(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) Get(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - v := r.URL.Query() - refresh := v.Get("refresh") - project := v.Get("project") - projects := make([]string, 0) - if len(project) > 0 { - projects = strings.Split(project, ",") - } - query := &application2.ApplicationQuery{ - Name: &name, - Projects: projects, - Refresh: &refresh, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.Get(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) TerminateOperation(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - query := application2.OperationTerminateRequest{ - Name: &name, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.TerminateOperation(ctx, &query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) PatchResource(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - token := r.Header.Get("token") - appId := vars["appId"] - id, err := strconv.Atoi(appId) - if err != nil { - common.WriteJsonResp(w, fmt.Errorf("appId is not integer"), nil, http.StatusBadRequest) - return - } - app := impl.enforcerUtil.GetAppRBACNameByAppId(id) - if app == "" { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - if ok := impl.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionTrigger, app); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - decoder := json.NewDecoder(r.Body) - query := new(application2.ApplicationResourcePatchRequest) - err = decoder.Decode(query.Patch) - if err != nil { - impl.logger.Error(err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - query.Name = &name - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.PatchResource(ctx, query) - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) DeleteResource(w http.ResponseWriter, r *http.Request) { - - userId, err := impl.userService.GetLoggedInUser(r) - - if err != nil { - // not returning err because userId is only needed for audit logs and not impacting delete functionality. - impl.logger.Errorw("error in getting logged in user for audit logs of k8s resource") - } - - vars := mux.Vars(r) - appNameACD := vars["appNameACD"] - name := vars["name"] - namespace := vars["namespace"] - resourceName := vars["resourceName"] - version := vars["version"] - kind := vars["kind"] - group := vars["group"] - force, err := strconv.ParseBool(vars["force"]) - if err != nil { - force = false - } - if name == "" || namespace == "" || resourceName == "" || version == "" || kind == "" { - common.WriteJsonResp(w, fmt.Errorf("missing mandatory field (name | namespace | resourceName | kind)"), nil, http.StatusBadRequest) - } - query := new(application2.ApplicationResourceDeleteRequest) - query.Name = &appNameACD - query.ResourceName = &name - query.Kind = &kind - query.Version = &version - query.Force = &force - query.Namespace = &namespace - query.Group = &group - token := r.Header.Get("token") - appId := vars["appId"] - envId := vars["envId"] - id, err := strconv.Atoi(appId) - if err != nil { - common.WriteJsonResp(w, fmt.Errorf("appId is not integer"), nil, http.StatusBadRequest) - return - } - eId, err := strconv.Atoi(envId) - if err != nil { - common.WriteJsonResp(w, fmt.Errorf("envId is not integer"), nil, http.StatusBadRequest) - return - } - appRbacObject := impl.enforcerUtil.GetAppRBACNameByAppId(id) - if appRbacObject == "" { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - envRbacObject := impl.enforcerUtil.GetEnvRBACNameByAppId(id, eId) - if envRbacObject == "" { - common.WriteJsonResp(w, fmt.Errorf("envId is incorrect"), nil, http.StatusBadRequest) - return - } - if ok := impl.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionTrigger, appRbacObject); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - if ok := impl.enforcer.Enforce(token, casbin.ResourceEnvironment, casbin.ActionTrigger, envRbacObject); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.DeleteResource(ctx, query) - - if err == nil { - ResourceHistoryErr := impl.K8sResourceHistoryService.SaveArgoCdAppsResourceDeleteHistory(query, id, eId, userId) - if ResourceHistoryErr != nil { - impl.logger.Errorw("error in saving audit logs of delete resource request for argo cd apps", "err", ResourceHistoryErr) - } - } - - impl.pump.StartMessage(w, recv, err) -} - -func (impl ArgoApplicationRestHandlerImpl) GetServiceLink(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - name := vars["name"] - v := r.URL.Query() - revision := v.Get("revision") - query := &application2.ApplicationManifestQuery{ - Name: &name, - Revision: &revision, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - recv, err := impl.client.GetManifests(ctx, query) - - manifests := recv.GetManifests() - var topMap []map[string]interface{} - serviceCounter := 0 - //port := "" - for _, manifest := range manifests { - lowMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(manifest), &lowMap) - //if val, ok := lowMap["kind"]; ok { - if lowMap["kind"] == "Service" { - serviceCounter = serviceCounter + 1 - } - topMap = append(topMap, lowMap) - } - - var activeService string - var serviceName string - var serviceNamespace string - var port string - var serviceLink string - if serviceCounter > 1 { - for _, lowMap := range topMap { - if lowMap["kind"] == "Rollout" { - specObj := lowMap["spec"].(map[string]interface{}) - strategyObj := specObj["strategy"].(map[string]interface{}) - blueGreenObj := strategyObj["blueGreen"].(map[string]interface{}) - activeService = blueGreenObj["activeService"].(string) - break - } - } - } - for _, lowMap := range topMap { - if lowMap["kind"] == "Service" { - metaObj := lowMap["metadata"].(map[string]interface{}) - specObj := lowMap["spec"].(map[string]interface{}) - portArr := specObj["ports"].([]interface{}) - - serviceName = metaObj["name"].(string) - serviceNamespace = metaObj["namespace"].(string) - if serviceCounter == 1 { - for _, item := range portArr { - itemObj := item.(map[string]interface{}) - if itemObj["name"] == name { - portF := itemObj["port"].(float64) - portI := int(portF) - port = strconv.Itoa(portI) - break - } - } - serviceLink = "http://" + serviceName + "." + serviceNamespace + ":" + port - break - } else if serviceCounter > 1 && serviceName == activeService { - for _, item := range portArr { - itemObj := item.(map[string]interface{}) - if itemObj["name"] == name { - portF := itemObj["port"].(float64) - portI := int(portF) - port = strconv.Itoa(portI) - break - } - } - serviceLink = "http://" + serviceName + "." + serviceNamespace + ":" + port - break - } else { - continue - } - } - } - common.WriteJsonResp(w, err, serviceLink, 200) -} diff --git a/api/restHandler/CDRestHandler.go b/api/restHandler/CDRestHandler.go deleted file mode 100644 index e305cebc1b..0000000000 --- a/api/restHandler/CDRestHandler.go +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package restHandler - -import ( - "encoding/json" - "github.com/devtron-labs/devtron/internal/util/ArgoUtil" - "github.com/gorilla/mux" - "go.uber.org/zap" - "net/http" -) - -type CDRestHandler interface { - FetchResourceTree(w http.ResponseWriter, r *http.Request) - - FetchPodContainerLogs(w http.ResponseWriter, r *http.Request) -} - -type CDRestHandlerImpl struct { - logger *zap.SugaredLogger - resourceService ArgoUtil.ResourceService -} - -func NewCDRestHandlerImpl(logger *zap.SugaredLogger, resourceService ArgoUtil.ResourceService) *CDRestHandlerImpl { - cdRestHandler := &CDRestHandlerImpl{logger: logger, resourceService: resourceService} - return cdRestHandler -} - -func (handler CDRestHandlerImpl) FetchResourceTree(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - appName := vars["app-name"] - - res, err := handler.resourceService.FetchResourceTree(appName) - if err != nil { - handler.logger.Errorw("request err, FetchResourceTree", "err", err, "appName", appName) - } - resJson, err := json.Marshal(res) - _, err = w.Write(resJson) - if err != nil { - handler.logger.Errorw("request err, FetchResourceTree", "err", err, "appName", appName, "response", res) - } -} - -func (handler CDRestHandlerImpl) FetchPodContainerLogs(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - appName := vars["app-name"] - podName := vars["pod-name"] - - res, err := handler.resourceService.FetchPodContainerLogs(appName, podName, ArgoUtil.PodContainerLogReq{}) - if err != nil { - handler.logger.Errorw("service err, FetchPodContainerLogs", "err", err, "appName", appName, "podName", podName) - } - resJson, err := json.Marshal(res) - _, err = w.Write(resJson) - if err != nil { - handler.logger.Errorw("service err, FetchPodContainerLogs", "err", err, "appName", appName, "podName", podName) - } -} diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index b8098c2f3d..5274fdd8da 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -22,13 +22,13 @@ import ( "encoding/json" "errors" "fmt" + app2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" "net/http" "strconv" "strings" "time" appBean "github.com/devtron-labs/devtron/api/appbean" - app2 "github.com/devtron-labs/devtron/api/restHandler/app" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository" @@ -63,7 +63,6 @@ const ( APP_DELETE_FAILED_RESP = "App deletion failed, please try deleting from Devtron UI" APP_CREATE_SUCCESSFUL_RESP = "App created successfully." APP_WORKFLOW_CREATE_SUCCESSFUL_RESP = "App workflow created successfully." - WORKFLOW_NAME_EMPTY = "" ) type CoreAppRestHandler interface { diff --git a/api/restHandler/ExternalCiRestHandler.go b/api/restHandler/ExternalCiRestHandler.go index a02d2a34cd..7dbe9b8b68 100644 --- a/api/restHandler/ExternalCiRestHandler.go +++ b/api/restHandler/ExternalCiRestHandler.go @@ -19,6 +19,7 @@ package restHandler import ( "encoding/json" + util3 "github.com/devtron-labs/devtron/api/util" "net/http" "strconv" @@ -63,7 +64,7 @@ func NewExternalCiRestHandlerImpl(logger *zap.SugaredLogger, webhookService pipe } func (impl ExternalCiRestHandlerImpl) HandleExternalCiWebhook(w http.ResponseWriter, r *http.Request) { - setupResponse(&w, r) + util3.SetupCorsOriginHeader(&w) vars := mux.Vars(r) token := r.Header.Get("api-token") userId, err := impl.userService.GetLoggedInUser(r) diff --git a/api/restHandler/PipelineStatusTimelineRestHandler.go b/api/restHandler/PipelineStatusTimelineRestHandler.go deleted file mode 100644 index 76e936240d..0000000000 --- a/api/restHandler/PipelineStatusTimelineRestHandler.go +++ /dev/null @@ -1,84 +0,0 @@ -package restHandler - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/pkg/app/status" - "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" - "github.com/devtron-labs/devtron/util/rbac" - "github.com/gorilla/mux" - "go.uber.org/zap" -) - -type PipelineStatusTimelineRestHandler interface { - FetchTimelines(w http.ResponseWriter, r *http.Request) -} - -type PipelineStatusTimelineRestHandlerImpl struct { - logger *zap.SugaredLogger - pipelineStatusTimelineService status.PipelineStatusTimelineService - enforcerUtil rbac.EnforcerUtil - enforcer casbin.Enforcer -} - -func NewPipelineStatusTimelineRestHandlerImpl(logger *zap.SugaredLogger, - pipelineStatusTimelineService status.PipelineStatusTimelineService, enforcerUtil rbac.EnforcerUtil, - enforcer casbin.Enforcer) *PipelineStatusTimelineRestHandlerImpl { - return &PipelineStatusTimelineRestHandlerImpl{ - logger: logger, - pipelineStatusTimelineService: pipelineStatusTimelineService, - enforcerUtil: enforcerUtil, - enforcer: enforcer, - } -} - -func (handler *PipelineStatusTimelineRestHandlerImpl) FetchTimelines(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - appId, err := strconv.Atoi(vars["appId"]) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - envId, err := strconv.Atoi(vars["envId"]) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - wfrId := 0 - wfrIdParam := r.URL.Query().Get("wfrId") - if len(wfrIdParam) != 0 { - wfrId, err = strconv.Atoi(wfrIdParam) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - } - showTimeline := false - showTimelineParam := r.URL.Query().Get("showTimeline") - if len(showTimelineParam) > 0 { - showTimeline, err = strconv.ParseBool(showTimelineParam) - if err != nil { - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - } - - resourceName := handler.enforcerUtil.GetAppRBACNameByAppId(appId) - token := r.Header.Get("token") - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, resourceName); !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) - return - } - - timelines, err := handler.pipelineStatusTimelineService.FetchTimelines(appId, envId, wfrId, showTimeline) - if err != nil { - handler.logger.Errorw("error in getting cd pipeline status timelines by wfrId", "err", err, "wfrId", wfrId) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, err, timelines, http.StatusOK) - return -} diff --git a/api/restHandler/AppRestHandler.go b/api/restHandler/app/appInfo/AppInfoRestHandler.go similarity index 93% rename from api/restHandler/AppRestHandler.go rename to api/restHandler/app/appInfo/AppInfoRestHandler.go index c787fd4f66..b6e614c1d7 100644 --- a/api/restHandler/AppRestHandler.go +++ b/api/restHandler/app/appInfo/AppInfoRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package appInfo import ( "encoding/json" @@ -38,7 +38,7 @@ import ( "gopkg.in/go-playground/validator.v9" ) -type AppRestHandler interface { +type AppInfoRestHandler interface { GetAllLabels(w http.ResponseWriter, r *http.Request) GetAppMetaInfo(w http.ResponseWriter, r *http.Request) GetHelmAppMetaInfo(w http.ResponseWriter, r *http.Request) @@ -48,7 +48,7 @@ type AppRestHandler interface { UpdateAppNote(w http.ResponseWriter, r *http.Request) } -type AppRestHandlerImpl struct { +type AppInfoRestHandlerImpl struct { logger *zap.SugaredLogger appService app.AppCrudOperationService userAuthService user.UserService @@ -60,11 +60,11 @@ type AppRestHandlerImpl struct { genericNoteService genericNotes.GenericNoteService } -func NewAppRestHandlerImpl(logger *zap.SugaredLogger, appService app.AppCrudOperationService, +func NewAppInfoRestHandlerImpl(logger *zap.SugaredLogger, appService app.AppCrudOperationService, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil, enforcer casbin.Enforcer, helmAppService client.HelmAppService, enforcerUtilHelm rbac.EnforcerUtilHelm, - genericNoteService genericNotes.GenericNoteService) *AppRestHandlerImpl { - handler := &AppRestHandlerImpl{ + genericNoteService genericNotes.GenericNoteService) *AppInfoRestHandlerImpl { + handler := &AppInfoRestHandlerImpl{ logger: logger, appService: appService, userAuthService: userAuthService, @@ -78,7 +78,7 @@ func NewAppRestHandlerImpl(logger *zap.SugaredLogger, appService app.AppCrudOper return handler } -func (handler AppRestHandlerImpl) GetAllLabels(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) GetAllLabels(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -102,7 +102,7 @@ func (handler AppRestHandlerImpl) GetAllLabels(w http.ResponseWriter, r *http.Re common.WriteJsonResp(w, nil, results, http.StatusOK) } -func (handler AppRestHandlerImpl) GetAppMetaInfo(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) GetAppMetaInfo(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -135,7 +135,7 @@ func (handler AppRestHandlerImpl) GetAppMetaInfo(w http.ResponseWriter, r *http. common.WriteJsonResp(w, nil, res, http.StatusOK) } -func (handler AppRestHandlerImpl) GetHelmAppMetaInfo(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) GetHelmAppMetaInfo(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -188,7 +188,7 @@ func (handler AppRestHandlerImpl) GetHelmAppMetaInfo(w http.ResponseWriter, r *h common.WriteJsonResp(w, nil, res, http.StatusOK) } -func (handler AppRestHandlerImpl) UpdateApp(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) UpdateApp(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -242,7 +242,7 @@ func (handler AppRestHandlerImpl) UpdateApp(w http.ResponseWriter, r *http.Reque common.WriteJsonResp(w, nil, res, http.StatusOK) } -func (handler AppRestHandlerImpl) UpdateProjectForApps(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) UpdateProjectForApps(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -286,7 +286,7 @@ func (handler AppRestHandlerImpl) UpdateProjectForApps(w http.ResponseWriter, r common.WriteJsonResp(w, nil, res, http.StatusOK) } -func (handler AppRestHandlerImpl) GetAppListByTeamIds(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) GetAppListByTeamIds(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -343,7 +343,7 @@ func (handler AppRestHandlerImpl) GetAppListByTeamIds(w http.ResponseWriter, r * common.WriteJsonResp(w, err, projectWiseApps, http.StatusOK) } -func (handler AppRestHandlerImpl) UpdateAppNote(w http.ResponseWriter, r *http.Request) { +func (handler AppInfoRestHandlerImpl) UpdateAppNote(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") decoder := json.NewDecoder(r.Body) userId, err := handler.userAuthService.GetLoggedInUser(r) diff --git a/api/restHandler/app/appList/AppFilteringRestHandler.go b/api/restHandler/app/appList/AppFilteringRestHandler.go new file mode 100644 index 0000000000..c0e6faf87a --- /dev/null +++ b/api/restHandler/app/appList/AppFilteringRestHandler.go @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package appList + +import ( + "github.com/caarlos0/env/v6" + "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/restHandler/common" + "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" + "github.com/devtron-labs/devtron/pkg/auth/user" + "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/team" + "go.uber.org/zap" + "net/http" + "strconv" + "strings" + "time" +) + +type AppFilteringRestHandler interface { + GetClusterTeamAndEnvListForAutocomplete(w http.ResponseWriter, r *http.Request) +} + +type AppFilteringRestHandlerImpl struct { + logger *zap.SugaredLogger + teamService team.TeamService + enforcer casbin.Enforcer + userService user.UserService + clusterService cluster.ClusterService + environmentClusterMappingsService cluster.EnvironmentService + cfg *bean.Config +} + +func NewAppFilteringRestHandlerImpl(logger *zap.SugaredLogger, + teamService team.TeamService, + enforcer casbin.Enforcer, + userService user.UserService, + clusterService cluster.ClusterService, + environmentClusterMappingsService cluster.EnvironmentService, +) *AppFilteringRestHandlerImpl { + cfg := &bean.Config{} + err := env.Parse(cfg) + if err != nil { + logger.Errorw("error occurred while parsing config ", "err", err) + cfg.IgnoreAuthCheck = false + } + logger.Infow("app listing rest handler initialized", "ignoreAuthCheckValue", cfg.IgnoreAuthCheck) + appFilteringRestHandler := &AppFilteringRestHandlerImpl{ + logger: logger, + teamService: teamService, + enforcer: enforcer, + userService: userService, + clusterService: clusterService, + environmentClusterMappingsService: environmentClusterMappingsService, + cfg: cfg, + } + return appFilteringRestHandler +} + +func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomplete(w http.ResponseWriter, r *http.Request) { + userId, err := handler.userService.GetLoggedInUser(r) + if userId == 0 || err != nil { + common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) + return + } + clusterMapping := make(map[string]cluster.ClusterBean) + start := time.Now() + clusterList, err := handler.clusterService.FindAllForAutoComplete() + dbOperationTime := time.Since(start) + if err != nil { + handler.logger.Errorw("service err, FindAllForAutoComplete in clusterService layer", "error", err) + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } + var granterClusters []cluster.ClusterBean + v := r.URL.Query() + authEnabled := true + auth := v.Get("auth") + if len(auth) > 0 { + authEnabled, err = strconv.ParseBool(auth) + if err != nil { + authEnabled = true + err = nil + //ignore error, apply rbac by default + } + } + // RBAC enforcer applying + token := r.Header.Get("token") + start = time.Now() + for _, item := range clusterList { + clusterMapping[strings.ToLower(item.ClusterName)] = item + if authEnabled == true { + if ok := handler.enforcer.Enforce(token, casbin.ResourceCluster, casbin.ActionGet, item.ClusterName); ok { + granterClusters = append(granterClusters, item) + } + } else { + granterClusters = append(granterClusters, item) + } + + } + handler.logger.Infow("Cluster elapsed Time for enforcer", "dbElapsedTime", dbOperationTime, "enforcerTime", time.Since(start), "envSize", len(granterClusters)) + //RBAC enforcer Ends + + if len(granterClusters) == 0 { + granterClusters = make([]cluster.ClusterBean, 0) + } + + //getting environment for autocomplete + start = time.Now() + environments, err := handler.environmentClusterMappingsService.GetEnvironmentOnlyListForAutocomplete() + if err != nil { + handler.logger.Errorw("service err, GetEnvironmentListForAutocomplete at environmentClusterMappingsService layer", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } + dbElapsedTime := time.Since(start) + var grantedEnvironment = environments + start = time.Now() + println(dbElapsedTime, grantedEnvironment) + if !handler.cfg.IgnoreAuthCheck { + grantedEnvironment = make([]cluster.EnvironmentBean, 0) + // RBAC enforcer applying + var envIdentifierList []string + for index, item := range environments { + clusterName := strings.ToLower(strings.Split(item.EnvironmentIdentifier, "__")[0]) + if clusterMapping[clusterName].Id != 0 { + environments[index].CdArgoSetup = clusterMapping[clusterName].IsCdArgoSetup + environments[index].ClusterName = clusterMapping[clusterName].ClusterName + } + envIdentifierList = append(envIdentifierList, strings.ToLower(item.EnvironmentIdentifier)) + } + + result := handler.enforcer.EnforceInBatch(token, casbin.ResourceGlobalEnvironment, casbin.ActionGet, envIdentifierList) + for _, item := range environments { + + var hasAccess bool + EnvironmentIdentifier := item.ClusterName + "__" + item.Namespace + if item.EnvironmentIdentifier != EnvironmentIdentifier { + // fix for futuristic case + hasAccess = result[strings.ToLower(EnvironmentIdentifier)] || result[strings.ToLower(item.EnvironmentIdentifier)] + } else { + hasAccess = result[strings.ToLower(item.EnvironmentIdentifier)] + } + if hasAccess { + grantedEnvironment = append(grantedEnvironment, item) + } + } + //RBAC enforcer Ends + } + elapsedTime := time.Since(start) + handler.logger.Infow("Env elapsed Time for enforcer", "dbElapsedTime", dbElapsedTime, "elapsedTime", + elapsedTime, "envSize", len(grantedEnvironment)) + + //getting teams for autocomplete + start = time.Now() + teams, err := handler.teamService.FetchForAutocomplete() + if err != nil { + handler.logger.Errorw("service err, FetchForAutocomplete at teamService layer", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } + dbElapsedTime = time.Since(start) + var grantedTeams = teams + start = time.Now() + if !handler.cfg.IgnoreAuthCheck { + grantedTeams = make([]team.TeamRequest, 0) + // RBAC enforcer applying + var teamNameList []string + for _, item := range teams { + teamNameList = append(teamNameList, strings.ToLower(item.Name)) + } + + result := handler.enforcer.EnforceInBatch(token, casbin.ResourceTeam, casbin.ActionGet, teamNameList) + + for _, item := range teams { + if hasAccess := result[strings.ToLower(item.Name)]; hasAccess { + grantedTeams = append(grantedTeams, item) + } + } + } + handler.logger.Infow("Team elapsed Time for enforcer", "dbElapsedTime", dbElapsedTime, "elapsedTime", time.Since(start), + "envSize", len(grantedTeams)) + + //RBAC enforcer Ends + resp := &AppAutocomplete{ + Teams: grantedTeams, + Environments: grantedEnvironment, + Clusters: granterClusters, + } + common.WriteJsonResp(w, nil, resp, http.StatusOK) + +} diff --git a/api/restHandler/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go similarity index 80% rename from api/restHandler/AppListingRestHandler.go rename to api/restHandler/app/appList/AppListingRestHandler.go index 59b922f6c1..1ac828625a 100644 --- a/api/restHandler/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package appList import ( "context" @@ -23,6 +23,8 @@ import ( "fmt" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" + util3 "github.com/devtron-labs/devtron/api/util" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" "net/http" @@ -32,7 +34,6 @@ import ( application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/caarlos0/env/v6" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8s/health" k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" @@ -75,7 +76,6 @@ type AppListingRestHandler interface { FetchAppDetailsV2(w http.ResponseWriter, r *http.Request) FetchResourceTree(w http.ResponseWriter, r *http.Request) FetchAllDevtronManagedApps(w http.ResponseWriter, r *http.Request) - FetchAppTriggerView(w http.ResponseWriter, r *http.Request) FetchAppStageStatus(w http.ResponseWriter, r *http.Request) FetchOtherEnvironment(w http.ResponseWriter, r *http.Request) @@ -83,8 +83,6 @@ type AppListingRestHandler interface { RedirectToLinkouts(w http.ResponseWriter, r *http.Request) GetHostUrlsByBatch(w http.ResponseWriter, r *http.Request) - ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request) - GetClusterTeamAndEnvListForAutocomplete(w http.ResponseWriter, r *http.Request) FetchAppsByEnvironmentV2(w http.ResponseWriter, r *http.Request) FetchAppsByEnvironmentV1(w http.ResponseWriter, r *http.Request) FetchAppsByEnvironmentVersioned(w http.ResponseWriter, r *http.Request) @@ -94,7 +92,6 @@ type AppListingRestHandler interface { type AppListingRestHandlerImpl struct { application application.ServiceClient appListingService app.AppListingService - teamService team.TeamService enforcer casbin.Enforcer pipeline pipeline.PipelineBuilder logger *zap.SugaredLogger @@ -102,22 +99,19 @@ type AppListingRestHandlerImpl struct { deploymentGroupService deploymentGroup.DeploymentGroupService userService user.UserService // TODO fix me next - helmAppClient gRPC.HelmAppClient // TODO refactoring: use HelmAppService - clusterService cluster.ClusterService - helmAppService client.HelmAppService - argoUserService argo.ArgoUserService - k8sCommonService k8s.K8sCommonService - installedAppService FullMode.InstalledAppDBExtendedService - installedAppResourceService resource.InstalledAppResourceService - cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler - pipelineRepository pipelineConfig.PipelineRepository - appStatusService appStatus.AppStatusService - installedAppRepository repository.InstalledAppRepository - environmentClusterMappingsService cluster.EnvironmentService - genericNoteService genericNotes.GenericNoteService - cfg *bean.Config - k8sApplicationService application3.K8sApplicationService - deploymentTemplateService generateManifest.DeploymentTemplateService + helmAppClient gRPC.HelmAppClient // TODO refactoring: use HelmAppService + helmAppService client.HelmAppService + argoUserService argo.ArgoUserService + k8sCommonService k8s.K8sCommonService + installedAppService FullMode.InstalledAppDBExtendedService + installedAppResourceService resource.InstalledAppResourceService + cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler + pipelineRepository pipelineConfig.PipelineRepository + appStatusService appStatus.AppStatusService + installedAppRepository repository.InstalledAppRepository + genericNoteService genericNotes.GenericNoteService + k8sApplicationService application3.K8sApplicationService + deploymentTemplateService generateManifest.DeploymentTemplateService } type AppStatus struct { @@ -136,65 +130,46 @@ type AppAutocomplete struct { func NewAppListingRestHandlerImpl(application application.ServiceClient, appListingService app.AppListingService, - teamService team.TeamService, enforcer casbin.Enforcer, pipeline pipeline.PipelineBuilder, logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil, deploymentGroupService deploymentGroup.DeploymentGroupService, userService user.UserService, - helmAppClient gRPC.HelmAppClient, clusterService cluster.ClusterService, helmAppService client.HelmAppService, + helmAppClient gRPC.HelmAppClient, helmAppService client.HelmAppService, argoUserService argo.ArgoUserService, k8sCommonService k8s.K8sCommonService, installedAppService FullMode.InstalledAppDBExtendedService, installedAppResourceService resource.InstalledAppResourceService, cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, pipelineRepository pipelineConfig.PipelineRepository, appStatusService appStatus.AppStatusService, installedAppRepository repository.InstalledAppRepository, - environmentClusterMappingsService cluster.EnvironmentService, genericNoteService genericNotes.GenericNoteService, k8sApplicationService application3.K8sApplicationService, deploymentTemplateService generateManifest.DeploymentTemplateService, ) *AppListingRestHandlerImpl { - cfg := &bean.Config{} - err := env.Parse(cfg) - if err != nil { - logger.Errorw("error occurred while parsing config ", "err", err) - cfg.IgnoreAuthCheck = false - } - logger.Infow("app listing rest handler initialized", "ignoreAuthCheckValue", cfg.IgnoreAuthCheck) appListingHandler := &AppListingRestHandlerImpl{ - application: application, - appListingService: appListingService, - logger: logger, - teamService: teamService, - pipeline: pipeline, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - deploymentGroupService: deploymentGroupService, - userService: userService, - helmAppClient: helmAppClient, - clusterService: clusterService, - helmAppService: helmAppService, - argoUserService: argoUserService, - k8sCommonService: k8sCommonService, - installedAppService: installedAppService, - installedAppResourceService: installedAppResourceService, - cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, - pipelineRepository: pipelineRepository, - appStatusService: appStatusService, - installedAppRepository: installedAppRepository, - environmentClusterMappingsService: environmentClusterMappingsService, - genericNoteService: genericNoteService, - cfg: cfg, - k8sApplicationService: k8sApplicationService, - deploymentTemplateService: deploymentTemplateService, + application: application, + appListingService: appListingService, + logger: logger, + pipeline: pipeline, + enforcer: enforcer, + enforcerUtil: enforcerUtil, + deploymentGroupService: deploymentGroupService, + userService: userService, + helmAppClient: helmAppClient, + helmAppService: helmAppService, + argoUserService: argoUserService, + k8sCommonService: k8sCommonService, + installedAppService: installedAppService, + installedAppResourceService: installedAppResourceService, + cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, + pipelineRepository: pipelineRepository, + appStatusService: appStatusService, + installedAppRepository: installedAppRepository, + genericNoteService: genericNoteService, + k8sApplicationService: k8sApplicationService, + deploymentTemplateService: deploymentTemplateService, } return appListingHandler } -func setupResponse(w *http.ResponseWriter, req *http.Request) { - (*w).Header().Set("Access-Control-Allow-Origin", "*") - (*w).Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") - (*w).Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") - (*w).Header().Set("Content-Type", "text/html; charset=utf-8") -} func (handler AppListingRestHandlerImpl) FetchAllDevtronManagedApps(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") userId, err := handler.userService.GetLoggedInUser(r) @@ -213,6 +188,7 @@ func (handler AppListingRestHandlerImpl) FetchAllDevtronManagedApps(w http.Respo res, err := handler.appListingService.FetchAllDevtronManagedApps() common.WriteJsonResp(w, err, res, http.StatusOK) } + func (handler AppListingRestHandlerImpl) FetchJobs(w http.ResponseWriter, r *http.Request) { userId, err := handler.userService.GetLoggedInUser(r) if userId == 0 || err != nil { @@ -285,6 +261,7 @@ func (handler AppListingRestHandlerImpl) FetchJobs(w http.ResponseWriter, r *htt common.WriteJsonResp(w, err, jobContainerResponse, http.StatusOK) } + func (handler AppListingRestHandlerImpl) FetchJobOverviewCiPipelines(w http.ResponseWriter, r *http.Request) { userId, err := handler.userService.GetLoggedInUser(r) if userId == 0 || err != nil { @@ -323,6 +300,7 @@ func (handler AppListingRestHandlerImpl) FetchJobOverviewCiPipelines(w http.Resp common.WriteJsonResp(w, err, jobCi, http.StatusOK) } + func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentVersioned(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) version := vars["version"] @@ -335,9 +313,10 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentVersioned(w http. return } } + func (handler AppListingRestHandlerImpl) FetchAppsByEnvironment(w http.ResponseWriter, r *http.Request) { //Allow CORS here By * or specific origin - setupResponse(&w, r) + util3.SetupCorsOriginHeader(&w) token := r.Header.Get("token") t0 := time.Now() t1 := time.Now() @@ -515,9 +494,10 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironment(w http.ResponseW handler.logger.Infow("api response time testing", "total time", time.Now().String(), "total time", t1.Unix()-t0.Unix()) common.WriteJsonResp(w, err, appContainerResponse, http.StatusOK) } + func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV1(w http.ResponseWriter, r *http.Request) { //Allow CORS here By * or specific origin - setupResponse(&w, r) + util3.SetupCorsOriginHeader(&w) token := r.Header.Get("token") t0 := time.Now() t1 := time.Now() @@ -695,9 +675,10 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV1(w http.Respons handler.logger.Infow("api response time testing", "total time", time.Now().String(), "total time", t1.Unix()-t0.Unix()) common.WriteJsonResp(w, err, appContainerResponse, http.StatusOK) } + func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV2(w http.ResponseWriter, r *http.Request) { //Allow CORS here By * or specific origin - setupResponse(&w, r) + util3.SetupCorsOriginHeader(&w) token := r.Header.Get("token") t0 := time.Now() t1 := time.Now() @@ -822,6 +803,7 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV2(w http.Respons common.WriteJsonResp(w, err, appContainerResponse, http.StatusOK) } +// TODO refactoring: use schema.NewDecoder().Decode(&queryStruct, r.URL.Query()) func (handler AppListingRestHandlerImpl) FetchOverviewAppsByEnvironment(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) userId, err := handler.userService.GetLoggedInUser(r) @@ -1063,136 +1045,6 @@ func (handler AppListingRestHandlerImpl) handleResourceTreeErrAndDeletePipelineI }, nil, http.StatusInternalServerError) } -func (handler AppListingRestHandlerImpl) FetchAppTriggerView(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - token := r.Header.Get("token") - appId, err := strconv.Atoi(vars["app-id"]) - if err != nil { - handler.logger.Errorw("request err, FetchAppTriggerView", "err", err, "appId", appId) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - handler.logger.Debugw("request payload, FetchAppTriggerView", "appId", appId) - - triggerView, err := handler.appListingService.FetchAppTriggerView(appId) - if err != nil { - handler.logger.Errorw("service err, FetchAppTriggerView", "err", err, "appId", appId) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - - //TODO: environment based auth, purge data of environment on which user doesnt have access, only show environment name - // RBAC enforcer applying - if len(triggerView) > 0 { - object := handler.enforcerUtil.GetAppRBACName(triggerView[0].AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, object); !ok { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden) - return - } - } - //RBAC enforcer Ends - - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - acdToken, err := handler.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - handler.logger.Errorw("error in getting acd token", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - ctx = context.WithValue(ctx, "token", acdToken) - defer cancel() - - response := make(chan AppStatus) - qCount := len(triggerView) - responses := map[string]AppStatus{} - - for i := 0; i < len(triggerView); i++ { - acdAppName := triggerView[i].AppName + "-" + triggerView[i].EnvironmentName - go func(pipelineName string) { - ctxt, cancel := context.WithTimeout(ctx, 60*time.Second) - defer cancel() - query := application2.ApplicationQuery{Name: &pipelineName} - app, conn, err := handler.application.Watch(ctxt, &query) - defer conn.Close() - if err != nil { - response <- AppStatus{name: pipelineName, status: "", message: "", err: err, conditions: make([]v1alpha1.ApplicationCondition, 0)} - return - } - if app != nil { - resp, err := app.Recv() - if err != nil { - response <- AppStatus{name: pipelineName, status: "", message: "", err: err, conditions: make([]v1alpha1.ApplicationCondition, 0)} - return - } - if resp != nil { - healthStatus := resp.Application.Status.Health.Status - status := AppStatus{ - name: pipelineName, - status: string(healthStatus), - message: resp.Application.Status.Health.Message, - err: nil, - conditions: resp.Application.Status.Conditions, - } - response <- status - return - } - response <- AppStatus{name: pipelineName, status: "", message: "", err: fmt.Errorf("Missing Application"), conditions: make([]v1alpha1.ApplicationCondition, 0)} - return - } - response <- AppStatus{name: pipelineName, status: "", message: "", err: fmt.Errorf("Connection Closed by Client"), conditions: make([]v1alpha1.ApplicationCondition, 0)} - - }(acdAppName) - } - rCount := 0 - - for { - select { - case msg, ok := <-response: - if ok { - if msg.err == nil { - responses[msg.name] = msg - } - } - rCount++ - } - if qCount == rCount { - break - } - } - - for i := 0; i < len(triggerView); i++ { - acdAppName := triggerView[i].AppName + "-" + triggerView[i].EnvironmentName - if val, ok := responses[acdAppName]; ok { - status := val.status - conditions := val.conditions - for _, condition := range conditions { - if condition.Type != v1alpha1.ApplicationConditionSharedResourceWarning { - status = "Degraded" - } - } - triggerView[i].Status = status - triggerView[i].StatusMessage = val.message - triggerView[i].Conditions = val.conditions - } - if triggerView[i].Status == "" { - triggerView[i].Status = "Unknown" - } - if triggerView[i].Status == string(health.HealthStatusDegraded) { - triggerView[i].Status = "Not Deployed" - } - } - common.WriteJsonResp(w, err, triggerView, http.StatusOK) -} - func (handler AppListingRestHandlerImpl) FetchAppStageStatus(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) appId, err := strconv.Atoi(vars["app-id"]) @@ -1554,7 +1406,7 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter if err != nil { handler.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) } else if status { - resp.Status = application.HIBERNATING + resp.Status = argoApplication.HIBERNATING } } if resp.Status == string(health.HealthStatusDegraded) { @@ -1600,12 +1452,12 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter applicationStatus := detail.ApplicationStatus resourceTree["releaseStatus"] = releaseStatus resourceTree["status"] = applicationStatus - if applicationStatus == application.Healthy { + if applicationStatus == argoApplication.Healthy { status, err := handler.appListingService.ISLastReleaseStopType(appId, envId) if err != nil { handler.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) } else if status { - resourceTree["status"] = application.HIBERNATING + resourceTree["status"] = argoApplication.HIBERNATING } } handler.logger.Warnw("appName and envName not found - avoiding resource tree call", "app", cdPipeline.DeploymentAppName, "env", cdPipeline.Environment.Name) @@ -1637,184 +1489,3 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter newResourceTree := handler.k8sCommonService.PortNumberExtraction(resp, resourceTree) return newResourceTree, nil } -func (handler AppListingRestHandlerImpl) ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request) { - token := r.Header.Get("token") - vars := mux.Vars(r) - userId, err := handler.userService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - appId, err := strconv.Atoi(vars["appId"]) - if err != nil { - handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - envId, err := strconv.Atoi(vars["envId"]) - if err != nil { - handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "envId", envId) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - - app, err := handler.pipeline.GetApp(appId) - if err != nil { - handler.logger.Errorw("bad request", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusBadRequest) - return - } - // RBAC enforcer applying - object := handler.enforcerUtil.GetAppRBACName(app.AppName) - if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, object); !ok { - common.WriteJsonResp(w, err, "unauthorized user", http.StatusForbidden) - return - } - //RBAC enforcer Ends - if app.AppType == helper.ChartStoreApp { - err = handler.cdApplicationStatusUpdateHandler.ManualSyncPipelineStatus(appId, 0, userId) - } else { - err = handler.cdApplicationStatusUpdateHandler.ManualSyncPipelineStatus(appId, envId, userId) - } - - if err != nil { - handler.logger.Errorw("service err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId, "envId", envId) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - common.WriteJsonResp(w, nil, "App synced successfully.", http.StatusOK) -} - -func (handler AppListingRestHandlerImpl) GetClusterTeamAndEnvListForAutocomplete(w http.ResponseWriter, r *http.Request) { - userId, err := handler.userService.GetLoggedInUser(r) - if userId == 0 || err != nil { - common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) - return - } - clusterMapping := make(map[string]cluster.ClusterBean) - start := time.Now() - clusterList, err := handler.clusterService.FindAllForAutoComplete() - dbOperationTime := time.Since(start) - if err != nil { - handler.logger.Errorw("service err, FindAllForAutoComplete in clusterService layer", "error", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - var granterClusters []cluster.ClusterBean - v := r.URL.Query() - authEnabled := true - auth := v.Get("auth") - if len(auth) > 0 { - authEnabled, err = strconv.ParseBool(auth) - if err != nil { - authEnabled = true - err = nil - //ignore error, apply rbac by default - } - } - // RBAC enforcer applying - token := r.Header.Get("token") - start = time.Now() - for _, item := range clusterList { - clusterMapping[strings.ToLower(item.ClusterName)] = item - if authEnabled == true { - if ok := handler.enforcer.Enforce(token, casbin.ResourceCluster, casbin.ActionGet, item.ClusterName); ok { - granterClusters = append(granterClusters, item) - } - } else { - granterClusters = append(granterClusters, item) - } - - } - handler.logger.Infow("Cluster elapsed Time for enforcer", "dbElapsedTime", dbOperationTime, "enforcerTime", time.Since(start), "envSize", len(granterClusters)) - //RBAC enforcer Ends - - if len(granterClusters) == 0 { - granterClusters = make([]cluster.ClusterBean, 0) - } - - //getting environment for autocomplete - start = time.Now() - environments, err := handler.environmentClusterMappingsService.GetEnvironmentOnlyListForAutocomplete() - if err != nil { - handler.logger.Errorw("service err, GetEnvironmentListForAutocomplete at environmentClusterMappingsService layer", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - dbElapsedTime := time.Since(start) - var grantedEnvironment = environments - start = time.Now() - println(dbElapsedTime, grantedEnvironment) - if !handler.cfg.IgnoreAuthCheck { - grantedEnvironment = make([]cluster.EnvironmentBean, 0) - // RBAC enforcer applying - var envIdentifierList []string - for index, item := range environments { - clusterName := strings.ToLower(strings.Split(item.EnvironmentIdentifier, "__")[0]) - if clusterMapping[clusterName].Id != 0 { - environments[index].CdArgoSetup = clusterMapping[clusterName].IsCdArgoSetup - environments[index].ClusterName = clusterMapping[clusterName].ClusterName - } - envIdentifierList = append(envIdentifierList, strings.ToLower(item.EnvironmentIdentifier)) - } - - result := handler.enforcer.EnforceInBatch(token, casbin.ResourceGlobalEnvironment, casbin.ActionGet, envIdentifierList) - for _, item := range environments { - - var hasAccess bool - EnvironmentIdentifier := item.ClusterName + "__" + item.Namespace - if item.EnvironmentIdentifier != EnvironmentIdentifier { - // fix for futuristic case - hasAccess = result[strings.ToLower(EnvironmentIdentifier)] || result[strings.ToLower(item.EnvironmentIdentifier)] - } else { - hasAccess = result[strings.ToLower(item.EnvironmentIdentifier)] - } - if hasAccess { - grantedEnvironment = append(grantedEnvironment, item) - } - } - //RBAC enforcer Ends - } - elapsedTime := time.Since(start) - handler.logger.Infow("Env elapsed Time for enforcer", "dbElapsedTime", dbElapsedTime, "elapsedTime", - elapsedTime, "envSize", len(grantedEnvironment)) - - //getting teams for autocomplete - start = time.Now() - teams, err := handler.teamService.FetchForAutocomplete() - if err != nil { - handler.logger.Errorw("service err, FetchForAutocomplete at teamService layer", "err", err) - common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) - return - } - dbElapsedTime = time.Since(start) - var grantedTeams = teams - start = time.Now() - if !handler.cfg.IgnoreAuthCheck { - grantedTeams = make([]team.TeamRequest, 0) - // RBAC enforcer applying - var teamNameList []string - for _, item := range teams { - teamNameList = append(teamNameList, strings.ToLower(item.Name)) - } - - result := handler.enforcer.EnforceInBatch(token, casbin.ResourceTeam, casbin.ActionGet, teamNameList) - - for _, item := range teams { - if hasAccess := result[strings.ToLower(item.Name)]; hasAccess { - grantedTeams = append(grantedTeams, item) - } - } - } - handler.logger.Infow("Team elapsed Time for enforcer", "dbElapsedTime", dbElapsedTime, "elapsedTime", time.Since(start), - "envSize", len(grantedTeams)) - - //RBAC enforcer Ends - resp := &AppAutocomplete{ - Teams: grantedTeams, - Environments: grantedEnvironment, - Clusters: granterClusters, - } - common.WriteJsonResp(w, nil, resp, http.StatusOK) - -} diff --git a/api/restHandler/app/AutoCompleteRestHandler.go b/api/restHandler/app/pipeline/AutoCompleteRestHandler.go similarity index 77% rename from api/restHandler/app/AutoCompleteRestHandler.go rename to api/restHandler/app/pipeline/AutoCompleteRestHandler.go index 116f88b391..ac03a3d052 100644 --- a/api/restHandler/app/AutoCompleteRestHandler.go +++ b/api/restHandler/app/pipeline/AutoCompleteRestHandler.go @@ -1,8 +1,13 @@ -package app +package pipeline import ( "context" "fmt" + "github.com/devtron-labs/devtron/pkg/auth/user" + "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/team" + "github.com/devtron-labs/devtron/util/rbac" + "go.uber.org/zap" "net/http" "strconv" @@ -17,14 +22,49 @@ import ( ) type DevtronAppAutoCompleteRestHandler interface { + GetAppListForAutocomplete(w http.ResponseWriter, r *http.Request) + EnvironmentListAutocomplete(w http.ResponseWriter, r *http.Request) GitListAutocomplete(w http.ResponseWriter, r *http.Request) RegistriesListAutocomplete(w http.ResponseWriter, r *http.Request) TeamListAutocomplete(w http.ResponseWriter, r *http.Request) - EnvironmentListAutocomplete(w http.ResponseWriter, r *http.Request) - GetAppListForAutocomplete(w http.ResponseWriter, r *http.Request) } -func (handler PipelineConfigRestHandlerImpl) GetAppListForAutocomplete(w http.ResponseWriter, r *http.Request) { +type DevtronAppAutoCompleteRestHandlerImpl struct { + Logger *zap.SugaredLogger + userAuthService user.UserService + teamService team.TeamService + enforcer casbin.Enforcer + enforcerUtil rbac.EnforcerUtil + devtronAppConfigService pipeline.DevtronAppConfigService + envService cluster.EnvironmentService + gitRegistryConfig pipeline.GitRegistryConfig + dockerRegistryConfig pipeline.DockerRegistryConfig +} + +func NewDevtronAppAutoCompleteRestHandlerImpl( + Logger *zap.SugaredLogger, + userAuthService user.UserService, + teamService team.TeamService, + enforcer casbin.Enforcer, + enforcerUtil rbac.EnforcerUtil, + devtronAppConfigService pipeline.DevtronAppConfigService, + envService cluster.EnvironmentService, + gitRegistryConfig pipeline.GitRegistryConfig, + dockerRegistryConfig pipeline.DockerRegistryConfig) *DevtronAppAutoCompleteRestHandlerImpl { + return &DevtronAppAutoCompleteRestHandlerImpl{ + Logger: Logger, + userAuthService: userAuthService, + teamService: teamService, + enforcer: enforcer, + enforcerUtil: enforcerUtil, + devtronAppConfigService: devtronAppConfigService, + envService: envService, + gitRegistryConfig: gitRegistryConfig, + dockerRegistryConfig: dockerRegistryConfig, + } +} + +func (handler DevtronAppAutoCompleteRestHandlerImpl) GetAppListForAutocomplete(w http.ResponseWriter, r *http.Request) { userId, err := handler.userAuthService.GetLoggedInUser(r) if userId == 0 || err != nil { common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) @@ -53,7 +93,7 @@ func (handler PipelineConfigRestHandlerImpl) GetAppListForAutocomplete(w http.Re handler.Logger.Infow("request payload, GetAppListForAutocomplete", "teamId", teamId) var apps []*pipeline.AppBean if len(teamId) == 0 { - apps, err = handler.pipelineBuilder.FindAllMatchesByAppName(appName, helper.AppType(appType)) + apps, err = handler.devtronAppConfigService.FindAllMatchesByAppName(appName, helper.AppType(appType)) if err != nil { handler.Logger.Errorw("service err, GetAppListForAutocomplete", "err", err, "teamId", teamId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -65,7 +105,7 @@ func (handler PipelineConfigRestHandlerImpl) GetAppListForAutocomplete(w http.Re common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } else { - apps, err = handler.pipelineBuilder.FindAppsByTeamId(teamIdInt) + apps, err = handler.devtronAppConfigService.FindAppsByTeamId(teamIdInt) if err != nil { handler.Logger.Errorw("service err, GetAppListForAutocomplete", "err", err, "teamId", teamId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -107,7 +147,7 @@ func (handler PipelineConfigRestHandlerImpl) GetAppListForAutocomplete(w http.Re common.WriteJsonResp(w, err, accessedApps, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) EnvironmentListAutocomplete(w http.ResponseWriter, r *http.Request) { +func (handler DevtronAppAutoCompleteRestHandlerImpl) EnvironmentListAutocomplete(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") vars := mux.Vars(r) appId, err := strconv.Atoi(vars["appId"]) @@ -137,7 +177,7 @@ func (handler PipelineConfigRestHandlerImpl) EnvironmentListAutocomplete(w http. common.WriteJsonResp(w, err, result, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) GitListAutocomplete(w http.ResponseWriter, r *http.Request) { +func (handler DevtronAppAutoCompleteRestHandlerImpl) GitListAutocomplete(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") vars := mux.Vars(r) appId, err := strconv.Atoi(vars["appId"]) @@ -164,7 +204,7 @@ func (handler PipelineConfigRestHandlerImpl) GitListAutocomplete(w http.Response common.WriteJsonResp(w, err, res, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) RegistriesListAutocomplete(w http.ResponseWriter, r *http.Request) { +func (handler DevtronAppAutoCompleteRestHandlerImpl) RegistriesListAutocomplete(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") vars := mux.Vars(r) appId, err := strconv.Atoi(vars["appId"]) @@ -208,7 +248,7 @@ func (handler PipelineConfigRestHandlerImpl) RegistriesListAutocomplete(w http.R common.WriteJsonResp(w, err, res, http.StatusOK) } -func (handler PipelineConfigRestHandlerImpl) TeamListAutocomplete(w http.ResponseWriter, r *http.Request) { +func (handler DevtronAppAutoCompleteRestHandlerImpl) TeamListAutocomplete(w http.ResponseWriter, r *http.Request) { token := r.Header.Get("token") vars := mux.Vars(r) appId, err := strconv.Atoi(vars["appId"]) diff --git a/api/restHandler/app/BuildPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go similarity index 99% rename from api/restHandler/app/BuildPipelineRestHandler.go rename to api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go index cd7b6b1e5e..95ced7033b 100644 --- a/api/restHandler/app/BuildPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go @@ -1,4 +1,4 @@ -package app +package configure import ( "context" diff --git a/api/restHandler/app/BuildPipelineRestHandler_test.go b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go similarity index 99% rename from api/restHandler/app/BuildPipelineRestHandler_test.go rename to api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go index 01a01735fb..13cbe791e5 100644 --- a/api/restHandler/app/BuildPipelineRestHandler_test.go +++ b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go @@ -1,4 +1,4 @@ -package app +package configure import ( "bytes" diff --git a/api/restHandler/app/DeploymentPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go similarity index 99% rename from api/restHandler/app/DeploymentPipelineRestHandler.go rename to api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go index d6076e34fc..605aec3c1a 100644 --- a/api/restHandler/app/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go @@ -1,4 +1,4 @@ -package app +package configure import ( "context" diff --git a/api/restHandler/app/PipelineConfigRestHandler.go b/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go similarity index 98% rename from api/restHandler/app/PipelineConfigRestHandler.go rename to api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go index 557d8c5e88..99809d282e 100644 --- a/api/restHandler/app/PipelineConfigRestHandler.go +++ b/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go @@ -15,7 +15,7 @@ * */ -package app +package configure import ( "bufio" @@ -51,7 +51,6 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/bean" - request "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/pipeline" security2 "github.com/devtron-labs/devtron/pkg/security" "github.com/devtron-labs/devtron/pkg/team" @@ -84,7 +83,6 @@ type DevtronAppWorkflowRestHandler interface { } type PipelineConfigRestHandler interface { - DevtronAppAutoCompleteRestHandler DevtronAppRestHandler DevtronAppWorkflowRestHandler DevtronAppBuildRestHandler @@ -115,8 +113,6 @@ type PipelineConfigRestHandlerImpl struct { pipelineRepository pipelineConfig.PipelineRepository appWorkflowService appWorkflow.AppWorkflowService enforcerUtil rbac.EnforcerUtil - envService request.EnvironmentService - gitRegistryConfig pipeline.GitRegistryConfig dockerRegistryConfig pipeline.DockerRegistryConfig cdHandler pipeline.CdHandler appCloneService appClone.AppCloneService @@ -144,8 +140,8 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger validator *validator.Validate, gitSensorClient gitSensor.Client, ciPipelineRepository pipelineConfig.CiPipelineRepository, pipelineRepository pipelineConfig.PipelineRepository, - enforcerUtil rbac.EnforcerUtil, envService request.EnvironmentService, - gitRegistryConfig pipeline.GitRegistryConfig, dockerRegistryConfig pipeline.DockerRegistryConfig, + enforcerUtil rbac.EnforcerUtil, + dockerRegistryConfig pipeline.DockerRegistryConfig, cdHandler pipeline.CdHandler, appCloneService appClone.AppCloneService, deploymentTemplateService generateManifest.DeploymentTemplateService, @@ -177,8 +173,6 @@ func NewPipelineRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, Logger ciPipelineRepository: ciPipelineRepository, pipelineRepository: pipelineRepository, enforcerUtil: enforcerUtil, - envService: envService, - gitRegistryConfig: gitRegistryConfig, dockerRegistryConfig: dockerRegistryConfig, cdHandler: cdHandler, appCloneService: appCloneService, diff --git a/api/restHandler/PipelineHistoryRestHandler.go b/api/restHandler/app/pipeline/history/PipelineHistoryRestHandler.go similarity index 99% rename from api/restHandler/PipelineHistoryRestHandler.go rename to api/restHandler/app/pipeline/history/PipelineHistoryRestHandler.go index ebf9f75a73..01ada568f3 100644 --- a/api/restHandler/PipelineHistoryRestHandler.go +++ b/api/restHandler/app/pipeline/history/PipelineHistoryRestHandler.go @@ -1,4 +1,4 @@ -package restHandler +package history import ( "fmt" diff --git a/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go b/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go new file mode 100644 index 0000000000..c3b7c931e5 --- /dev/null +++ b/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go @@ -0,0 +1,140 @@ +package status + +import ( + "fmt" + "github.com/devtron-labs/devtron/client/cron" + "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/pkg/auth/user" + "github.com/devtron-labs/devtron/pkg/pipeline" + "net/http" + "strconv" + + "github.com/devtron-labs/devtron/api/restHandler/common" + "github.com/devtron-labs/devtron/pkg/app/status" + "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" + "github.com/devtron-labs/devtron/util/rbac" + "github.com/gorilla/mux" + "go.uber.org/zap" +) + +type PipelineStatusTimelineRestHandler interface { + FetchTimelines(w http.ResponseWriter, r *http.Request) + ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request) +} + +type PipelineStatusTimelineRestHandlerImpl struct { + logger *zap.SugaredLogger + userService user.UserService + pipelineStatusTimelineService status.PipelineStatusTimelineService + enforcerUtil rbac.EnforcerUtil + enforcer casbin.Enforcer + pipeline pipeline.PipelineBuilder + cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler +} + +func NewPipelineStatusTimelineRestHandlerImpl(logger *zap.SugaredLogger, + pipelineStatusTimelineService status.PipelineStatusTimelineService, enforcerUtil rbac.EnforcerUtil, + enforcer casbin.Enforcer) *PipelineStatusTimelineRestHandlerImpl { + return &PipelineStatusTimelineRestHandlerImpl{ + logger: logger, + pipelineStatusTimelineService: pipelineStatusTimelineService, + enforcerUtil: enforcerUtil, + enforcer: enforcer, + } +} + +func (handler *PipelineStatusTimelineRestHandlerImpl) FetchTimelines(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + appId, err := strconv.Atoi(vars["appId"]) + if err != nil { + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + envId, err := strconv.Atoi(vars["envId"]) + if err != nil { + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + wfrId := 0 + wfrIdParam := r.URL.Query().Get("wfrId") + if len(wfrIdParam) != 0 { + wfrId, err = strconv.Atoi(wfrIdParam) + if err != nil { + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + } + showTimeline := false + showTimelineParam := r.URL.Query().Get("showTimeline") + if len(showTimelineParam) > 0 { + showTimeline, err = strconv.ParseBool(showTimelineParam) + if err != nil { + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + } + + resourceName := handler.enforcerUtil.GetAppRBACNameByAppId(appId) + token := r.Header.Get("token") + if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, resourceName); !ok { + common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden) + return + } + + timelines, err := handler.pipelineStatusTimelineService.FetchTimelines(appId, envId, wfrId, showTimeline) + if err != nil { + handler.logger.Errorw("error in getting cd pipeline status timelines by wfrId", "err", err, "wfrId", wfrId) + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } + common.WriteJsonResp(w, err, timelines, http.StatusOK) + return +} + +func (handler *PipelineStatusTimelineRestHandlerImpl) ManualSyncAcdPipelineDeploymentStatus(w http.ResponseWriter, r *http.Request) { + token := r.Header.Get("token") + vars := mux.Vars(r) + userId, err := handler.userService.GetLoggedInUser(r) + if userId == 0 || err != nil { + common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) + return + } + appId, err := strconv.Atoi(vars["appId"]) + if err != nil { + handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + envId, err := strconv.Atoi(vars["envId"]) + if err != nil { + handler.logger.Errorw("request err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "envId", envId) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + + app, err := handler.pipeline.GetApp(appId) + if err != nil { + handler.logger.Errorw("bad request", "err", err) + common.WriteJsonResp(w, err, nil, http.StatusBadRequest) + return + } + // RBAC enforcer applying + object := handler.enforcerUtil.GetAppRBACName(app.AppName) + if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionGet, object); !ok { + common.WriteJsonResp(w, err, "unauthorized user", http.StatusForbidden) + return + } + //RBAC enforcer Ends + if app.AppType == helper.ChartStoreApp { + err = handler.cdApplicationStatusUpdateHandler.ManualSyncPipelineStatus(appId, 0, userId) + } else { + err = handler.cdApplicationStatusUpdateHandler.ManualSyncPipelineStatus(appId, envId, userId) + } + + if err != nil { + handler.logger.Errorw("service err, ManualSyncAcdPipelineDeploymentStatus", "err", err, "appId", appId, "envId", envId) + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } + common.WriteJsonResp(w, nil, "App synced successfully.", http.StatusOK) +} diff --git a/api/restHandler/PipelineTriggerRestHandler.go b/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go similarity index 99% rename from api/restHandler/PipelineTriggerRestHandler.go rename to api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go index f019462e65..695ee95f44 100644 --- a/api/restHandler/PipelineTriggerRestHandler.go +++ b/api/restHandler/app/pipeline/trigger/PipelineTriggerRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package trigger import ( "context" diff --git a/api/restHandler/WebhookDataRestHandler.go b/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go similarity index 99% rename from api/restHandler/WebhookDataRestHandler.go rename to api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go index 4a4463d06a..c0dd12c85b 100644 --- a/api/restHandler/WebhookDataRestHandler.go +++ b/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package webhook import ( "context" diff --git a/api/restHandler/AppWorkflowRestHandler.go b/api/restHandler/app/workflow/AppWorkflowRestHandler.go similarity index 99% rename from api/restHandler/AppWorkflowRestHandler.go rename to api/restHandler/app/workflow/AppWorkflowRestHandler.go index ee99852e51..f0b2016bc8 100644 --- a/api/restHandler/AppWorkflowRestHandler.go +++ b/api/restHandler/app/workflow/AppWorkflowRestHandler.go @@ -15,7 +15,7 @@ * */ -package restHandler +package workflow import ( "encoding/json" diff --git a/api/router/AppListingRouter.go b/api/router/AppListingRouter.go deleted file mode 100644 index affdb15823..0000000000 --- a/api/router/AppListingRouter.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/gorilla/mux" -) - -type AppListingRouter interface { - initAppListingRouter(helmRouter *mux.Router) -} - -type AppListingRouterImpl struct { - appListingRestHandler restHandler.AppListingRestHandler -} - -func NewAppListingRouterImpl(appListingRestHandler restHandler.AppListingRestHandler) *AppListingRouterImpl { - router := &AppListingRouterImpl{ - appListingRestHandler: appListingRestHandler, - } - return router -} - -func (router AppListingRouterImpl) initAppListingRouter(appListingRouter *mux.Router) { - appListingRouter.Path("/allApps").HandlerFunc(router.appListingRestHandler.FetchAllDevtronManagedApps). - Methods("GET") - - appListingRouter.Path("/resource/urls").Queries("envId", "{envId}"). - HandlerFunc(router.appListingRestHandler.GetHostUrlsByBatch).Methods("GET") - - appListingRouter.Path("/list"). - HandlerFunc(router.appListingRestHandler.FetchAppsByEnvironment). - Methods("POST") - - appListingRouter.Path("/list/{version}"). - HandlerFunc(router.appListingRestHandler.FetchAppsByEnvironmentVersioned). - Methods("POST") - - appListingRouter.Path("/list/group/{env-id}"). - HandlerFunc(router.appListingRestHandler.FetchOverviewAppsByEnvironment). - Methods("GET") - - appListingRouter.Path("/list/group/{env-id}"). - Queries("size", "{size}", "offset", "{offset}"). - HandlerFunc(router.appListingRestHandler.FetchOverviewAppsByEnvironment). - Methods("GET") - //This API used for fetch app details, not deployment details - appListingRouter.Path("/detail").Queries("app-id", "{app-id}").Queries("env-id", "{env-id}"). - HandlerFunc(router.appListingRestHandler.FetchAppDetails). - Methods("GET") - - appListingRouter.Path("/detail/v2").Queries("app-id", "{app-id}").Queries("env-id", "{env-id}"). - HandlerFunc(router.appListingRestHandler.FetchAppDetailsV2). - Methods("GET") - - appListingRouter.Path("/detail/resource-tree").Queries("app-id", "{app-id}").Queries("env-id", "{env-id}"). - HandlerFunc(router.appListingRestHandler.FetchResourceTree). - Methods("GET") - - appListingRouter.Path("/vsm").Queries("app-id", "{app-id}"). - HandlerFunc(router.appListingRestHandler.FetchAppTriggerView). - Methods("GET") - - appListingRouter.Path("/stage/status").Queries("app-id", "{app-id}"). - HandlerFunc(router.appListingRestHandler.FetchAppStageStatus). - Methods("GET") - - appListingRouter.Path("/other-env").Queries("app-id", "{app-id}"). - HandlerFunc(router.appListingRestHandler.FetchOtherEnvironment). - Methods("GET") - - appListingRouter.Path("/other-env/min").Queries("app-id", "{app-id}"). - HandlerFunc(router.appListingRestHandler.FetchMinDetailOtherEnvironment).Methods("GET") - - appListingRouter.Path("/linkouts/{Id}/{appId}/{envId}").Queries("podName", "{podName}"). - Queries("containerName", "{containerName}"). - HandlerFunc(router.appListingRestHandler.RedirectToLinkouts). - Methods("GET") - - appListingRouter.Path("/deployment-status/manual-sync/{appId}/{envId}"). - HandlerFunc(router.appListingRestHandler.ManualSyncAcdPipelineDeploymentStatus). - Methods("GET") - - appListingRouter.Path("/app-listing/autocomplete"). - HandlerFunc(router.appListingRestHandler.GetClusterTeamAndEnvListForAutocomplete).Methods("GET") - -} diff --git a/api/router/ApplicationRouter.go b/api/router/ApplicationRouter.go deleted file mode 100644 index 729f7f5242..0000000000 --- a/api/router/ApplicationRouter.go +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/pkg/terminal" - "github.com/gorilla/mux" - "go.uber.org/zap" -) - -type ApplicationRouter interface { - initApplicationRouter(router *mux.Router) -} - -type ApplicationRouterImpl struct { - handler restHandler.ArgoApplicationRestHandler - logger *zap.SugaredLogger -} - -func NewApplicationRouterImpl(handler restHandler.ArgoApplicationRestHandler, logger *zap.SugaredLogger) *ApplicationRouterImpl { - return &ApplicationRouterImpl{ - handler: handler, - logger: logger, - } -} - -func (r ApplicationRouterImpl) initApplicationRouter(router *mux.Router) { - router.Path("/stream"). - Queries("name", "{name}"). - Methods("GET"). - HandlerFunc(r.handler.Watch) - - router.Path("/{name}/pods/{podName}/logs"). - Queries("container", "{container}", "namespace", "{namespace}"). - Queries("follow", "{follow}"). - Queries("sinceSeconds", "{sinceSeconds}"). - Queries("sinceTime.seconds", "{sinceTime.seconds}"). - Queries("sinceTime.nanos", "{sinceTime.nanos}"). - Queries("tailLines", "{tailLines}"). - Methods("GET"). - HandlerFunc(r.handler.GetPodLogs) - router.Path("/{name}/pods/{podName}/logs"). - Methods("GET"). - HandlerFunc(r.handler.GetPodLogs) - router.Path("/{name}/resource-tree"). - Methods("GET"). - HandlerFunc(r.handler.GetResourceTree) - router.Path("/{name}/resource"). - Queries("version", "{version}", "namespace", "{namespace}", "group", "{group}", "kind", "{kind}", "resourceName", "{resourceName}"). - Methods("GET"). - HandlerFunc(r.handler.GetResource) - router.Path("/{name}/events"). - Queries("resourceNamespace", "{resourceNamespace}", "resourceUID", "{resourceUID}", "resourceName", "{resourceName}"). - Methods("GET"). - HandlerFunc(r.handler.ListResourceEvents) - router.Path("/{name}/events"). - Methods("GET"). - HandlerFunc(r.handler.ListResourceEvents) - router.Path("/"). - Queries("name", "{name}", "refresh", "{refresh}", "project", "{project}"). - Methods("GET"). - HandlerFunc(r.handler.List) - router.Path("/{applicationName}/managed-resources"). - Methods("GET"). - HandlerFunc(r.handler.ManagedResources) - router.Path("/{name}" + - "/rollback"). - Methods("GET"). - HandlerFunc(r.handler.Rollback) - - router.Path("/{name}/manifests"). - Methods("GET"). - HandlerFunc(r.handler.GetManifests) - router.Path("/{name}"). - Methods("GET"). - HandlerFunc(r.handler.Get) - router.Path("/{appName}/operation"). - Methods("DELETE"). - HandlerFunc(r.handler.TerminateOperation) - router.Path("/{name}/resource"). - Methods("POST"). - HandlerFunc(r.handler.PatchResource) - router.Path("/{appNameACD}/resource"). - Queries("name", "{name}", "namespace", "{namespace}", "resourceName", "{resourceName}", "version", "{version}", - "force", "{force}", "appId", "{appId}", "envId", "{envId}", "group", "{group}", "kind", "{kind}"). - Methods("DELETE"). - HandlerFunc(r.handler.DeleteResource) - - router.Path("/{name}/service-link"). - Methods("GET"). - HandlerFunc(r.handler.GetServiceLink) - router.Path("/pod/exec/session/{appId}/{environmentId}/{namespace}/{pod}/{shell}/{container}"). - Methods("GET"). - HandlerFunc(r.handler.GetTerminalSession) - router.Path("/pod/exec/sockjs/ws/").Handler(terminal.CreateAttachHandler("/api/v1/applications/pod/exec/sockjs/ws/")) -} diff --git a/api/router/CDRouter.go b/api/router/CDRouter.go deleted file mode 100644 index 7cf9ae9fe9..0000000000 --- a/api/router/CDRouter.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package router - -import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/gorilla/mux" - "go.uber.org/zap" - "net/http" -) - -type CDRouter interface { - initCDRouter(helmRouter *mux.Router) -} - -type CDRouterImpl struct { - logger *zap.SugaredLogger - cdRestHandler restHandler.CDRestHandler -} - -func NewCDRouterImpl(logger *zap.SugaredLogger, cdRestHandler restHandler.CDRestHandler) *CDRouterImpl { - router := &CDRouterImpl{ - logger: logger, - cdRestHandler: cdRestHandler, - } - return router -} - -func (router CDRouterImpl) initCDRouter(cdRouter *mux.Router) { - cdRouter.Path("/"). - HandlerFunc(func(writer http.ResponseWriter, request *http.Request) { - router.writeSuccess("Welcome @Devtron", writer) - }).Methods("GET") - - cdRouter.Path("/tree/{app-name}"). - HandlerFunc(router.cdRestHandler.FetchResourceTree). - Methods("GET") - - cdRouter.Path("/logs/{app-name}/pods/{pod-name}"). - HandlerFunc(router.cdRestHandler.FetchPodContainerLogs). - Methods("GET") -} - -func (router CDRouterImpl) writeSuccess(message string, w http.ResponseWriter) { - w.WriteHeader(http.StatusOK) - _, err := w.Write([]byte(message)) - if err != nil { - router.logger.Error(err) - } -} diff --git a/api/router/JobsRouter.go b/api/router/JobsRouter.go index e6130ae93e..08fb268d4b 100644 --- a/api/router/JobsRouter.go +++ b/api/router/JobsRouter.go @@ -1,8 +1,8 @@ package router import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/appList" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" "github.com/gorilla/mux" ) @@ -10,11 +10,11 @@ type JobRouter interface { InitJobRouter(router *mux.Router) } type JobRouterImpl struct { - pipelineConfigRestHandler app.PipelineConfigRestHandler - appListingRestHandler restHandler.AppListingRestHandler + pipelineConfigRestHandler configure.PipelineConfigRestHandler + appListingRestHandler appList.AppListingRestHandler } -func NewJobRouterImpl(pipelineConfigRestHandler app.PipelineConfigRestHandler, appListingRestHandler restHandler.AppListingRestHandler) *JobRouterImpl { +func NewJobRouterImpl(pipelineConfigRestHandler configure.PipelineConfigRestHandler, appListingRestHandler appList.AppListingRestHandler) *JobRouterImpl { return &JobRouterImpl{ appListingRestHandler: appListingRestHandler, pipelineConfigRestHandler: pipelineConfigRestHandler, diff --git a/api/router/ResourceGroupingRouter.go b/api/router/ResourceGroupingRouter.go index 94a72a1acd..252d2d225a 100644 --- a/api/router/ResourceGroupingRouter.go +++ b/api/router/ResourceGroupingRouter.go @@ -2,7 +2,8 @@ package router import ( "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" + "github.com/devtron-labs/devtron/api/restHandler/app/workflow" "github.com/gorilla/mux" ) @@ -10,13 +11,13 @@ type ResourceGroupingRouter interface { InitResourceGroupingRouter(router *mux.Router) } type ResourceGroupingRouterImpl struct { - pipelineConfigRestHandler app.PipelineConfigRestHandler - appWorkflowRestHandler restHandler.AppWorkflowRestHandler + pipelineConfigRestHandler configure.PipelineConfigRestHandler + appWorkflowRestHandler workflow.AppWorkflowRestHandler resourceGroupRestHandler restHandler.ResourceGroupRestHandler } -func NewResourceGroupingRouterImpl(restHandler app.PipelineConfigRestHandler, - appWorkflowRestHandler restHandler.AppWorkflowRestHandler, +func NewResourceGroupingRouterImpl(restHandler configure.PipelineConfigRestHandler, + appWorkflowRestHandler workflow.AppWorkflowRestHandler, resourceGroupRestHandler restHandler.ResourceGroupRestHandler) *ResourceGroupingRouterImpl { return &ResourceGroupingRouterImpl{ pipelineConfigRestHandler: restHandler, diff --git a/api/router/WebhookRouter.go b/api/router/WebhookRouter.go index 4fa1ea0ae8..9b852150fa 100644 --- a/api/router/WebhookRouter.go +++ b/api/router/WebhookRouter.go @@ -19,7 +19,7 @@ package router import ( "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" "github.com/gorilla/mux" ) @@ -29,13 +29,13 @@ type WebhookRouter interface { type WebhookRouterImpl struct { gitWebhookRestHandler restHandler.GitWebhookRestHandler - pipelineRestHandler app.PipelineConfigRestHandler + pipelineRestHandler configure.PipelineConfigRestHandler externalCiRestHandler restHandler.ExternalCiRestHandler pubSubClientRestHandler restHandler.PubSubClientRestHandler } func NewWebhookRouterImpl(gitWebhookRestHandler restHandler.GitWebhookRestHandler, - pipelineRestHandler app.PipelineConfigRestHandler, externalCiRestHandler restHandler.ExternalCiRestHandler, + pipelineRestHandler configure.PipelineConfigRestHandler, externalCiRestHandler restHandler.ExternalCiRestHandler, pubSubClientRestHandler restHandler.PubSubClientRestHandler) *WebhookRouterImpl { return &WebhookRouterImpl{ gitWebhookRestHandler: gitWebhookRestHandler, diff --git a/api/router/app/AppRouter.go b/api/router/app/AppRouter.go new file mode 100644 index 0000000000..9a55f865b7 --- /dev/null +++ b/api/router/app/AppRouter.go @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package app + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/appList" + workflow2 "github.com/devtron-labs/devtron/api/restHandler/app/workflow" + "github.com/devtron-labs/devtron/api/router/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/router/app/appList" + pipeline2 "github.com/devtron-labs/devtron/api/router/app/pipeline" + "github.com/devtron-labs/devtron/api/router/app/pipeline/configure" + "github.com/devtron-labs/devtron/api/router/app/pipeline/history" + "github.com/devtron-labs/devtron/api/router/app/pipeline/status" + "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger" + "github.com/devtron-labs/devtron/api/router/app/workflow" + "github.com/gorilla/mux" +) + +type AppRouter interface { + InitAppRouter(helmRouter *mux.Router) +} + +type AppRouterImpl struct { + appFilteringRouter appList2.AppFilteringRouter + appListingRouter appList2.AppListingRouter + appInfoRouter appInfo.AppInfoRouter + helmRouter trigger.PipelineTriggerRouter + pipelineConfigRouter configure.PipelineConfigRouter + pipelineHistoryRouter history.PipelineHistoryRouter + pipelineStatusRouter status.PipelineStatusRouter + appWorkflowRouter workflow.AppWorkflowRouter + devtronAppAutoCompleteRouter pipeline2.DevtronAppAutoCompleteRouter + + // TODO remove these dependencies after migration + appWorkflowRestHandler workflow2.AppWorkflowRestHandler + appListingRestHandler appList.AppListingRestHandler + appFilteringRestHandler appList.AppFilteringRestHandler +} + +func NewAppRouterImpl(appFilteringRouter appList2.AppFilteringRouter, + appListingRouter appList2.AppListingRouter, + appInfoRouter appInfo.AppInfoRouter, + helmRouter trigger.PipelineTriggerRouter, + pipelineConfigRouter configure.PipelineConfigRouter, + pipelineHistoryRouter history.PipelineHistoryRouter, + pipelineStatusRouter status.PipelineStatusRouter, + appWorkflowRouter workflow.AppWorkflowRouter, + devtronAppAutoCompleteRouter pipeline2.DevtronAppAutoCompleteRouter, + appWorkflowRestHandler workflow2.AppWorkflowRestHandler, + appListingRestHandler appList.AppListingRestHandler, + appFilteringRestHandler appList.AppFilteringRestHandler) *AppRouterImpl { + router := &AppRouterImpl{ + appInfoRouter: appInfoRouter, + helmRouter: helmRouter, + appFilteringRouter: appFilteringRouter, + appListingRouter: appListingRouter, + pipelineConfigRouter: pipelineConfigRouter, + pipelineHistoryRouter: pipelineHistoryRouter, + pipelineStatusRouter: pipelineStatusRouter, + appWorkflowRouter: appWorkflowRouter, + devtronAppAutoCompleteRouter: devtronAppAutoCompleteRouter, + appWorkflowRestHandler: appWorkflowRestHandler, + appListingRestHandler: appListingRestHandler, + appFilteringRestHandler: appFilteringRestHandler, + } + return router +} + +func (router AppRouterImpl) InitAppRouter(AppRouter *mux.Router) { + router.appInfoRouter.InitAppInfoRouter(AppRouter) + router.pipelineConfigRouter.InitPipelineConfigRouter(AppRouter) + router.helmRouter.InitPipelineTriggerRouter(AppRouter) + router.devtronAppAutoCompleteRouter.InitDevtronAppAutoCompleteRouter(AppRouter) + + appFilterRouter := AppRouter.PathPrefix("/filter").Subrouter() + router.appFilteringRouter.InitAppFilteringRouter(appFilterRouter) + + appListRouter := AppRouter.PathPrefix("/list").Subrouter() + router.appListingRouter.InitAppListingRouter(appListRouter) + + pipelineHistoryRouter := AppRouter.PathPrefix("/history").Subrouter() + router.pipelineHistoryRouter.InitPipelineHistoryRouter(pipelineHistoryRouter) + + deploymentStatusRouter := AppRouter.PathPrefix("/deployment-status").Subrouter() + router.pipelineStatusRouter.InitPipelineStatusRouter(deploymentStatusRouter) + + appWorkflowRouter := AppRouter.PathPrefix("/app-wf").Subrouter() + router.appWorkflowRouter.InitAppWorkflowRouter(appWorkflowRouter) + + // TODO refactoring: categorise and move to respective folders + AppRouter.Path("/allApps"). + HandlerFunc(router.appListingRestHandler.FetchAllDevtronManagedApps). + Methods("GET") + + AppRouter.Path("/resource/urls"). + Queries("envId", "{envId}"). + HandlerFunc(router.appListingRestHandler.GetHostUrlsByBatch). + Methods("GET") + + //This API used for fetch app details, not deployment details + AppRouter.Path("/detail"). + Queries("app-id", "{app-id}"). + Queries("env-id", "{env-id}"). + HandlerFunc(router.appListingRestHandler.FetchAppDetails). + Methods("GET") + + AppRouter.Path("/detail/v2").Queries("app-id", "{app-id}"). + Queries("env-id", "{env-id}"). + HandlerFunc(router.appListingRestHandler.FetchAppDetailsV2). + Methods("GET") + + AppRouter.Path("/detail/resource-tree").Queries("app-id", "{app-id}"). + Queries("env-id", "{env-id}"). + HandlerFunc(router.appListingRestHandler.FetchResourceTree). + Methods("GET") + + AppRouter.Path("/stage/status").Queries("app-id", "{app-id}"). + HandlerFunc(router.appListingRestHandler.FetchAppStageStatus). + Methods("GET") + + AppRouter.Path("/other-env").Queries("app-id", "{app-id}"). + HandlerFunc(router.appListingRestHandler.FetchOtherEnvironment). + Methods("GET") + + AppRouter.Path("/other-env/min").Queries("app-id", "{app-id}"). + HandlerFunc(router.appListingRestHandler.FetchMinDetailOtherEnvironment). + Methods("GET") + + AppRouter.Path("/linkouts/{Id}/{appId}/{envId}").Queries("podName", "{podName}"). + Queries("containerName", "{containerName}"). + HandlerFunc(router.appListingRestHandler.RedirectToLinkouts). + Methods("GET") + + // TODO refactoring: migrate + AppRouter.Path("/app-listing/autocomplete"). + HandlerFunc(router.appFilteringRestHandler.GetClusterTeamAndEnvListForAutocomplete). + Methods("GET") // deprecated; use filter/autocomplete instead. + + // TODO refactoring: migrate + AppRouter.Path("/wf/all/component-names/{appId}"). + HandlerFunc(router.appWorkflowRestHandler.FindAllWorkflows). + Methods("GET") // deprecated; use /app-wf/all/component-names/{appId} instead. +} diff --git a/api/router/app/AppRouterEAMode.go b/api/router/app/AppRouterEAMode.go new file mode 100644 index 0000000000..cebef3f989 --- /dev/null +++ b/api/router/app/AppRouterEAMode.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package app + +import ( + "github.com/devtron-labs/devtron/api/router/app/appInfo" + "github.com/devtron-labs/devtron/api/router/app/appList" + "github.com/gorilla/mux" +) + +type AppRouterEAMode interface { + InitAppRouterEAMode(helmRouter *mux.Router) +} + +type AppRouterEAModeImpl struct { + appInfoRouter appInfo.AppInfoRouter + appFilteringRouter appList.AppFilteringRouter +} + +func NewAppRouterEAModeImpl(appInfoRouter appInfo.AppInfoRouter, appFilteringRouter appList.AppFilteringRouter) *AppRouterEAModeImpl { + router := &AppRouterEAModeImpl{ + appInfoRouter: appInfoRouter, + appFilteringRouter: appFilteringRouter, + } + return router +} + +func (router AppRouterEAModeImpl) InitAppRouterEAMode(AppRouterEAMode *mux.Router) { + router.appInfoRouter.InitAppInfoRouter(AppRouterEAMode) + appFilterRouter := AppRouterEAMode.PathPrefix("/filter").Subrouter() + router.appFilteringRouter.InitAppFilteringRouter(appFilterRouter) +} diff --git a/api/router/AppRouter.go b/api/router/app/appInfo/AppInfoRouter.go similarity index 76% rename from api/router/AppRouter.go rename to api/router/app/appInfo/AppInfoRouter.go index 2f6f146ea4..175d0f8ff4 100644 --- a/api/router/AppRouter.go +++ b/api/router/app/appInfo/AppInfoRouter.go @@ -15,32 +15,32 @@ * */ -package router +package appInfo import ( - "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" "github.com/gorilla/mux" "go.uber.org/zap" ) -type AppRouter interface { - InitAppRouter(router *mux.Router) +type AppInfoRouter interface { + InitAppInfoRouter(router *mux.Router) } -type AppRouterImpl struct { +type AppInfoRouterImpl struct { logger *zap.SugaredLogger - handler restHandler.AppRestHandler + handler appInfo.AppInfoRestHandler } -func NewAppRouterImpl(logger *zap.SugaredLogger, handler restHandler.AppRestHandler) *AppRouterImpl { - router := &AppRouterImpl{ +func NewAppInfoRouterImpl(logger *zap.SugaredLogger, handler appInfo.AppInfoRestHandler) *AppInfoRouterImpl { + router := &AppInfoRouterImpl{ logger: logger, handler: handler, } return router } -func (router AppRouterImpl) InitAppRouter(appRouter *mux.Router) { +func (router AppInfoRouterImpl) InitAppInfoRouter(appRouter *mux.Router) { appRouter.Path("/labels/list"). HandlerFunc(router.handler.GetAllLabels).Methods("GET") appRouter.Path("/meta/info/{appId}"). diff --git a/api/router/app/appList/AppFilteringRouter.go b/api/router/app/appList/AppFilteringRouter.go new file mode 100644 index 0000000000..3e56c0a74f --- /dev/null +++ b/api/router/app/appList/AppFilteringRouter.go @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package appList + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/appList" + "github.com/gorilla/mux" +) + +type AppFilteringRouter interface { + InitAppFilteringRouter(helmRouter *mux.Router) +} + +type AppFilteringRouterImpl struct { + appFilteringRestHandler appList.AppFilteringRestHandler +} + +func NewAppFilteringRouterImpl(appFilteringRestHandler appList.AppFilteringRestHandler) *AppFilteringRouterImpl { + router := &AppFilteringRouterImpl{ + appFilteringRestHandler: appFilteringRestHandler, + } + return router +} + +func (router AppFilteringRouterImpl) InitAppFilteringRouter(AppFilteringRouter *mux.Router) { + AppFilteringRouter.Path("/autocomplete"). + HandlerFunc(router.appFilteringRestHandler.GetClusterTeamAndEnvListForAutocomplete).Methods("GET") +} diff --git a/api/router/app/appList/AppListingRouter.go b/api/router/app/appList/AppListingRouter.go new file mode 100644 index 0000000000..2f5590ead1 --- /dev/null +++ b/api/router/app/appList/AppListingRouter.go @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package appList + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/appList" + "github.com/gorilla/mux" +) + +type AppListingRouter interface { + InitAppListingRouter(helmRouter *mux.Router) +} + +type AppListingRouterImpl struct { + appListingRestHandler appList.AppListingRestHandler +} + +func NewAppListingRouterImpl(appListingRestHandler appList.AppListingRestHandler) *AppListingRouterImpl { + router := &AppListingRouterImpl{ + appListingRestHandler: appListingRestHandler, + } + return router +} + +func (router AppListingRouterImpl) InitAppListingRouter(appListingRouter *mux.Router) { + + appListingRouter.Path(""). + HandlerFunc(router.appListingRestHandler.FetchAppsByEnvironment). + Methods("POST") + + appListingRouter.Path("/{version}"). + HandlerFunc(router.appListingRestHandler.FetchAppsByEnvironmentVersioned). + Methods("POST") + + appListingRouter.Path("/group/{env-id}"). + Queries("size", "{size}", "offset", "{offset}"). + HandlerFunc(router.appListingRestHandler.FetchOverviewAppsByEnvironment). + Methods("GET") +} diff --git a/api/router/app/pipeline/DevtronAppAutoCompleteRouter.go b/api/router/app/pipeline/DevtronAppAutoCompleteRouter.go new file mode 100644 index 0000000000..2b4a8f49b0 --- /dev/null +++ b/api/router/app/pipeline/DevtronAppAutoCompleteRouter.go @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package pipeline + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline" + "github.com/gorilla/mux" +) + +type DevtronAppAutoCompleteRouter interface { + InitDevtronAppAutoCompleteRouter(configRouter *mux.Router) +} +type DevtronAppAutoCompleteRouterImpl struct { + devtronAppAutoCompleteRestHandler pipeline.DevtronAppAutoCompleteRestHandler +} + +func NewDevtronAppAutoCompleteRouterImpl( + devtronAppAutoCompleteRestHandler pipeline.DevtronAppAutoCompleteRestHandler, +) *DevtronAppAutoCompleteRouterImpl { + return &DevtronAppAutoCompleteRouterImpl{ + devtronAppAutoCompleteRestHandler: devtronAppAutoCompleteRestHandler, + } +} + +func (router DevtronAppAutoCompleteRouterImpl) InitDevtronAppAutoCompleteRouter(configRouter *mux.Router) { + configRouter.Path("/autocomplete").HandlerFunc(router.devtronAppAutoCompleteRestHandler.GetAppListForAutocomplete).Methods("GET") + configRouter.Path("/{appId}/autocomplete/environment").HandlerFunc(router.devtronAppAutoCompleteRestHandler.EnvironmentListAutocomplete).Methods("GET") + configRouter.Path("/{appId}/autocomplete/git").HandlerFunc(router.devtronAppAutoCompleteRestHandler.GitListAutocomplete).Methods("GET") + configRouter.Path("/{appId}/autocomplete/docker").HandlerFunc(router.devtronAppAutoCompleteRestHandler.RegistriesListAutocomplete).Methods("GET") + configRouter.Path("/{appId}/autocomplete/team").HandlerFunc(router.devtronAppAutoCompleteRestHandler.TeamListAutocomplete).Methods("GET") +} diff --git a/api/router/PipelineConfigRouter.go b/api/router/app/pipeline/configure/PipelineConfigRouter.go similarity index 73% rename from api/router/PipelineConfigRouter.go rename to api/router/app/pipeline/configure/PipelineConfigRouter.go index 17ed897e73..be69e3fbfd 100644 --- a/api/router/PipelineConfigRouter.go +++ b/api/router/app/pipeline/configure/PipelineConfigRouter.go @@ -15,40 +15,31 @@ * */ -package router +package configure import ( - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook" "github.com/gorilla/mux" ) type PipelineConfigRouter interface { - initPipelineConfigRouter(configRouter *mux.Router) + InitPipelineConfigRouter(configRouter *mux.Router) } type PipelineConfigRouterImpl struct { - restHandler app.PipelineConfigRestHandler - appWorkflowRestHandler restHandler.AppWorkflowRestHandler - webhookDataRestHandler restHandler.WebhookDataRestHandler - pipelineHistoryRestHandler restHandler.PipelineHistoryRestHandler - pipelineStatusTimelineRestHandler restHandler.PipelineStatusTimelineRestHandler + restHandler configure.PipelineConfigRestHandler + webhookDataRestHandler webhook.WebhookDataRestHandler } -func NewPipelineRouterImpl(restHandler app.PipelineConfigRestHandler, - appWorkflowRestHandler restHandler.AppWorkflowRestHandler, - webhookDataRestHandler restHandler.WebhookDataRestHandler, - pipelineHistoryRestHandler restHandler.PipelineHistoryRestHandler, - pipelineStatusTimelineRestHandler restHandler.PipelineStatusTimelineRestHandler) *PipelineConfigRouterImpl { +func NewPipelineRouterImpl(restHandler configure.PipelineConfigRestHandler, + webhookDataRestHandler webhook.WebhookDataRestHandler) *PipelineConfigRouterImpl { return &PipelineConfigRouterImpl{ - restHandler: restHandler, - appWorkflowRestHandler: appWorkflowRestHandler, - webhookDataRestHandler: webhookDataRestHandler, - pipelineHistoryRestHandler: pipelineHistoryRestHandler, - pipelineStatusTimelineRestHandler: pipelineStatusTimelineRestHandler, + restHandler: restHandler, + webhookDataRestHandler: webhookDataRestHandler, } } -func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mux.Router) { +func (router PipelineConfigRouterImpl) InitPipelineConfigRouter(configRouter *mux.Router) { configRouter.Path("").HandlerFunc(router.restHandler.CreateApp).Methods("POST") configRouter.Path("/{appId}").HandlerFunc(router.restHandler.DeleteApp).Methods("DELETE") configRouter.Path("/delete/{appId}/{envId}/non-cascade").HandlerFunc(router.restHandler.DeleteACDAppWithNonCascade).Methods("DELETE") @@ -56,7 +47,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/material").HandlerFunc(router.restHandler.UpdateMaterial).Methods("PUT") configRouter.Path("/material/delete").HandlerFunc(router.restHandler.DeleteMaterial).Methods("DELETE") configRouter.Path("/get/{appId}").HandlerFunc(router.restHandler.GetApp).Methods("GET") - configRouter.Path("/autocomplete").HandlerFunc(router.restHandler.GetAppListForAutocomplete).Methods("GET") //Deprecated configRouter.Path("/template/{appId}/default/{chartRefId}").HandlerFunc(router.restHandler.GetAppOverrideForDefaultTemplate).Methods("GET") @@ -116,11 +106,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/ci-pipeline/{pipelineId}/workflow/{workflowId}").HandlerFunc(router.restHandler.CancelWorkflow).Methods("DELETE") configRouter.Path("/cd-pipeline/{pipelineId}/workflowRunner/{workflowRunnerId}").HandlerFunc(router.restHandler.CancelStage).Methods("DELETE") - configRouter.Path("/{appId}/autocomplete/environment").HandlerFunc(router.restHandler.EnvironmentListAutocomplete).Methods("GET") - configRouter.Path("/{appId}/autocomplete/git").HandlerFunc(router.restHandler.GitListAutocomplete).Methods("GET") - configRouter.Path("/{appId}/autocomplete/docker").HandlerFunc(router.restHandler.RegistriesListAutocomplete).Methods("GET") - configRouter.Path("/{appId}/autocomplete/team").HandlerFunc(router.restHandler.TeamListAutocomplete).Methods("GET") - configRouter.Path("/cd-pipeline/defaultStrategy/{appId}/{envId}").HandlerFunc(router.restHandler.GetDefaultDeploymentPipelineStrategy).Methods("GET") configRouter.Path("/cd-pipeline/{appId}/{envId}/{pipelineId}").HandlerFunc(router.restHandler.IsReadyToTrigger).Methods("GET") configRouter.Path("/cd-pipeline/strategies/{appId}").HandlerFunc(router.restHandler.GetDeploymentPipelineStrategy).Methods("GET") @@ -130,24 +115,6 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/env/reset/{appId}/{environmentId}/{id}").HandlerFunc(router.restHandler.EnvConfigOverrideReset).Methods("DELETE") configRouter.Path("/env/namespace/{appId}/{environmentId}").HandlerFunc(router.restHandler.EnvConfigOverrideCreateNamespace).Methods("POST") - configRouter.Path("/app-wf"). - HandlerFunc(router.appWorkflowRestHandler.CreateAppWorkflow).Methods("POST") - - configRouter.Path("/app-wf/{app-id}"). - HandlerFunc(router.appWorkflowRestHandler.FindAppWorkflow).Methods("GET") - - configRouter.Path("/app-wf/view/{app-id}"). - HandlerFunc(router.appWorkflowRestHandler.GetWorkflowsViewData).Methods("GET") - - configRouter.Path("/app-wf/{app-id}/{app-wf-id}"). - HandlerFunc(router.appWorkflowRestHandler.DeleteAppWorkflow).Methods("DELETE") - - configRouter.Path("/app-wf/all"). - HandlerFunc(router.appWorkflowRestHandler.FindAllWorkflowsForApps).Methods("POST") - - configRouter.Path("/wf/all/component-names/{appId}"). - HandlerFunc(router.appWorkflowRestHandler.FindAllWorkflows).Methods("GET") - configRouter.Path("/cd-pipeline/workflow/history/{appId}/{environmentId}/{pipelineId}").HandlerFunc(router.restHandler.ListDeploymentHistory).Methods("GET") configRouter.Path("/cd-pipeline/workflow/logs/{appId}/{environmentId}/{pipelineId}/{workflowId}").HandlerFunc(router.restHandler.GetPrePostDeploymentLogs).Methods("GET") configRouter.Path("/cd-pipeline/workflow/trigger-info/{appId}/{environmentId}/{pipelineId}/{workflowRunnerId}").HandlerFunc(router.restHandler.FetchCdWorkflowDetails).Methods("GET") @@ -170,29 +137,8 @@ func (router PipelineConfigRouterImpl) initPipelineConfigRouter(configRouter *mu configRouter.Path("/pipeline/suggest/{type}/{appId}"). HandlerFunc(router.restHandler.PipelineNameSuggestion).Methods("GET") - configRouter.Path("/history/deployed-configuration/{appId}/{pipelineId}/{wfrId}"). - HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedConfigurationsForWorkflow). - Methods("GET") - - configRouter.Path("/history/deployed-component/list/{appId}/{pipelineId}"). - HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedHistoryComponentList). - Methods("GET") - - configRouter.Path("/history/deployed-component/detail/{appId}/{pipelineId}/{id}"). - HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedHistoryComponentDetail). - Methods("GET") - - configRouter.Path("/history/deployed-configuration/latest/deployed/{appId}/{pipelineId}"). - HandlerFunc(router.pipelineHistoryRestHandler.GetAllDeployedConfigurationHistoryForLatestWfrIdForPipeline). - Methods("GET") - - configRouter.Path("/history/deployed-configuration/all/{appId}/{pipelineId}/{wfrId}"). - HandlerFunc(router.pipelineHistoryRestHandler.GetAllDeployedConfigurationHistoryForSpecificWfrIdForPipeline). - Methods("GET") - configRouter.Path("/commit-info/{ciPipelineMaterialId}/{gitHash}").HandlerFunc(router.restHandler.GetCommitMetadataForPipelineMaterial).Methods("GET") - configRouter.Path("/deployment-status/timeline/{appId}/{envId}").HandlerFunc(router.pipelineStatusTimelineRestHandler.FetchTimelines).Methods("GET") configRouter.Path("/image-tagging/{ciPipelineId}/{artifactId}").HandlerFunc(router.restHandler.CreateUpdateImageTagging).Methods("POST") configRouter.Path("/image-tagging/{ciPipelineId}/{artifactId}").HandlerFunc(router.restHandler.GetImageTaggingData).Methods("GET") } diff --git a/api/router/app/pipeline/history/PipelineHistoryRouter.go b/api/router/app/pipeline/history/PipelineHistoryRouter.go new file mode 100644 index 0000000000..74da1b2a8f --- /dev/null +++ b/api/router/app/pipeline/history/PipelineHistoryRouter.go @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package history + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history" + "github.com/gorilla/mux" +) + +type PipelineHistoryRouter interface { + InitPipelineHistoryRouter(appRouter *mux.Router) +} +type PipelineHistoryRouterImpl struct { + pipelineHistoryRestHandler history.PipelineHistoryRestHandler +} + +func NewPipelineHistoryRouterImpl(pipelineHistoryRestHandler history.PipelineHistoryRestHandler) *PipelineHistoryRouterImpl { + return &PipelineHistoryRouterImpl{ + pipelineHistoryRestHandler: pipelineHistoryRestHandler, + } +} + +func (router PipelineHistoryRouterImpl) InitPipelineHistoryRouter(appRouter *mux.Router) { + appRouter.Path("/deployed-configuration/{appId}/{pipelineId}/{wfrId}"). + HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedConfigurationsForWorkflow). + Methods("GET") + + appRouter.Path("/deployed-component/list/{appId}/{pipelineId}"). + HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedHistoryComponentList). + Methods("GET") + + appRouter.Path("/deployed-component/detail/{appId}/{pipelineId}/{id}"). + HandlerFunc(router.pipelineHistoryRestHandler.FetchDeployedHistoryComponentDetail). + Methods("GET") + + appRouter.Path("/deployed-configuration/latest/deployed/{appId}/{pipelineId}"). + HandlerFunc(router.pipelineHistoryRestHandler.GetAllDeployedConfigurationHistoryForLatestWfrIdForPipeline). + Methods("GET") + + appRouter.Path("/deployed-configuration/all/{appId}/{pipelineId}/{wfrId}"). + HandlerFunc(router.pipelineHistoryRestHandler.GetAllDeployedConfigurationHistoryForSpecificWfrIdForPipeline). + Methods("GET") +} diff --git a/api/router/app/pipeline/status/PipelineStatusRouter.go b/api/router/app/pipeline/status/PipelineStatusRouter.go new file mode 100644 index 0000000000..cb0c84d22f --- /dev/null +++ b/api/router/app/pipeline/status/PipelineStatusRouter.go @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package status + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status" + "github.com/gorilla/mux" +) + +type PipelineStatusRouter interface { + InitPipelineStatusRouter(appRouter *mux.Router) +} +type PipelineStatusRouterImpl struct { + pipelineStatusTimelineRestHandler status.PipelineStatusTimelineRestHandler +} + +func NewPipelineStatusRouterImpl(pipelineStatusTimelineRestHandler status.PipelineStatusTimelineRestHandler) *PipelineStatusRouterImpl { + return &PipelineStatusRouterImpl{ + pipelineStatusTimelineRestHandler: pipelineStatusTimelineRestHandler, + } +} + +func (router PipelineStatusRouterImpl) InitPipelineStatusRouter(appRouter *mux.Router) { + appRouter.Path("/timeline/{appId}/{envId}"). + HandlerFunc(router.pipelineStatusTimelineRestHandler.FetchTimelines). + Methods("GET") + + appRouter.Path("/manual-sync/{appId}/{envId}"). + HandlerFunc(router.pipelineStatusTimelineRestHandler.ManualSyncAcdPipelineDeploymentStatus). + Methods("GET") +} diff --git a/api/router/PipelineTriggerRouter.go b/api/router/app/pipeline/trigger/PipelineTriggerRouter.go similarity index 86% rename from api/router/PipelineTriggerRouter.go rename to api/router/app/pipeline/trigger/PipelineTriggerRouter.go index 6d40fe9b6b..8678550185 100644 --- a/api/router/PipelineTriggerRouter.go +++ b/api/router/app/pipeline/trigger/PipelineTriggerRouter.go @@ -15,10 +15,10 @@ * */ -package router +package trigger import ( - "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger" sse2 "github.com/devtron-labs/devtron/api/sse" "github.com/gorilla/mux" "github.com/juju/errors" @@ -31,7 +31,7 @@ import ( var sse *sse2.SSE type PipelineTriggerRouter interface { - initPipelineTriggerRouter(pipelineTriggerRouter *mux.Router) + InitPipelineTriggerRouter(pipelineTriggerRouter *mux.Router) } func PollTopic(r *http.Request) (string, error) { @@ -46,17 +46,17 @@ func PollTopic(r *http.Request) (string, error) { return "/" + name, nil } -func NewPipelineTriggerRouter(pipelineRestHandler restHandler.PipelineTriggerRestHandler, sseChannel *sse2.SSE) *PipelineTriggerRouterImpl { +func NewPipelineTriggerRouter(pipelineRestHandler trigger.PipelineTriggerRestHandler, sseChannel *sse2.SSE) *PipelineTriggerRouterImpl { routerImpl := &PipelineTriggerRouterImpl{restHandler: pipelineRestHandler} sse = sseChannel return routerImpl } type PipelineTriggerRouterImpl struct { - restHandler restHandler.PipelineTriggerRestHandler + restHandler trigger.PipelineTriggerRestHandler } -func (router PipelineTriggerRouterImpl) initPipelineTriggerRouter(pipelineTriggerRouter *mux.Router) { +func (router PipelineTriggerRouterImpl) InitPipelineTriggerRouter(pipelineTriggerRouter *mux.Router) { pipelineTriggerRouter.Path("/cd-pipeline/trigger").HandlerFunc(router.restHandler.OverrideConfig).Methods("POST") pipelineTriggerRouter.Path("/update-release-status").HandlerFunc(router.restHandler.ReleaseStatusUpdate).Methods("POST") pipelineTriggerRouter.Path("/rotate-pods").HandlerFunc(router.restHandler.RotatePods).Methods("POST") diff --git a/api/router/app/workflow/AppWorkflowRouter.go b/api/router/app/workflow/AppWorkflowRouter.go new file mode 100644 index 0000000000..1bc932d04d --- /dev/null +++ b/api/router/app/workflow/AppWorkflowRouter.go @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 Devtron Labs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package workflow + +import ( + "github.com/devtron-labs/devtron/api/restHandler/app/workflow" + "github.com/gorilla/mux" +) + +type AppWorkflowRouter interface { + InitAppWorkflowRouter(appRouter *mux.Router) +} +type AppWorkflowRouterImpl struct { + appWorkflowRestHandler workflow.AppWorkflowRestHandler +} + +func NewAppWorkflowRouterImpl(appWorkflowRestHandler workflow.AppWorkflowRestHandler) *AppWorkflowRouterImpl { + return &AppWorkflowRouterImpl{ + appWorkflowRestHandler: appWorkflowRestHandler, + } +} + +func (router AppWorkflowRouterImpl) InitAppWorkflowRouter(appRouter *mux.Router) { + appRouter.Path(""). + HandlerFunc(router.appWorkflowRestHandler.CreateAppWorkflow).Methods("POST") + + appRouter.Path("/{app-id}"). + HandlerFunc(router.appWorkflowRestHandler.FindAppWorkflow).Methods("GET") + + appRouter.Path("/view/{app-id}"). + HandlerFunc(router.appWorkflowRestHandler.GetWorkflowsViewData).Methods("GET") + + appRouter.Path("/{app-id}/{app-wf-id}"). + HandlerFunc(router.appWorkflowRestHandler.DeleteAppWorkflow).Methods("DELETE") + + appRouter.Path("/all"). + HandlerFunc(router.appWorkflowRestHandler.FindAllWorkflowsForApps).Methods("POST") + + appRouter.Path("/all/component-names/{appId}"). + HandlerFunc(router.appWorkflowRestHandler.FindAllWorkflows).Methods("GET") +} diff --git a/api/router/router.go b/api/router/router.go index 58375546ce..57440bf749 100644 --- a/api/router/router.go +++ b/api/router/router.go @@ -36,6 +36,7 @@ import ( "github.com/devtron-labs/devtron/api/k8s/capacity" "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler/common" + "github.com/devtron-labs/devtron/api/router/app" "github.com/devtron-labs/devtron/api/router/pubsub" "github.com/devtron-labs/devtron/api/server" "github.com/devtron-labs/devtron/api/team" @@ -56,16 +57,11 @@ import ( type MuxRouter struct { logger *zap.SugaredLogger Router *mux.Router - HelmRouter PipelineTriggerRouter - PipelineConfigRouter PipelineConfigRouter JobRouter JobRouter EnvironmentClusterMappingsRouter cluster.EnvironmentRouter - AppListingRouter AppListingRouter ClusterRouter cluster.ClusterRouter WebHookRouter WebhookRouter UserAuthRouter user.UserAuthRouter - ApplicationRouter ApplicationRouter - CDRouter CDRouter GitProviderRouter GitProviderRouter GitHostRouter GitHostRouter DockerRegRouter DockerRegRouter @@ -99,7 +95,7 @@ type MuxRouter struct { telemetryWatcher telemetry.TelemetryEventClient bulkUpdateRouter BulkUpdateRouter WebhookListenerRouter WebhookListenerRouter - appRouter AppRouter + appRouter app.AppRouter coreAppRouter CoreAppRouter helmAppRouter client.HelmAppRouter k8sApplicationRouter application.K8sApplicationRouter @@ -124,11 +120,9 @@ type MuxRouter struct { ciTriggerCron cron.CiTriggerCron } -func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, PipelineConfigRouter PipelineConfigRouter, - AppListingRouter AppListingRouter, +func NewMuxRouter(logger *zap.SugaredLogger, EnvironmentClusterMappingsRouter cluster.EnvironmentRouter, ClusterRouter cluster.ClusterRouter, - WebHookRouter WebhookRouter, UserAuthRouter user.UserAuthRouter, ApplicationRouter ApplicationRouter, - CDRouter CDRouter, + WebHookRouter WebhookRouter, UserAuthRouter user.UserAuthRouter, GitProviderRouter GitProviderRouter, GitHostRouter GitHostRouter, DockerRegRouter DockerRegRouter, NotificationRouter NotificationRouter, @@ -141,7 +135,7 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P ReleaseMetricsRouter ReleaseMetricsRouter, deploymentGroupRouter DeploymentGroupRouter, batchOperationRouter BatchOperationRouter, chartGroupRouter chartGroup.ChartGroupRouter, imageScanRouter ImageScanRouter, policyRouter PolicyRouter, gitOpsConfigRouter GitOpsConfigRouter, dashboardRouter dashboard.DashboardRouter, attributesRouter AttributesRouter, userAttributesRouter UserAttributesRouter, - commonRouter CommonRouter, grafanaRouter GrafanaRouter, ssoLoginRouter sso.SsoLoginRouter, telemetryRouter TelemetryRouter, telemetryWatcher telemetry.TelemetryEventClient, bulkUpdateRouter BulkUpdateRouter, webhookListenerRouter WebhookListenerRouter, appRouter AppRouter, + commonRouter CommonRouter, grafanaRouter GrafanaRouter, ssoLoginRouter sso.SsoLoginRouter, telemetryRouter TelemetryRouter, telemetryWatcher telemetry.TelemetryEventClient, bulkUpdateRouter BulkUpdateRouter, webhookListenerRouter WebhookListenerRouter, appRouter app.AppRouter, coreAppRouter CoreAppRouter, helmAppRouter client.HelmAppRouter, k8sApplicationRouter application.K8sApplicationRouter, pProfRouter PProfRouter, deploymentConfigRouter deployment.DeploymentConfigRouter, dashboardTelemetryRouter dashboardEvent.DashboardTelemetryRouter, commonDeploymentRouter appStoreDeployment.CommonDeploymentRouter, externalLinkRouter externalLink.ExternalLinkRouter, @@ -157,15 +151,10 @@ func NewMuxRouter(logger *zap.SugaredLogger, HelmRouter PipelineTriggerRouter, P proxyRouter proxy.ProxyRouter) *MuxRouter { r := &MuxRouter{ Router: mux.NewRouter(), - HelmRouter: HelmRouter, - PipelineConfigRouter: PipelineConfigRouter, EnvironmentClusterMappingsRouter: EnvironmentClusterMappingsRouter, - AppListingRouter: AppListingRouter, ClusterRouter: ClusterRouter, WebHookRouter: WebHookRouter, UserAuthRouter: UserAuthRouter, - ApplicationRouter: ApplicationRouter, - CDRouter: CDRouter, DockerRegRouter: DockerRegRouter, GitProviderRouter: GitProviderRouter, GitHostRouter: GitHostRouter, @@ -265,11 +254,8 @@ func (r MuxRouter) Init() { coreAppRouter := r.Router.PathPrefix("/orchestrator/core").Subrouter() r.coreAppRouter.initCoreAppRouter(coreAppRouter) - pipelineConfigRouter := r.Router.PathPrefix("/orchestrator/app").Subrouter() - r.PipelineConfigRouter.initPipelineConfigRouter(pipelineConfigRouter) - r.AppListingRouter.initAppListingRouter(pipelineConfigRouter) - r.HelmRouter.initPipelineTriggerRouter(pipelineConfigRouter) - r.appRouter.InitAppRouter(pipelineConfigRouter) + appSubRouter := r.Router.PathPrefix("/orchestrator/app").Subrouter() + r.appRouter.InitAppRouter(appSubRouter) jobConfigRouter := r.Router.PathPrefix("/orchestrator/job").Subrouter() r.JobRouter.InitJobRouter(jobConfigRouter) @@ -284,9 +270,6 @@ func (r MuxRouter) Init() { webHookRouter := r.Router.PathPrefix("/orchestrator/webhook").Subrouter() r.WebHookRouter.intWebhookRouter(webHookRouter) - applicationRouter := r.Router.PathPrefix("/orchestrator/api/v1/applications").Subrouter() - r.ApplicationRouter.initApplicationRouter(applicationRouter) - rootRouter := r.Router.PathPrefix("/orchestrator").Subrouter() r.UserAuthRouter.InitUserAuthRouter(rootRouter) diff --git a/api/util/apiHeader.go b/api/util/apiHeader.go new file mode 100644 index 0000000000..60d0f1ae08 --- /dev/null +++ b/api/util/apiHeader.go @@ -0,0 +1,10 @@ +package util + +import "net/http" + +func SetupCorsOriginHeader(w *http.ResponseWriter) { + (*w).Header().Set("Access-Control-Allow-Origin", "*") + (*w).Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + (*w).Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") + (*w).Header().Set("Content-Type", "text/html; charset=utf-8") +} diff --git a/client/argocdServer/application/Application.go b/client/argocdServer/application/Application.go index dfb9dea97b..e58eb87655 100644 --- a/client/argocdServer/application/Application.go +++ b/client/argocdServer/application/Application.go @@ -21,146 +21,53 @@ import ( "context" "encoding/json" "errors" - "fmt" - k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" - "github.com/devtron-labs/devtron/client/argocdServer/connection" - "strings" - "time" - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/argoproj/argo-cd/v2/reposerver/apiclient" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" + "github.com/devtron-labs/devtron/client/argocdServer/connection" "github.com/devtron-labs/devtron/util" "go.uber.org/zap" - "google.golang.org/grpc" - v12 "k8s.io/api/apps/v1" - v1 "k8s.io/api/core/v1" -) - -const ( - Degraded = "Degraded" - Healthy = "Healthy" - Progressing = "Progressing" - Suspended = "Suspended" - TimeoutFast = 10 * time.Second - TimeoutSlow = 30 * time.Second - TimeoutLazy = 60 * time.Second - HIBERNATING = "HIBERNATING" - SUCCEEDED = "Succeeded" ) type ServiceClient interface { - List(ctxt context.Context, query *application.ApplicationQuery) (*v1alpha1.ApplicationList, error) - PodLogs(ctxt context.Context, query *application.ApplicationPodLogsQuery) (application.ApplicationService_PodLogsClient, *grpc.ClientConn, error) - ListResourceEvents(ctx context.Context, query *application.ApplicationResourceEventsQuery) (*v1.EventList, error) - ResourceTree(ctx context.Context, query *application.ResourcesQuery) (*ResourceTreeResponse, error) - // Watch returns stream of application change events. - Watch(ctx context.Context, in *application.ApplicationQuery) (application.ApplicationService_WatchClient, *grpc.ClientConn, error) - ManagedResources(ctx context.Context, query *application.ResourcesQuery) (*application.ManagedResourcesResponse, error) - // Rollback syncs an application to its target state - Rollback(ctx context.Context, query *application.ApplicationRollbackRequest) (*v1alpha1.Application, error) - // Patch patch an application + // ResourceTree returns the status for all Apps deployed via ArgoCd + ResourceTree(ctx context.Context, query *application.ResourcesQuery) (*argoApplication.ResourceTreeResponse, error) + + // Patch an ArgoCd application Patch(ctx context.Context, query *application.ApplicationPatchRequest) (*v1alpha1.Application, error) - // GetManifests returns application manifests - GetManifests(ctx context.Context, query *application.ApplicationManifestQuery) (*apiclient.ManifestResponse, error) + // GetResource returns single application resource GetResource(ctxt context.Context, query *application.ApplicationResourceRequest) (*application.ApplicationResourceResponse, error) + // Get returns an application by name Get(ctx context.Context, query *application.ApplicationQuery) (*v1alpha1.Application, error) - // Create creates an application - Create(ctx context.Context, query *application.ApplicationCreateRequest) (*v1alpha1.Application, error) + // Update updates an application Update(ctx context.Context, query *application.ApplicationUpdateRequest) (*v1alpha1.Application, error) + // Sync syncs an application to its target state Sync(ctx context.Context, query *application.ApplicationSyncRequest) (*v1alpha1.Application, error) - // TerminateOperation terminates the currently running operation - TerminateOperation(ctx context.Context, query *application.OperationTerminateRequest) (*application.OperationTerminateResponse, error) - // PatchResource patch single application resource - PatchResource(ctx context.Context, query *application.ApplicationResourcePatchRequest) (*application.ApplicationResourceResponse, error) - // DeleteResource deletes a single application resource - DeleteResource(ctx context.Context, query *application.ApplicationResourceDeleteRequest) (*application.ApplicationResponse, error) + // Delete deletes an application Delete(ctx context.Context, query *application.ApplicationDeleteRequest) (*application.ApplicationResponse, error) } -type Result struct { - Response *application.ApplicationResourceResponse - Error error - Request *application.ApplicationResourceRequest -} - -type ResourceTreeResponse struct { - *v1alpha1.ApplicationTree - NewGenerationReplicaSets []string `json:"newGenerationReplicaSets"` - Status string `json:"status"` - RevisionHash string `json:"revisionHash"` - PodMetadata []*PodMetadata `json:"podMetadata"` - Conditions []v1alpha1.ApplicationCondition `json:"conditions"` -} - -type PodMetadata struct { - Name string `json:"name"` - UID string `json:"uid"` - Containers []*string `json:"containers"` - InitContainers []*string `json:"initContainers"` - IsNew bool `json:"isNew"` - // EphemeralContainers are set for Pod kind manifest response only - // will always contain running ephemeral containers - // +optional - EphemeralContainers []*k8sObjectUtils.EphemeralContainerData `json:"ephemeralContainers"` -} - -type Manifests struct { - rolloutManifest map[string]interface{} - deploymentManifest map[string]interface{} - replicaSetManifests []map[string]interface{} - serviceManifests []map[string]interface{} -} - type ServiceClientImpl struct { logger *zap.SugaredLogger argoCDConnectionManager connection.ArgoCDConnectionManager } func NewApplicationClientImpl( - logger *zap.SugaredLogger, argoCDConnectionManager connection.ArgoCDConnectionManager, -) *ServiceClientImpl { + logger *zap.SugaredLogger, + argoCDConnectionManager connection.ArgoCDConnectionManager) *ServiceClientImpl { return &ServiceClientImpl{ logger: logger, argoCDConnectionManager: argoCDConnectionManager, } } -func (c ServiceClientImpl) ManagedResources(ctxt context.Context, query *application.ResourcesQuery) (*application.ManagedResourcesResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.ManagedResources(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) Rollback(ctxt context.Context, query *application.ApplicationRollbackRequest) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.Rollback(ctx, query) - return resp, err -} - func (c ServiceClientImpl) Patch(ctxt context.Context, query *application.ApplicationPatchRequest) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutLazy) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutLazy) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -173,22 +80,8 @@ func (c ServiceClientImpl) Patch(ctxt context.Context, query *application.Applic return resp, err } -func (c ServiceClientImpl) GetManifests(ctxt context.Context, query *application.ApplicationManifestQuery) (*apiclient.ManifestResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.GetManifests(ctx, query) - return resp, err -} - func (c ServiceClientImpl) Get(ctxt context.Context, query *application.ApplicationQuery) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutFast) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -202,7 +95,7 @@ func (c ServiceClientImpl) Get(ctxt context.Context, query *application.Applicat } func (c ServiceClientImpl) Update(ctxt context.Context, query *application.ApplicationUpdateRequest) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutFast) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -215,25 +108,12 @@ func (c ServiceClientImpl) Update(ctxt context.Context, query *application.Appli return resp, err } -type ErrUnauthorized struct { - message string -} - -func NewErrUnauthorized(message string) *ErrUnauthorized { - return &ErrUnauthorized{ - message: message, - } -} -func (e *ErrUnauthorized) Error() string { - return e.message -} - func (c ServiceClientImpl) Sync(ctxt context.Context, query *application.ApplicationSyncRequest) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutFast) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { - return nil, NewErrUnauthorized("Unauthorized") + return nil, argoApplication.NewErrUnauthorized("Unauthorized") } conn := c.argoCDConnectionManager.GetConnection(token) defer util.Close(conn, c.logger) @@ -242,82 +122,8 @@ func (c ServiceClientImpl) Sync(ctxt context.Context, query *application.Applica return resp, err } -func (c ServiceClientImpl) TerminateOperation(ctxt context.Context, query *application.OperationTerminateRequest) (*application.OperationTerminateResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutSlow) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.TerminateOperation(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) PatchResource(ctxt context.Context, query *application.ApplicationResourcePatchRequest) (*application.ApplicationResourceResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.PatchResource(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) DeleteResource(ctxt context.Context, query *application.ApplicationResourceDeleteRequest) (*application.ApplicationResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutSlow) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.DeleteResource(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) List(ctxt context.Context, query *application.ApplicationQuery) (*v1alpha1.ApplicationList, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.List(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) PodLogs(ctx context.Context, query *application.ApplicationPodLogsQuery) (application.ApplicationService_PodLogsClient, *grpc.ClientConn, error) { - token, _ := ctx.Value("token").(string) - conn := c.argoCDConnectionManager.GetConnection(token) - //defer conn.Close() - asc := application.NewApplicationServiceClient(conn) - logs, err := asc.PodLogs(ctx, query) - return logs, conn, err -} - -func (c ServiceClientImpl) Watch(ctx context.Context, query *application.ApplicationQuery) (application.ApplicationService_WatchClient, *grpc.ClientConn, error) { - token, _ := ctx.Value("token").(string) - conn := c.argoCDConnectionManager.GetConnection(token) - //defer conn.Close() - asc := application.NewApplicationServiceClient(conn) - logs, err := asc.Watch(ctx, query) - return logs, conn, err -} - func (c ServiceClientImpl) GetResource(ctxt context.Context, query *application.ApplicationResourceRequest) (*application.ApplicationResourceResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutFast) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -330,7 +136,7 @@ func (c ServiceClientImpl) GetResource(ctxt context.Context, query *application. } func (c ServiceClientImpl) Delete(ctxt context.Context, query *application.ApplicationDeleteRequest) (*application.ApplicationResponse, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutSlow) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutSlow) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -342,37 +148,9 @@ func (c ServiceClientImpl) Delete(ctxt context.Context, query *application.Appli return asc.Delete(ctx, query) } -func (c ServiceClientImpl) ListResourceEvents(ctxt context.Context, query *application.ApplicationResourceEventsQuery) (*v1.EventList, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutFast) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.ListResourceEvents(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) Create(ctxt context.Context, query *application.ApplicationCreateRequest) (*v1alpha1.Application, error) { - ctx, cancel := context.WithTimeout(ctxt, TimeoutSlow) - defer cancel() - token, ok := ctxt.Value("token").(string) - if !ok { - return nil, errors.New("Unauthorized") - } - conn := c.argoCDConnectionManager.GetConnection(token) - defer util.Close(conn, c.logger) - asc := application.NewApplicationServiceClient(conn) - resp, err := asc.Create(ctx, query) - return resp, err -} - -func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application.ResourcesQuery) (*ResourceTreeResponse, error) { +func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application.ResourcesQuery) (*argoApplication.ResourceTreeResponse, error) { //all the apps deployed via argo are fetching status from here - ctx, cancel := context.WithTimeout(ctxt, TimeoutSlow) + ctx, cancel := context.WithTimeout(ctxt, argoApplication.TimeoutSlow) defer cancel() token, ok := ctxt.Value("token").(string) if !ok { @@ -399,7 +177,7 @@ func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application appResp, err := app.Recv() if err == nil { // https://github.com/argoproj/argo-cd/issues/11234 workaround - c.updateNodeHealthStatus(resp, appResp) + updateNodeHealthStatus(resp, appResp) status = string(appResp.Application.Status.Health.Status) hash = appResp.Application.Status.Sync.Revision @@ -414,40 +192,10 @@ func (c ServiceClientImpl) ResourceTree(ctxt context.Context, query *application } } } - return &ResourceTreeResponse{resp, newReplicaSets, status, hash, podMetadata, conditions}, err -} - -// fill the health status in node from app resources -func (c ServiceClientImpl) updateNodeHealthStatus(resp *v1alpha1.ApplicationTree, appResp *v1alpha1.ApplicationWatchEvent) { - if resp == nil || len(resp.Nodes) == 0 || appResp == nil || len(appResp.Application.Status.Resources) == 0 { - return - } - - for index, node := range resp.Nodes { - if node.Health != nil { - continue - } - for _, resource := range appResp.Application.Status.Resources { - if node.Group != resource.Group || node.Version != resource.Version || node.Kind != resource.Kind || - node.Name != resource.Name || node.Namespace != resource.Namespace { - continue - } - resourceHealth := resource.Health - if resourceHealth != nil { - node.Health = &v1alpha1.HealthStatus{ - Message: resourceHealth.Message, - Status: resourceHealth.Status, - } - // updating the element in slice - // https://medium.com/@xcoulon/3-ways-to-update-elements-in-a-slice-d5df54c9b2f8 - resp.Nodes[index] = node - } - break - } - } + return &argoApplication.ResourceTreeResponse{resp, newReplicaSets, status, hash, podMetadata, conditions}, err } -func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, responses []*Result) (podMetaData []*PodMetadata, newReplicaSets []string) { +func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, responses []*argoApplication.Result) (podMetaData []*argoApplication.PodMetadata, newReplicaSets []string) { rolloutManifests := make([]map[string]interface{}, 0) statefulSetManifest := make(map[string]interface{}) deploymentManifests := make([]map[string]interface{}, 0) @@ -520,7 +268,7 @@ func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, resp // for rollout we compare pod hash for _, rolloutManifest := range rolloutManifests { if _, ok := rolloutManifest["kind"]; ok { - newReplicaSet := c.getRolloutNewReplicaSetName(rolloutManifest, replicaSetManifests) + newReplicaSet := getRolloutNewReplicaSetName(rolloutManifest, replicaSetManifests) if len(newReplicaSet) > 0 { newReplicaSets = append(newReplicaSets, newReplicaSet) } @@ -529,7 +277,7 @@ func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, resp for _, deploymentManifest := range deploymentManifests { if _, ok := deploymentManifest["kind"]; ok { - newReplicaSet := c.getDeploymentNewReplicaSetName(deploymentManifest, replicaSetManifests) + newReplicaSet := getDeploymentNewReplicaSetName(deploymentManifest, replicaSetManifests) if len(newReplicaSet) > 0 { newReplicaSets = append(newReplicaSets, newReplicaSet) } @@ -537,15 +285,15 @@ func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, resp } if _, ok := statefulSetManifest["kind"]; ok { - newPodNames = c.getStatefulSetNewPods(statefulSetManifest, podManifests) + newPodNames = getStatefulSetNewPods(statefulSetManifest, podManifests) } if _, ok := daemonSetManifest["kind"]; ok { - newPodNames = c.getDaemonSetNewPods(daemonSetManifest, podManifests, controllerRevisionManifests) + newPodNames = getDaemonSetNewPods(daemonSetManifest, podManifests, controllerRevisionManifests) } if _, ok := jobsManifest["kind"]; ok { - newPodNames = c.getJobsNewPods(jobsManifest, podManifests) + newPodNames = getJobsNewPods(jobsManifest, podManifests) } for _, node := range resp.Nodes { @@ -565,7 +313,7 @@ func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, resp //podMetaData := make([]*PodMetadata, 0) duplicateCheck := make(map[string]bool) if len(newReplicaSets) > 0 { - results := c.buildPodMetadataFromReplicaSet(resp, newReplicaSets, replicaSetManifests) + results := buildPodMetadataFromReplicaSet(resp, newReplicaSets, replicaSetManifests) for _, meta := range results { duplicateCheck[meta.Name] = true podMetaData = append(podMetaData, meta) @@ -581,471 +329,3 @@ func (c ServiceClientImpl) buildPodMetadata(resp *v1alpha1.ApplicationTree, resp } return } - -func parseResult(resp *v1alpha1.ApplicationTree, query *application.ResourcesQuery, ctx context.Context, asc application.ApplicationServiceClient, err error, c ServiceClientImpl) []*Result { - var responses = make([]*Result, 0) - qCount := 0 - response := make(chan Result) - if err != nil || resp == nil || len(resp.Nodes) == 0 { - return responses - } - needPods := false - queryNodes := make([]v1alpha1.ResourceNode, 0) - podParents := make([]string, 0) - for _, node := range resp.Nodes { - if node.Kind == "Pod" { - for _, pr := range node.ParentRefs { - podParents = append(podParents, pr.Name) - } - } - } - for _, node := range resp.Nodes { - if node.Kind == "Rollout" || node.Kind == "Deployment" || node.Kind == "StatefulSet" || node.Kind == "DaemonSet" { - queryNodes = append(queryNodes, node) - } - if node.Kind == "ReplicaSet" { - for _, pr := range podParents { - if pr == node.Name { - queryNodes = append(queryNodes, node) - break - } - } - } - if node.Kind == "StatefulSet" || node.Kind == "DaemonSet" || node.Kind == "Workflow" { - needPods = true - } - - if node.Kind == "CronJob" || node.Kind == "Job" { - queryNodes = append(queryNodes, node) - needPods = true - } - } - - c.logger.Debugw("needPods", "pods", needPods) - - if needPods { - for _, node := range resp.Nodes { - if node.Kind == "Pod" { - queryNodes = append(queryNodes, node) - } - } - } - - relevantCR := make(map[string]bool) - for _, node := range resp.Nodes { - prefix := "" - if len(node.ParentRefs) > 0 { - for _, p := range node.ParentRefs { - if p.Kind == "DaemonSet" { - prefix = p.Name - } - } - } - if node.Kind == "Pod" { - relevantCR[prefix+"-"+node.NetworkingInfo.Labels["controller-revision-hash"]] = true - } - } - - for _, node := range resp.Nodes { - if node.Kind == "ControllerRevision" { - if ok := relevantCR[node.Name]; ok { - queryNodes = append(queryNodes, node) - } - } - } - - for _, node := range queryNodes { - rQuery := transform(node, query.ApplicationName) - qCount++ - go func(request application.ApplicationResourceRequest) { - ctx, cancel := context.WithTimeout(ctx, 60*time.Second) - defer cancel() - startTime := time.Now() - res, err := asc.GetResource(ctx, &request) - if err != nil { - c.logger.Errorw("GRPC_GET_RESOURCE", "data", request, "timeTaken", time.Since(startTime), "err", err) - } else { - c.logger.Debugw("GRPC_GET_RESOURCE", "data", request, "timeTaken", time.Since(startTime)) - } - if res != nil || err != nil { - response <- Result{Response: res, Error: err, Request: &request} - } else { - response <- Result{Response: nil, Error: fmt.Errorf("connection closed by client"), Request: &request} - } - }(*rQuery) - } - - if qCount == 0 { - return responses - } - - rCount := 0 - for { - select { - case msg, ok := <-response: - if ok { - if msg.Error == nil { - responses = append(responses, &msg) - } - } - rCount++ - } - if qCount == rCount { - break - } - } - return responses -} - -func (c ServiceClientImpl) getDeploymentNewReplicaSetName(deploymentManifest map[string]interface{}, replicaSetManifests []map[string]interface{}) (newReplicaSet string) { - d, err := json.Marshal(deploymentManifest) - if err != nil { - return - } - deployment := &v12.Deployment{} - err = json.Unmarshal(d, deployment) - if err != nil { - return - } - dPodHash := util.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) - for _, rs := range replicaSetManifests { - r, err := json.Marshal(rs) - if err != nil { - return - } - replicaset := &v12.ReplicaSet{} - err = json.Unmarshal(r, replicaset) - if err != nil { - continue - } - rsCopy := replicaset.Spec.DeepCopy() - labels := make(map[string]string) - for k, v := range rsCopy.Template.Labels { - if k != "pod-template-hash" { - labels[k] = v - } - } - rsCopy.Template.Labels = labels - podHash := util.ComputeHash(&rsCopy.Template, deployment.Status.CollisionCount) - if podHash == dPodHash { - newReplicaSet = getResourceName(rs) - } - } - return -} - -func (c ServiceClientImpl) getDaemonSetNewPods(daemonSetManifest map[string]interface{}, podManifests []map[string]interface{}, controllerRevisionManifests []map[string]interface{}) (newPodNames map[string]bool) { - d, err := json.Marshal(daemonSetManifest) - if err != nil { - return - } - daemonSet := &v12.DaemonSet{} - err = json.Unmarshal(d, daemonSet) - if err != nil { - return - } - latestRevision := "" - latestGen := 0 - newPodNames = make(map[string]bool, 0) - for _, crm := range controllerRevisionManifests { - rev := int(crm["revision"].(float64)) - if latestGen < rev { - latestGen = rev - latestRevision = getDaemonSetPodControllerRevisionHash(crm) - } - } - for _, pod := range podManifests { - podRevision := getDaemonSetPodControllerRevisionHash(pod) - if latestRevision == podRevision { - newPodNames[getResourceName(pod)] = true - } - } - return -} - -func getDaemonSetPodControllerRevisionHash(pod map[string]interface{}) string { - if md, ok := pod["metadata"]; ok { - if mdm, ok := md.(map[string]interface{}); ok { - if l, ok := mdm["labels"]; ok { - if lm, ok := l.(map[string]interface{}); ok { - if h, ok := lm["controller-revision-hash"]; ok { - if hs, ok := h.(string); ok { - return hs - } - } - } - } - } - } - return "" -} - -func (c ServiceClientImpl) getStatefulSetNewPods(statefulSetManifest map[string]interface{}, podManifests []map[string]interface{}) (newPodNames map[string]bool) { - newPodNames = make(map[string]bool, 0) - updateRevision := getStatefulSetUpdateRevision(statefulSetManifest) - for _, pod := range podManifests { - podRevision := getStatefulSetPodControllerRevisionHash(pod) - if updateRevision == podRevision { - newPodNames[getResourceName(pod)] = true - } - } - return -} - -func getStatefulSetUpdateRevision(statefulSet map[string]interface{}) string { - if s, ok := statefulSet["status"]; ok { - if sm, ok := s.(map[string]interface{}); ok { - if cph, ok := sm["updateRevision"]; ok { - if cphs, ok := cph.(string); ok { - return cphs - } - } - } - } - return "" -} - -func getStatefulSetPodControllerRevisionHash(pod map[string]interface{}) string { - if md, ok := pod["metadata"]; ok { - if mdm, ok := md.(map[string]interface{}); ok { - if l, ok := mdm["labels"]; ok { - if lm, ok := l.(map[string]interface{}); ok { - if h, ok := lm["controller-revision-hash"]; ok { - if hs, ok := h.(string); ok { - return hs - } - } - } - } - } - } - return "" -} - -func (c ServiceClientImpl) getRolloutNewReplicaSetName(rManifest map[string]interface{}, replicaSetManifests []map[string]interface{}) (newReplicaSet string) { - rPodHash := getRolloutPodHash(rManifest) - for _, rs := range replicaSetManifests { - podHash := getRolloutPodTemplateHash(rs) - if podHash == rPodHash { - newReplicaSet = getResourceName(rs) - } - } - return newReplicaSet -} - -func getRolloutPodHash(rollout map[string]interface{}) string { - if s, ok := rollout["status"]; ok { - if sm, ok := s.(map[string]interface{}); ok { - if cph, ok := sm["currentPodHash"]; ok { - if cphs, ok := cph.(string); ok { - return cphs - } - } - } - } - return "" -} - -func getRolloutPodTemplateHash(pod map[string]interface{}) string { - if md, ok := pod["metadata"]; ok { - if mdm, ok := md.(map[string]interface{}); ok { - if l, ok := mdm["labels"]; ok { - if lm, ok := l.(map[string]interface{}); ok { - if h, ok := lm["rollouts-pod-template-hash"]; ok { - if hs, ok := h.(string); ok { - return hs - } - } - } - } - } - } - return "" -} - -func buildPodMetadataFromPod(resp *v1alpha1.ApplicationTree, podManifests []map[string]interface{}, newPodNames map[string]bool) (podMetadata []*PodMetadata) { - containerMapping := make(map[string][]*string) - initContainerMapping := make(map[string][]*string) - for _, pod := range podManifests { - containerMapping[getResourceName(pod)] = getPodContainers(pod) - } - - for _, pod := range podManifests { - initContainerMapping[getResourceName(pod)] = getPodInitContainers(pod) - } - - for _, node := range resp.Nodes { - if node.Kind == "Pod" { - isNew := newPodNames[node.Name] - metadata := PodMetadata{Name: node.Name, UID: node.UID, Containers: containerMapping[node.Name], InitContainers: initContainerMapping[node.Name], IsNew: isNew} - podMetadata = append(podMetadata, &metadata) - } - } - return -} - -func contains(elems []string, v string) bool { - for _, s := range elems { - if strings.HasPrefix(v, s) { - return true - } - } - return false -} - -func getPodContainers(resource map[string]interface{}) []*string { - containers := make([]*string, 0) - if s, ok := resource["spec"]; ok { - if sm, ok := s.(map[string]interface{}); ok { - if c, ok := sm["containers"]; ok { - if cas, ok := c.([]interface{}); ok { - for _, ca := range cas { - if cam, ok := ca.(map[string]interface{}); ok { - if n, ok := cam["name"]; ok { - if cn, ok := n.(string); ok { - containers = append(containers, &cn) - } - } - } - } - } - } - } - } - return containers -} -func getPodInitContainers(resource map[string]interface{}) []*string { - containers := make([]*string, 0) - if s, ok := resource["spec"]; ok { - if sm, ok := s.(map[string]interface{}); ok { - if c, ok := sm["initContainers"]; ok { - if cas, ok := c.([]interface{}); ok { - for _, ca := range cas { - if cam, ok := ca.(map[string]interface{}); ok { - if n, ok := cam["name"]; ok { - if cn, ok := n.(string); ok { - containers = append(containers, &cn) - } - } - } - } - } - } - } - } - return containers -} - -func (c ServiceClientImpl) buildPodMetadataFromReplicaSet(resp *v1alpha1.ApplicationTree, newReplicaSets []string, replicaSetManifests []map[string]interface{}) (podMetadata []*PodMetadata) { - replicaSets := make(map[string]map[string]interface{}) - for _, replicaSet := range replicaSetManifests { - replicaSets[getResourceName(replicaSet)] = replicaSet - } - for _, node := range resp.Nodes { - if node.Kind == "Pod" { - parentName := "" - for _, p := range node.ParentRefs { - if p.Kind == "ReplicaSet" { - parentName = p.Name - } - } - if parentName != "" { - isNew := false - for _, newReplicaSet := range newReplicaSets { - if parentName == newReplicaSet { - isNew = true - break - } - } - replicaSet := replicaSets[parentName] - containers, intContainers := getReplicaSetContainers(replicaSet) - metadata := PodMetadata{Name: node.Name, UID: node.UID, Containers: containers, InitContainers: intContainers, IsNew: isNew} - podMetadata = append(podMetadata, &metadata) - } - } - } - return -} - -func getReplicaSetContainers(resource map[string]interface{}) (containers []*string, intContainers []*string) { - if s, ok := resource["spec"]; ok { - if sm, ok := s.(map[string]interface{}); ok { - if t, ok := sm["template"]; ok { - if tm, ok := t.(map[string]interface{}); ok { - if tms, ok := tm["spec"]; ok { - if tmsm, ok := tms.(map[string]interface{}); ok { - if c, ok := tmsm["containers"]; ok { - if cas, ok := c.([]interface{}); ok { - for _, ca := range cas { - if cam, ok := ca.(map[string]interface{}); ok { - if n, ok := cam["name"]; ok { - if cn, ok := n.(string); ok { - containers = append(containers, &cn) - } - } - } - } - } - } - ///initContainers.name - if c, ok := tmsm["initContainers"]; ok { - if cas, ok := c.([]interface{}); ok { - for _, ca := range cas { - if cam, ok := ca.(map[string]interface{}); ok { - if n, ok := cam["name"]; ok { - if cn, ok := n.(string); ok { - intContainers = append(intContainers, &cn) - } - } - } - } - } - } - } - } - } - } - } - } - return containers, intContainers -} - -func getResourceName(resource map[string]interface{}) string { - if md, ok := resource["metadata"]; ok { - if mdm, ok := md.(map[string]interface{}); ok { - if h, ok := mdm["name"]; ok { - if hs, ok := h.(string); ok { - return hs - } - } - } - } - return "" -} - -func transform(resource v1alpha1.ResourceNode, name *string) *application.ApplicationResourceRequest { - resourceName := resource.Name - kind := resource.Kind - group := resource.Group - version := resource.Version - namespace := resource.Namespace - request := &application.ApplicationResourceRequest{ - Name: name, - ResourceName: &resourceName, - Kind: &kind, - Group: &group, - Version: &version, - Namespace: &namespace, - } - return request -} - -func (c ServiceClientImpl) getJobsNewPods(jobManifest map[string]interface{}, podManifests []map[string]interface{}) (newPodNames map[string]bool) { - newPodNames = make(map[string]bool, 0) - for _, pod := range podManifests { - newPodNames[getResourceName(pod)] = true - } - - //TODO - new or old logic - return -} diff --git a/client/argocdServer/application/ApplicationUtil.go b/client/argocdServer/application/ApplicationUtil.go new file mode 100644 index 0000000000..cbf7df2b6b --- /dev/null +++ b/client/argocdServer/application/ApplicationUtil.go @@ -0,0 +1,513 @@ +package application + +import ( + "context" + "encoding/json" + "fmt" + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" + "github.com/devtron-labs/devtron/util" + v12 "k8s.io/api/apps/v1" + "strings" + "time" +) + +// fill the health status in node from app resources +func updateNodeHealthStatus(resp *v1alpha1.ApplicationTree, appResp *v1alpha1.ApplicationWatchEvent) { + if resp == nil || len(resp.Nodes) == 0 || appResp == nil || len(appResp.Application.Status.Resources) == 0 { + return + } + + for index, node := range resp.Nodes { + if node.Health != nil { + continue + } + for _, resource := range appResp.Application.Status.Resources { + if node.Group != resource.Group || node.Version != resource.Version || node.Kind != resource.Kind || + node.Name != resource.Name || node.Namespace != resource.Namespace { + continue + } + resourceHealth := resource.Health + if resourceHealth != nil { + node.Health = &v1alpha1.HealthStatus{ + Message: resourceHealth.Message, + Status: resourceHealth.Status, + } + // updating the element in slice + // https://medium.com/@xcoulon/3-ways-to-update-elements-in-a-slice-d5df54c9b2f8 + resp.Nodes[index] = node + } + break + } + } +} + +func parseResult(resp *v1alpha1.ApplicationTree, query *application.ResourcesQuery, ctx context.Context, asc application.ApplicationServiceClient, err error, c ServiceClientImpl) []*argoApplication.Result { + var responses = make([]*argoApplication.Result, 0) + qCount := 0 + response := make(chan argoApplication.Result) + if err != nil || resp == nil || len(resp.Nodes) == 0 { + return responses + } + needPods := false + queryNodes := make([]v1alpha1.ResourceNode, 0) + podParents := make([]string, 0) + for _, node := range resp.Nodes { + if node.Kind == "Pod" { + for _, pr := range node.ParentRefs { + podParents = append(podParents, pr.Name) + } + } + } + for _, node := range resp.Nodes { + if node.Kind == "Rollout" || node.Kind == "Deployment" || node.Kind == "StatefulSet" || node.Kind == "DaemonSet" { + queryNodes = append(queryNodes, node) + } + if node.Kind == "ReplicaSet" { + for _, pr := range podParents { + if pr == node.Name { + queryNodes = append(queryNodes, node) + break + } + } + } + if node.Kind == "StatefulSet" || node.Kind == "DaemonSet" || node.Kind == "Workflow" { + needPods = true + } + + if node.Kind == "CronJob" || node.Kind == "Job" { + queryNodes = append(queryNodes, node) + needPods = true + } + } + + c.logger.Debugw("needPods", "pods", needPods) + + if needPods { + for _, node := range resp.Nodes { + if node.Kind == "Pod" { + queryNodes = append(queryNodes, node) + } + } + } + + relevantCR := make(map[string]bool) + for _, node := range resp.Nodes { + prefix := "" + if len(node.ParentRefs) > 0 { + for _, p := range node.ParentRefs { + if p.Kind == "DaemonSet" { + prefix = p.Name + } + } + } + if node.Kind == "Pod" { + relevantCR[prefix+"-"+node.NetworkingInfo.Labels["controller-revision-hash"]] = true + } + } + + for _, node := range resp.Nodes { + if node.Kind == "ControllerRevision" { + if ok := relevantCR[node.Name]; ok { + queryNodes = append(queryNodes, node) + } + } + } + + for _, node := range queryNodes { + rQuery := transform(node, query.ApplicationName) + qCount++ + go func(request application.ApplicationResourceRequest) { + ctx, cancel := context.WithTimeout(ctx, 60*time.Second) + defer cancel() + startTime := time.Now() + res, err := asc.GetResource(ctx, &request) + if err != nil { + c.logger.Errorw("GRPC_GET_RESOURCE", "data", request, "timeTaken", time.Since(startTime), "err", err) + } else { + c.logger.Debugw("GRPC_GET_RESOURCE", "data", request, "timeTaken", time.Since(startTime)) + } + if res != nil || err != nil { + response <- argoApplication.Result{Response: res, Error: err, Request: &request} + } else { + response <- argoApplication.Result{Response: nil, Error: fmt.Errorf("connection closed by client"), Request: &request} + } + }(*rQuery) + } + + if qCount == 0 { + return responses + } + + rCount := 0 + for { + select { + case msg, ok := <-response: + if ok { + if msg.Error == nil { + responses = append(responses, &msg) + } + } + rCount++ + } + if qCount == rCount { + break + } + } + return responses +} + +func getDeploymentNewReplicaSetName(deploymentManifest map[string]interface{}, replicaSetManifests []map[string]interface{}) (newReplicaSet string) { + d, err := json.Marshal(deploymentManifest) + if err != nil { + return + } + deployment := &v12.Deployment{} + err = json.Unmarshal(d, deployment) + if err != nil { + return + } + dPodHash := util.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) + for _, rs := range replicaSetManifests { + r, err := json.Marshal(rs) + if err != nil { + return + } + replicaset := &v12.ReplicaSet{} + err = json.Unmarshal(r, replicaset) + if err != nil { + continue + } + rsCopy := replicaset.Spec.DeepCopy() + labels := make(map[string]string) + for k, v := range rsCopy.Template.Labels { + if k != "pod-template-hash" { + labels[k] = v + } + } + rsCopy.Template.Labels = labels + podHash := util.ComputeHash(&rsCopy.Template, deployment.Status.CollisionCount) + if podHash == dPodHash { + newReplicaSet = getResourceName(rs) + } + } + return +} + +func getDaemonSetNewPods(daemonSetManifest map[string]interface{}, podManifests []map[string]interface{}, controllerRevisionManifests []map[string]interface{}) (newPodNames map[string]bool) { + d, err := json.Marshal(daemonSetManifest) + if err != nil { + return + } + daemonSet := &v12.DaemonSet{} + err = json.Unmarshal(d, daemonSet) + if err != nil { + return + } + latestRevision := "" + latestGen := 0 + newPodNames = make(map[string]bool, 0) + for _, crm := range controllerRevisionManifests { + rev := int(crm["revision"].(float64)) + if latestGen < rev { + latestGen = rev + latestRevision = getDaemonSetPodControllerRevisionHash(crm) + } + } + for _, pod := range podManifests { + podRevision := getDaemonSetPodControllerRevisionHash(pod) + if latestRevision == podRevision { + newPodNames[getResourceName(pod)] = true + } + } + return +} + +func getDaemonSetPodControllerRevisionHash(pod map[string]interface{}) string { + if md, ok := pod["metadata"]; ok { + if mdm, ok := md.(map[string]interface{}); ok { + if l, ok := mdm["labels"]; ok { + if lm, ok := l.(map[string]interface{}); ok { + if h, ok := lm["controller-revision-hash"]; ok { + if hs, ok := h.(string); ok { + return hs + } + } + } + } + } + } + return "" +} + +func getStatefulSetNewPods(statefulSetManifest map[string]interface{}, podManifests []map[string]interface{}) (newPodNames map[string]bool) { + newPodNames = make(map[string]bool, 0) + updateRevision := getStatefulSetUpdateRevision(statefulSetManifest) + for _, pod := range podManifests { + podRevision := getStatefulSetPodControllerRevisionHash(pod) + if updateRevision == podRevision { + newPodNames[getResourceName(pod)] = true + } + } + return +} + +func getStatefulSetUpdateRevision(statefulSet map[string]interface{}) string { + if s, ok := statefulSet["status"]; ok { + if sm, ok := s.(map[string]interface{}); ok { + if cph, ok := sm["updateRevision"]; ok { + if cphs, ok := cph.(string); ok { + return cphs + } + } + } + } + return "" +} + +func getStatefulSetPodControllerRevisionHash(pod map[string]interface{}) string { + if md, ok := pod["metadata"]; ok { + if mdm, ok := md.(map[string]interface{}); ok { + if l, ok := mdm["labels"]; ok { + if lm, ok := l.(map[string]interface{}); ok { + if h, ok := lm["controller-revision-hash"]; ok { + if hs, ok := h.(string); ok { + return hs + } + } + } + } + } + } + return "" +} + +func getRolloutNewReplicaSetName(rManifest map[string]interface{}, replicaSetManifests []map[string]interface{}) (newReplicaSet string) { + rPodHash := getRolloutPodHash(rManifest) + for _, rs := range replicaSetManifests { + podHash := getRolloutPodTemplateHash(rs) + if podHash == rPodHash { + newReplicaSet = getResourceName(rs) + } + } + return newReplicaSet +} + +func getRolloutPodHash(rollout map[string]interface{}) string { + if s, ok := rollout["status"]; ok { + if sm, ok := s.(map[string]interface{}); ok { + if cph, ok := sm["currentPodHash"]; ok { + if cphs, ok := cph.(string); ok { + return cphs + } + } + } + } + return "" +} + +func getRolloutPodTemplateHash(pod map[string]interface{}) string { + if md, ok := pod["metadata"]; ok { + if mdm, ok := md.(map[string]interface{}); ok { + if l, ok := mdm["labels"]; ok { + if lm, ok := l.(map[string]interface{}); ok { + if h, ok := lm["rollouts-pod-template-hash"]; ok { + if hs, ok := h.(string); ok { + return hs + } + } + } + } + } + } + return "" +} + +func buildPodMetadataFromPod(resp *v1alpha1.ApplicationTree, podManifests []map[string]interface{}, newPodNames map[string]bool) (podMetadata []*argoApplication.PodMetadata) { + containerMapping := make(map[string][]*string) + initContainerMapping := make(map[string][]*string) + for _, pod := range podManifests { + containerMapping[getResourceName(pod)] = getPodContainers(pod) + } + + for _, pod := range podManifests { + initContainerMapping[getResourceName(pod)] = getPodInitContainers(pod) + } + + for _, node := range resp.Nodes { + if node.Kind == "Pod" { + isNew := newPodNames[node.Name] + metadata := argoApplication.PodMetadata{Name: node.Name, UID: node.UID, Containers: containerMapping[node.Name], InitContainers: initContainerMapping[node.Name], IsNew: isNew} + podMetadata = append(podMetadata, &metadata) + } + } + return +} + +func contains(elems []string, v string) bool { + for _, s := range elems { + if strings.HasPrefix(v, s) { + return true + } + } + return false +} + +func getPodContainers(resource map[string]interface{}) []*string { + containers := make([]*string, 0) + if s, ok := resource["spec"]; ok { + if sm, ok := s.(map[string]interface{}); ok { + if c, ok := sm["containers"]; ok { + if cas, ok := c.([]interface{}); ok { + for _, ca := range cas { + if cam, ok := ca.(map[string]interface{}); ok { + if n, ok := cam["name"]; ok { + if cn, ok := n.(string); ok { + containers = append(containers, &cn) + } + } + } + } + } + } + } + } + return containers +} + +func getPodInitContainers(resource map[string]interface{}) []*string { + containers := make([]*string, 0) + if s, ok := resource["spec"]; ok { + if sm, ok := s.(map[string]interface{}); ok { + if c, ok := sm["initContainers"]; ok { + if cas, ok := c.([]interface{}); ok { + for _, ca := range cas { + if cam, ok := ca.(map[string]interface{}); ok { + if n, ok := cam["name"]; ok { + if cn, ok := n.(string); ok { + containers = append(containers, &cn) + } + } + } + } + } + } + } + } + return containers +} + +func buildPodMetadataFromReplicaSet(resp *v1alpha1.ApplicationTree, newReplicaSets []string, replicaSetManifests []map[string]interface{}) (podMetadata []*argoApplication.PodMetadata) { + replicaSets := make(map[string]map[string]interface{}) + for _, replicaSet := range replicaSetManifests { + replicaSets[getResourceName(replicaSet)] = replicaSet + } + for _, node := range resp.Nodes { + if node.Kind == "Pod" { + parentName := "" + for _, p := range node.ParentRefs { + if p.Kind == "ReplicaSet" { + parentName = p.Name + } + } + if parentName != "" { + isNew := false + for _, newReplicaSet := range newReplicaSets { + if parentName == newReplicaSet { + isNew = true + break + } + } + replicaSet := replicaSets[parentName] + containers, intContainers := getReplicaSetContainers(replicaSet) + metadata := argoApplication.PodMetadata{Name: node.Name, UID: node.UID, Containers: containers, InitContainers: intContainers, IsNew: isNew} + podMetadata = append(podMetadata, &metadata) + } + } + } + return +} + +func getReplicaSetContainers(resource map[string]interface{}) (containers []*string, intContainers []*string) { + if s, ok := resource["spec"]; ok { + if sm, ok := s.(map[string]interface{}); ok { + if t, ok := sm["template"]; ok { + if tm, ok := t.(map[string]interface{}); ok { + if tms, ok := tm["spec"]; ok { + if tmsm, ok := tms.(map[string]interface{}); ok { + if c, ok := tmsm["containers"]; ok { + if cas, ok := c.([]interface{}); ok { + for _, ca := range cas { + if cam, ok := ca.(map[string]interface{}); ok { + if n, ok := cam["name"]; ok { + if cn, ok := n.(string); ok { + containers = append(containers, &cn) + } + } + } + } + } + } + ///initContainers.name + if c, ok := tmsm["initContainers"]; ok { + if cas, ok := c.([]interface{}); ok { + for _, ca := range cas { + if cam, ok := ca.(map[string]interface{}); ok { + if n, ok := cam["name"]; ok { + if cn, ok := n.(string); ok { + intContainers = append(intContainers, &cn) + } + } + } + } + } + } + } + } + } + } + } + } + return containers, intContainers +} + +func getResourceName(resource map[string]interface{}) string { + if md, ok := resource["metadata"]; ok { + if mdm, ok := md.(map[string]interface{}); ok { + if h, ok := mdm["name"]; ok { + if hs, ok := h.(string); ok { + return hs + } + } + } + } + return "" +} + +func transform(resource v1alpha1.ResourceNode, name *string) *application.ApplicationResourceRequest { + resourceName := resource.Name + kind := resource.Kind + group := resource.Group + version := resource.Version + namespace := resource.Namespace + request := &application.ApplicationResourceRequest{ + Name: name, + ResourceName: &resourceName, + Kind: &kind, + Group: &group, + Version: &version, + Namespace: &namespace, + } + return request +} + +func getJobsNewPods(jobManifest map[string]interface{}, podManifests []map[string]interface{}) (newPodNames map[string]bool) { + newPodNames = make(map[string]bool, 0) + for _, pod := range podManifests { + newPodNames[getResourceName(pod)] = true + } + + //TODO - new or old logic + return +} diff --git a/client/argocdServer/application/Application_test.go b/client/argocdServer/application/Application_test.go index 5cab0e0001..eb2c26e726 100644 --- a/client/argocdServer/application/Application_test.go +++ b/client/argocdServer/application/Application_test.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "testing" "go.uber.org/zap" @@ -60,7 +61,7 @@ func TestServiceClientImpl_getRolloutStatus(t *testing.T) { resp: data1.respTree, }, wantNewReplicaSet: "app-deployment-9-7c797c6d54", - wantStatus: Healthy, + wantStatus: argoApplication.Healthy, }, { name: "test2", @@ -74,7 +75,7 @@ func TestServiceClientImpl_getRolloutStatus(t *testing.T) { resp: data2.respTree, }, wantNewReplicaSet: "app-deployment-9-7c797c6d54", - wantStatus: Degraded, + wantStatus: argoApplication.Degraded, }, { name: "test3", @@ -88,7 +89,7 @@ func TestServiceClientImpl_getRolloutStatus(t *testing.T) { resp: data3.respTree, }, wantNewReplicaSet: "app-deployment-9-7c797c6d54", - wantStatus: Suspended, + wantStatus: argoApplication.Suspended, }, { name: "test4", @@ -102,7 +103,7 @@ func TestServiceClientImpl_getRolloutStatus(t *testing.T) { resp: data4.respTree, }, wantNewReplicaSet: "app-deployment-9-7c797c6d54", - wantStatus: Degraded, + wantStatus: argoApplication.Degraded, }, } for _, tt := range tests { diff --git a/client/argocdServer/bean/bean.go b/client/argocdServer/bean/bean.go index 1a75a5c204..c2b3093b4f 100644 --- a/client/argocdServer/bean/bean.go +++ b/client/argocdServer/bean/bean.go @@ -1,3 +1,63 @@ package bean +import ( + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" + "time" +) + const RefreshTypeNormal = "normal" + +const ( + Degraded = "Degraded" + Healthy = "Healthy" + Progressing = "Progressing" + Suspended = "Suspended" + TimeoutFast = 10 * time.Second + TimeoutSlow = 30 * time.Second + TimeoutLazy = 60 * time.Second + HIBERNATING = "HIBERNATING" + SUCCEEDED = "Succeeded" +) + +type Result struct { + Response *application.ApplicationResourceResponse + Error error + Request *application.ApplicationResourceRequest +} + +type ResourceTreeResponse struct { + *v1alpha1.ApplicationTree + NewGenerationReplicaSets []string `json:"newGenerationReplicaSets"` + Status string `json:"status"` + RevisionHash string `json:"revisionHash"` + PodMetadata []*PodMetadata `json:"podMetadata"` + Conditions []v1alpha1.ApplicationCondition `json:"conditions"` +} + +type PodMetadata struct { + Name string `json:"name"` + UID string `json:"uid"` + Containers []*string `json:"containers"` + InitContainers []*string `json:"initContainers"` + IsNew bool `json:"isNew"` + // EphemeralContainers are set for Pod kind manifest response only + // will always contain running ephemeral containers + // +optional + EphemeralContainers []*k8sObjectsUtil.EphemeralContainerData `json:"ephemeralContainers"` +} + +type ErrUnauthorized struct { + message string +} + +func NewErrUnauthorized(message string) *ErrUnauthorized { + return &ErrUnauthorized{ + message: message, + } +} + +func (e *ErrUnauthorized) Error() string { + return e.message +} diff --git a/client/argocdServer/repository/Repository.go b/client/argocdServer/repository/Repository.go index 7b5013f3f3..c53b720e46 100644 --- a/client/argocdServer/repository/Repository.go +++ b/client/argocdServer/repository/Repository.go @@ -23,7 +23,7 @@ import ( repository2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/repository" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/argoproj/argo-cd/v2/reposerver/apiclient" - "github.com/devtron-labs/devtron/client/argocdServer/application" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/client/argocdServer/connection" "go.uber.org/zap" ) @@ -66,7 +66,7 @@ func (r ServiceClientImpl) getService(ctx context.Context) (repository2.Reposito } func (r ServiceClientImpl) List(ctx context.Context, query *repository2.RepoQuery) (*v1alpha1.RepositoryList, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutFast) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutFast) defer cancel() client, err := r.getService(ctx) if err != nil { @@ -76,7 +76,7 @@ func (r ServiceClientImpl) List(ctx context.Context, query *repository2.RepoQuer } func (r ServiceClientImpl) ListApps(ctx context.Context, query *repository2.RepoAppsQuery) (*repository2.RepoAppsResponse, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutFast) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutFast) defer cancel() client, err := r.getService(ctx) if err != nil { @@ -86,7 +86,7 @@ func (r ServiceClientImpl) ListApps(ctx context.Context, query *repository2.Repo } func (r ServiceClientImpl) GetAppDetails(ctx context.Context, query *repository2.RepoAppDetailsQuery) (*apiclient.RepoAppDetailsResponse, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutFast) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutFast) defer cancel() client, err := r.getService(ctx) if err != nil { @@ -96,7 +96,7 @@ func (r ServiceClientImpl) GetAppDetails(ctx context.Context, query *repository2 } func (r ServiceClientImpl) Create(ctx context.Context, query *repository2.RepoCreateRequest) (*v1alpha1.Repository, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutSlow) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutSlow) defer cancel() client, err := r.getService(ctx) if err != nil { @@ -106,7 +106,7 @@ func (r ServiceClientImpl) Create(ctx context.Context, query *repository2.RepoCr } func (r ServiceClientImpl) Update(ctx context.Context, query *repository2.RepoUpdateRequest) (*v1alpha1.Repository, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutSlow) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutSlow) defer cancel() client, err := r.getService(ctx) if err != nil { @@ -116,7 +116,7 @@ func (r ServiceClientImpl) Update(ctx context.Context, query *repository2.RepoUp } func (r ServiceClientImpl) Delete(ctx context.Context, query *repository2.RepoQuery) (*repository2.RepoResponse, error) { - ctx, cancel := context.WithTimeout(ctx, application.TimeoutSlow) + ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutSlow) defer cancel() client, err := r.getService(ctx) if err != nil { diff --git a/cmd/external-app/router.go b/cmd/external-app/router.go index e143987a70..d5a803d256 100644 --- a/cmd/external-app/router.go +++ b/cmd/external-app/router.go @@ -19,6 +19,7 @@ import ( "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/api/router" + "github.com/devtron-labs/devtron/api/router/app" "github.com/devtron-labs/devtron/api/server" "github.com/devtron-labs/devtron/api/team" "github.com/devtron-labs/devtron/api/terminal" @@ -61,7 +62,7 @@ type MuxRouter struct { telemetryRouter router.TelemetryRouter userTerminalAccessRouter terminal.UserTerminalAccessRouter attributesRouter router.AttributesRouter - appRouter router.AppRouter + appRouter app.AppRouterEAMode rbacRoleRouter user.RbacRoleRouter } @@ -93,7 +94,7 @@ func NewMuxRouter( telemetryRouter router.TelemetryRouter, userTerminalAccessRouter terminal.UserTerminalAccessRouter, attributesRouter router.AttributesRouter, - appRouter router.AppRouter, + appRouter app.AppRouterEAMode, rbacRoleRouter user.RbacRoleRouter, ) *MuxRouter { r := &MuxRouter{ @@ -186,8 +187,8 @@ func (r *MuxRouter) Init() { r.helmAppRouter.InitAppListRouter(HelmApplicationSubRouter) r.commonDeploymentRouter.Init(HelmApplicationSubRouter) - ApplicationSubRouter := r.Router.PathPrefix("/orchestrator/app").Subrouter() - r.appRouter.InitAppRouter(ApplicationSubRouter) + applicationSubRouter := r.Router.PathPrefix("/orchestrator/app").Subrouter() + r.appRouter.InitAppRouterEAMode(applicationSubRouter) k8sApp := r.Router.PathPrefix("/orchestrator/k8s").Subrouter() r.k8sApplicationRouter.InitK8sApplicationRouter(k8sApp) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 30acc2fa2a..b0e804d812 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -23,7 +23,12 @@ import ( "github.com/devtron-labs/devtron/api/k8s" "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + "github.com/devtron-labs/devtron/api/router/app/appList" "github.com/devtron-labs/devtron/api/server" "github.com/devtron-labs/devtron/api/team" "github.com/devtron-labs/devtron/api/terminal" @@ -102,10 +107,18 @@ func InitializeApp() (*App, error) { rbac.NewEnforcerUtilImpl, wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), - router.NewAppRouterImpl, - wire.Bind(new(router.AppRouter), new(*router.AppRouterImpl)), - restHandler.NewAppRestHandlerImpl, - wire.Bind(new(restHandler.AppRestHandler), new(*restHandler.AppRestHandlerImpl)), + appInfo2.NewAppInfoRouterImpl, + wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), + appInfo.NewAppInfoRestHandlerImpl, + wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), + + appList.NewAppFilteringRouterImpl, + wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), + appList2.NewAppFilteringRestHandlerImpl, + wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), + + app3.NewAppRouterEAModeImpl, + wire.Bind(new(app3.AppRouterEAMode), new(*app3.AppRouterEAModeImpl)), app.NewAppCrudOperationServiceImpl, wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 886d7c3835..639fb9d4de 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -31,7 +31,12 @@ import ( capacity2 "github.com/devtron-labs/devtron/api/k8s/capacity" module2 "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + "github.com/devtron-labs/devtron/api/restHandler/app/appList" "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/router/app/appList" server2 "github.com/devtron-labs/devtron/api/server" team2 "github.com/devtron-labs/devtron/api/team" terminal2 "github.com/devtron-labs/devtron/api/terminal" @@ -374,12 +379,15 @@ func InitializeApp() (*App, error) { appLabelRepositoryImpl := pipelineConfig.NewAppLabelRepositoryImpl(db) materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, materialRepositoryImpl) - appRestHandlerImpl := restHandler.NewAppRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) - appRouterImpl := router.NewAppRouterImpl(sugaredLogger, appRestHandlerImpl) + appInfoRestHandlerImpl := appInfo.NewAppInfoRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) + appInfoRouterImpl := appInfo2.NewAppInfoRouterImpl(sugaredLogger, appInfoRestHandlerImpl) + appFilteringRestHandlerImpl := appList.NewAppFilteringRestHandlerImpl(sugaredLogger, teamServiceImpl, enforcerImpl, userServiceImpl, clusterServiceImpl, environmentServiceImpl) + appFilteringRouterImpl := appList2.NewAppFilteringRouterImpl(appFilteringRestHandlerImpl) + appRouterEAModeImpl := app3.NewAppRouterEAModeImpl(appInfoRouterImpl, appFilteringRouterImpl) rbacRoleServiceImpl := user.NewRbacRoleServiceImpl(sugaredLogger, rbacRoleDataRepositoryImpl) rbacRoleRestHandlerImpl := user2.NewRbacRoleHandlerImpl(sugaredLogger, validate, rbacRoleServiceImpl, userServiceImpl, enforcerImpl, enforcerUtilImpl) rbacRoleRouterImpl := user2.NewRbacRoleRouterImpl(sugaredLogger, validate, rbacRoleRestHandlerImpl) - muxRouter := NewMuxRouter(sugaredLogger, ssoLoginRouterImpl, teamRouterImpl, userAuthRouterImpl, userRouterImpl, clusterRouterImpl, dashboardRouterImpl, helmAppRouterImpl, environmentRouterImpl, k8sApplicationRouterImpl, chartRepositoryRouterImpl, appStoreDiscoverRouterImpl, appStoreValuesRouterImpl, appStoreDeploymentRouterImpl, chartProviderRouterImpl, dockerRegRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, userAttributesRouterImpl, telemetryRouterImpl, userTerminalAccessRouterImpl, attributesRouterImpl, appRouterImpl, rbacRoleRouterImpl) + muxRouter := NewMuxRouter(sugaredLogger, ssoLoginRouterImpl, teamRouterImpl, userAuthRouterImpl, userRouterImpl, clusterRouterImpl, dashboardRouterImpl, helmAppRouterImpl, environmentRouterImpl, k8sApplicationRouterImpl, chartRepositoryRouterImpl, appStoreDiscoverRouterImpl, appStoreValuesRouterImpl, appStoreDeploymentRouterImpl, chartProviderRouterImpl, dockerRegRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, userAttributesRouterImpl, telemetryRouterImpl, userTerminalAccessRouterImpl, attributesRouterImpl, appRouterEAModeImpl, rbacRoleRouterImpl) mainApp := NewApp(db, sessionManager, muxRouter, telemetryEventClientImpl, posthogClient, sugaredLogger) return mainApp, nil } diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index ac1edd885e..bb27a8d9a8 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -81,9 +81,6 @@ type LastDeployed struct { LastDeployedImage string `sql:"last_deployed_image"` } -const NewDeployment string = "Deployment Initiated" -const Hibernating string = "HIBERNATING" - type AppListingRepositoryImpl struct { dbConnection *pg.DB Logger *zap.SugaredLogger @@ -111,6 +108,7 @@ func (impl AppListingRepositoryImpl) FetchJobs(appIds []int, statuses []string, jobContainers = impl.extractEnvironmentNameFromId(jobContainers) return jobContainers, nil } + func (impl AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*bean.JobListingContainer, error) { var jobContainers []*bean.JobListingContainer jobsQuery := impl.appListingRepositoryQueryBuilder.OverviewCiPipelineQuery() diff --git a/internal/sql/repository/chartConfig/PipelineOverrideRepository.go b/internal/sql/repository/chartConfig/PipelineOverrideRepository.go index e617efafae..81548f1a07 100644 --- a/internal/sql/repository/chartConfig/PipelineOverrideRepository.go +++ b/internal/sql/repository/chartConfig/PipelineOverrideRepository.go @@ -19,12 +19,13 @@ package chartConfig import ( "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer/application" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/sql" + deploymentStatus "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "github.com/juju/errors" "time" @@ -231,7 +232,7 @@ func (impl PipelineOverrideRepositoryImpl) FetchHelmTypePipelineOverridesForStat Join("inner join cd_workflow cdwf on cdwf.pipeline_id = p.id"). Join("inner join cd_workflow_runner cdwfr on cdwfr.cd_workflow_id = cdwf.id"). Where("p.deployment_app_type = ?", util.PIPELINE_DEPLOYMENT_TYPE_HELM). - Where("cdwfr.status not in (?)", pg.In([]string{application.Degraded, application.HIBERNATING, application.Healthy, "Failed", "Aborted"})). + Where("cdwfr.status not in (?)", pg.In([]string{argoApplication.Degraded, argoApplication.HIBERNATING, argoApplication.Healthy, deploymentStatus.WorkflowFailed, deploymentStatus.WorkflowAborted})). Where("cdwfr.workflow_type = ?", bean.CD_WORKFLOW_TYPE_DEPLOY). Where("p.deleted = ?", false). Select() diff --git a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go b/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go index ed6be1c69f..e0f3001b19 100644 --- a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go +++ b/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go @@ -23,7 +23,7 @@ import ( "fmt" "github.com/devtron-labs/common-lib/utils/k8s/health" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer/application" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/internal/sql/repository" repository2 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" @@ -109,7 +109,7 @@ const ( WorkflowTypePost = "POST" ) -var WfrTerminalStatusList = []string{WorkflowAborted, WorkflowFailed, WorkflowSucceeded, application.HIBERNATING, string(health.HealthStatusHealthy), string(health.HealthStatusDegraded)} +var WfrTerminalStatusList = []string{WorkflowAborted, WorkflowFailed, WorkflowSucceeded, argoApplication.HIBERNATING, string(health.HealthStatusHealthy), string(health.HealthStatusDegraded)} func (a WorkflowStatus) String() string { return [...]string{"WF_UNKNOWN", "REQUEST_ACCEPTED", "ENQUEUED", "QUE_ERROR", "WF_STARTED", "DROPPED_STALE", "DEQUE_ERROR", "TRIGGER_ERROR"}[a] diff --git a/internal/util/ArgoUtil/ApplicationService.go b/internal/util/ArgoUtil/ApplicationService.go deleted file mode 100644 index 0b818a5ccd..0000000000 --- a/internal/util/ArgoUtil/ApplicationService.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import ( - "context" - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" -) - -type ApplicationService interface { - GetAll(ctx context.Context) (*v1alpha1.ApplicationList, error) - CreateApplication(appRequest *v1alpha1.Application, ctx context.Context) (appResponse *v1alpha1.Application, err error) - Delete(appName string, ctx context.Context) error -} -type ApplicationServiceImpl struct { - *ArgoSession - location string -} - -func NewApplicationServiceImpl(session *ArgoSession) *ApplicationServiceImpl { - return &ApplicationServiceImpl{ - ArgoSession: session, - location: "/api/v1/applications", - } -} - -func (impl *ApplicationServiceImpl) GetAll(ctx context.Context) (*v1alpha1.ApplicationList, error) { - res := &v1alpha1.ApplicationList{} - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: impl.location, Method: "GET"}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ApplicationServiceImpl) CreateApplication(appRequest *v1alpha1.Application, ctx context.Context) (appResponse *v1alpha1.Application, err error) { - res := &v1alpha1.Application{} - _, _, err = impl.DoRequest(&ClientRequest{ResponseBody: res, Path: impl.location, Method: "POST", RequestBody: appRequest}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ApplicationServiceImpl) Delete(appName string, ctx context.Context) error { - res := &v1alpha1.Application{} - _, _, err := impl.DoRequest(&ClientRequest{ - ResponseBody: res, - Method: "DELETE", - Path: impl.location + "/" + appName, - }) - return err -} diff --git a/internal/util/ArgoUtil/ArgoClient.go b/internal/util/ArgoUtil/ArgoClient.go deleted file mode 100644 index d6d3af4cc1..0000000000 --- a/internal/util/ArgoUtil/ArgoClient.go +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/caarlos0/env" - "go.uber.org/zap" - "io" - "io/ioutil" - "net/http" - "net/url" - "reflect" -) - -type ArgoConfig struct { - Url string `env:"ACD_URL" envDefault:""` - UserName string `env:"ACD_USER" ` - Password string `env:"ACD_PASSWORD" ` - Timeout int `env:"ACD_TIMEOUT" envDefault:"0"` // in seconds - InsecureSkipVerify bool `env:"ACD_SKIP_VERIFY" envDefault:"true"` //ignore ssl verification -} - -type ArgoSession struct { - httpClient *http.Client - logger *zap.SugaredLogger - baseUrl *url.URL -} -type StatusCode int - -func (code StatusCode) IsSuccess() bool { - return code >= 200 && code <= 299 -} - -type ClientRequest struct { - Method string - Path string - RequestBody interface{} - ResponseBody interface{} -} - -func GetArgoConfig() (*ArgoConfig, error) { - cfg := &ArgoConfig{} - err := env.Parse(cfg) - return cfg, err -} - -func (session *ArgoSession) DoRequest(clientRequest *ClientRequest) (resBody []byte, resCode *StatusCode, err error) { - if clientRequest.ResponseBody == nil { - return nil, nil, fmt.Errorf("response body cant be nil") - } - if reflect.ValueOf(clientRequest.ResponseBody).Kind() != reflect.Ptr { - return nil, nil, fmt.Errorf("responsebody non pointer") - } - rel, err := session.baseUrl.Parse(clientRequest.Path) - if err != nil { - return nil, nil, err - } - var body io.Reader - if clientRequest.RequestBody != nil { - if req, err := json.Marshal(clientRequest.RequestBody); err != nil { - return nil, nil, err - } else { - session.logger.Debugw("argo req with body", "body", string(req)) - body = bytes.NewBuffer(req) - } - - } - httpReq, err := http.NewRequest(clientRequest.Method, rel.String(), body) - if err != nil { - return nil, nil, err - } - httpRes, err := session.httpClient.Do(httpReq) - if err != nil { - return nil, nil, err - } - defer httpRes.Body.Close() - resBody, err = ioutil.ReadAll(httpRes.Body) - if err != nil { - session.logger.Errorw("error in argocd communication ", "err", err) - return nil, nil, err - } - status := StatusCode(httpRes.StatusCode) - if status.IsSuccess() { - err = json.Unmarshal(resBody, clientRequest.ResponseBody) - } else { - session.logger.Errorw("api err", "res", string(resBody)) - return resBody, &status, fmt.Errorf("res not success, code: %d ", status) - } - return resBody, &status, err -} - -func NewArgoSession(config *ArgoConfig, logger *zap.SugaredLogger) (session *ArgoSession, err error) { - /*location := "/api/v1/session" - baseUrl, err := url.Parse(config.RedirectionUrl) - if err != nil { - return nil, err - } - rel, err := baseUrl.Parse(location) - param := map[string]string{} - param["username"] = "admin" - param["password"] = "argocd-server-6cd5bcffd4-j6kcx" - paramJson, err := json.Marshal(param) - if err != nil { - return nil, err - } - req, _ := http.NewRequest("POST", rel.String(), bytes.NewBuffer(paramJson)) - transCfg := &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}, - } - cookieJar, err := cookiejar.New(nil) - if err != nil { - return nil, err - } - client := &http.Client{Transport: transCfg, Jar: cookieJar, Timeout: time.Duration(config.Timeout)} - res, err := client.Do(req) - defer res.Body.Close() - if res.StatusCode != http.StatusOK { - return nil, err - }*/ - return &ArgoSession{}, nil -} diff --git a/internal/util/ArgoUtil/ClusterService.go b/internal/util/ArgoUtil/ClusterService.go deleted file mode 100644 index bd04b5eaf2..0000000000 --- a/internal/util/ArgoUtil/ClusterService.go +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import ( - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" -) - -type ClusterService interface { - GetClusterByServer(server string) (*v1alpha1.Cluster, error) - ClusterList() (*v1alpha1.ClusterList, error) - CreateCluster(cluster v1alpha1.Cluster) (*v1alpha1.Cluster, error) - UpdateCluster(cluster v1alpha1.Cluster) (*v1alpha1.Cluster, error) - DeleteCluster(server string) (string, error) -} - -type ClusterServiceImpl struct { - *ArgoSession - id int - location string -} - -func NewClusterServiceImpl(session *ArgoSession) *ClusterServiceImpl { - return &ClusterServiceImpl{ - ArgoSession: session, - location: "/api/v1/clusters", - } -} - -func (impl *ClusterServiceImpl) GetClusterByServer(server string) (*v1alpha1.Cluster, error) { - - path := impl.location + "/" + server - res := &v1alpha1.Cluster{} - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: path, Method: "GET"}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ClusterServiceImpl) ClusterList() (*v1alpha1.ClusterList, error) { - - path := impl.location - res := &v1alpha1.ClusterList{} - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: path, Method: "GET"}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ClusterServiceImpl) CreateCluster(cluster v1alpha1.Cluster) (*v1alpha1.Cluster, error) { - - path := impl.location - res := &v1alpha1.Cluster{} - - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: path, RequestBody: cluster, Method: "POST"}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ClusterServiceImpl) UpdateCluster(cluster v1alpha1.Cluster) (*v1alpha1.Cluster, error) { - - path := impl.location + "/" + cluster.Server - res := &v1alpha1.Cluster{} - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: path, RequestBody: cluster, Method: "PUT"}) - if err != nil { - return nil, err - } - return res, nil -} - -func (impl *ClusterServiceImpl) DeleteCluster(server string) (string, error) { - res := "" - path := impl.location + "/" + server - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: &res, Path: path, Method: "DELETE"}) - if err != nil { - return "", err - } - return res, nil -} - -type CubeConfigCreate struct { - Context string `json:"context"` - InCluster bool `json:"inCluster"` - Kubeconfig string `json:"kubeconfig"` - Upsert bool `json:"upsert"` -} diff --git a/internal/util/ArgoUtil/ClusterService_test.go b/internal/util/ArgoUtil/ClusterService_test.go deleted file mode 100644 index fcefb1cc71..0000000000 --- a/internal/util/ArgoUtil/ClusterService_test.go +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import "testing" - -var clusterServiceImpl *ClusterServiceImpl - -func init() { - session, _ := GetTestClient() - clusterServiceImpl = NewClusterServiceImpl(session) -} -func TestClusterServiceImpl_DeleteCluster(t *testing.T) { - type args struct { - server string - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "abc", - args: args{server: "88888888devtron9.smartflow.k8s.local"}, - wantErr: false, - }, - // TODO: Add test cases. - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - impl := clusterServiceImpl - if _, err := impl.DeleteCluster(tt.args.server); (err != nil) != tt.wantErr { - t.Errorf("ClusterServiceImpl.DeleteCluster() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/internal/util/ArgoUtil/RepositoryService.go b/internal/util/ArgoUtil/RepositoryService.go deleted file mode 100644 index 8de7f23c99..0000000000 --- a/internal/util/ArgoUtil/RepositoryService.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - -type RepositoryService interface { - Create(repositoryRequest *v1alpha1.Repository) (repository *v1alpha1.Repository, err error) -} - -type RepositoryServiceImpl struct { - *ArgoSession - location string -} - -func NewRepositoryService(session *ArgoSession) *RepositoryServiceImpl { - return &RepositoryServiceImpl{ - ArgoSession: session, - location: "/api/v1/repositories", - } -} - -func (impl RepositoryServiceImpl) Create(repositoryRequest *v1alpha1.Repository) (repository *v1alpha1.Repository, err error) { - res := &v1alpha1.Repository{} - _, _, err = impl.DoRequest(&ClientRequest{ResponseBody: res, Path: impl.location, Method: "POST", RequestBody: repositoryRequest}) - if err != nil { - return nil, err - } - return res, nil -} diff --git a/internal/util/ArgoUtil/ResourceService.go b/internal/util/ArgoUtil/ResourceService.go deleted file mode 100644 index a8d7782fec..0000000000 --- a/internal/util/ArgoUtil/ResourceService.go +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -import ( - "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" -) - -type ResourceService interface { - FetchResourceTree(appName string) (*Items, error) - FetchPodContainerLogs(appName string, podName string, req PodContainerLogReq) (*Items, error) -} -type ResourceServiceImpl struct { - *ArgoSession - id int - location string -} - -func NewResourceServiceImpl(session *ArgoSession) *ResourceServiceImpl { - return &ResourceServiceImpl{ - ArgoSession: session, - location: "/api/v1/applications", - } -} - -func (impl *ResourceServiceImpl) FetchResourceTree(appName string) (*Items, error) { - - path := impl.location + "/" + appName + "/resource-tree" - res := &Items{} - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: res, Path: path, Method: "GET"}) - if err != nil { - return nil, err - } - //writeJsonResp(w, err, resJson, http.StatusOK) - return res, nil -} - -func (impl *ResourceServiceImpl) FetchPodContainerLogs(appName string, podName string, req PodContainerLogReq) (*Items, error) { - - path := impl.location + "/" + appName + "/pods/" + podName + "/logs" - req2 := &PodContainerLogReq{ - Namespace: "dont-use", - Container: "application", - Follow: true, - } - _, _, err := impl.DoRequest(&ClientRequest{ResponseBody: nil, Path: path, RequestBody: req2, Method: "GET"}) - if err != nil { - return nil, err - } - //writeJsonResp(w, err, resJson, http.StatusOK) - return nil, nil -} - -type Items struct { - Items []Resource `json:"items"` -} - -type Resource struct { - v1alpha1.ResourceNode `json:",inline" protobuf:"bytes,1,opt,name=resourceNode"` - //Children []v1alpha1.ResourceRef `json:"children,omitempty" protobuf:"bytes,3,opt,name=children"` -} - -type PodContainerLogReq struct { - Namespace string `json:"namespace,omitempty"` - Container string `json:"container,omitempty"` - SinceSeconds string `json:"sinceSeconds,omitempty"` - TailLines string `json:"tailLines,omitempty"` - Follow bool `json:"follow,omitempty"` -} diff --git a/internal/util/ArgoUtil/TestUtil.go b/internal/util/ArgoUtil/TestUtil.go deleted file mode 100644 index 6096348a91..0000000000 --- a/internal/util/ArgoUtil/TestUtil.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ArgoUtil - -func GetTestClient() (session *ArgoSession, err error) { - config, err := GetArgoConfig() - if err != nil { - return nil, err - } - session, err = NewArgoSession(config, nil) - return session, err -} diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 0f67f2bad0..ea5685c4eb 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -19,8 +19,8 @@ package app import ( "context" - "encoding/json" "fmt" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "net/http" "strconv" @@ -39,20 +39,15 @@ import ( "go.opentelemetry.io/otel" "golang.org/x/exp/slices" - "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/prometheus" "github.com/go-pg/pg" - "github.com/pkg/errors" - v1 "github.com/prometheus/client_golang/api/prometheus/v1" "go.uber.org/zap" ) @@ -65,25 +60,7 @@ type AppListingService interface { FetchAllDevtronManagedApps() ([]AppNameTypeIdContainer, error) FetchAppDetails(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) - PodCountByAppLabel(appLabel string, namespace string, env string, proEndpoint string) int - PodListByAppLabel(appLabel string, namespace string, env string, proEndpoint string) map[string]string - - // below 4 functions used for pod level cpu and memory usage - CpuUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string - CpuRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string - MemoryUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string - MemoryRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string - - //Currently not in use - CpuUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string - CpuRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string - MemoryUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string - MemoryRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string - - //Currently not in use (intent to fetch graph data from prometheus) - CpuUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{} - MemoryUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{} - GraphAPI(appId int, envId int) error + //------------------ FetchAppTriggerView(appId int) ([]bean.TriggerView, error) FetchAppStageStatus(appId int, appType int) ([]bean.AppStageStatus, error) @@ -100,10 +77,8 @@ type AppListingService interface { } const ( - Initiate string = "Initiate" - ScalingReplicaSetDown string = "ScalingReplicaSetDown" - APIVersionV1 string = "v1" - APIVersionV2 string = "v2" + APIVersionV1 string = "v1" + APIVersionV2 string = "v2" ) type FetchAppListingRequest struct { @@ -130,6 +105,7 @@ type AppNameTypeIdContainer struct { func (req FetchAppListingRequest) GetNamespaceClusterMapping() (namespaceClusterPair []*repository2.ClusterNamespacePair, clusterIds []int, err error) { for _, ns := range req.Namespaces { items := strings.Split(ns, "_") + // TODO refactoring: invalid condition; always false if len(items) < 1 && len(items) > 2 { return nil, nil, fmt.Errorf("invalid namespaceds") } @@ -764,7 +740,7 @@ func (impl AppListingServiceImpl) fetchACDAppStatus(fetchAppListingRequest Fetch if status == string(health.HealthStatusHealthy) { stopType := releaseMap[pipeline.Id] if stopType { - status = application2.HIBERNATING + status = argoApplication.HIBERNATING env.Status = status } } @@ -812,55 +788,6 @@ func (impl AppListingServiceImpl) fetchACDAppStatusV2(fetchAppListingRequest Fet return appEnvMapping, nil } -func (impl AppListingServiceImpl) getAppACDStatus(env bean.AppEnvironmentContainer, w http.ResponseWriter, r *http.Request, token string) (string, error) { - //not being used now - if len(env.AppName) > 0 && len(env.EnvironmentName) > 0 { - acdAppName := env.AppName + "-" + env.EnvironmentName - query := &application.ResourcesQuery{ - ApplicationName: &acdAppName, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - defer cancel() - acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken() - if err != nil { - impl.Logger.Errorw("error in getting acd token", "err", err) - return "", err - } - ctx = context.WithValue(ctx, "token", acdToken) - impl.Logger.Debugf("Getting status for app %s in env %s", env.AppId, env.EnvironmentId) - start := time.Now() - resp, err := impl.application.ResourceTree(ctx, query) - elapsed := time.Since(start) - impl.Logger.Debugf("Time elapsed %s in fetching application %s for environment %s", elapsed, env.AppId, env.EnvironmentId) - if err != nil { - impl.Logger.Errorw("error fetching resource tree", "error", err) - err = &util.ApiError{ - Code: constants.AppDetailResourceTreeNotFound, - InternalMessage: "app detail fetched, failed to get resource tree from acd", - UserMessage: "app detail fetched, failed to get resource tree from acd", - } - return "", err - } - return resp.Status, nil - } - impl.Logger.Error("invalid acd app name and env ", env.AppName, " - ", env.EnvironmentName) - return "", errors.New(AcdInvalidAppErr) -} - -// TODO: Status mapping -func (impl AppListingServiceImpl) adaptStatusForView(status string) string { - return status -} - func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) { appDetailContainer, err := impl.appListingRepository.FetchAppDetail(ctx, appId, envId) if err != nil { @@ -915,745 +842,6 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a return appDetailContainer, nil } -// Return only a integer value pod count, aggregated of all the pod inside a app -// (includes all the pods running different cd pipeline for same app) -func (impl AppListingServiceImpl) PodCountByAppLabel(appLabel string, namespace string, env string, proEndpoint string) int { - if appLabel == "" || namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return 0 - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return 0 - } - - podCountQuery := "count(kube_pod_labels{label_app='" + appLabel + "', namespace='" + namespace + "'})" - out, _, err := prometheusAPI.Query(context.Background(), podCountQuery, time.Now()) - if err != nil { - impl.Logger.Errorw("pod count query failed in prometheus:", "error", err) - return 0 - } - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("pod count data marshal failed:", "error", err) - return 0 - } - - podCount := 0 - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("pod count data unmarshal failed: ", "error", err) - return 0 - } - for _, value := range resultMap { - data := value.([]interface{}) - - for _, item := range data { - - ito := item - for k, v := range ito.(map[string]interface{}) { - if k == "value" { - vArr := v.([]interface{}) - //t := (vArr[1].(string)) - feetInt, err := strconv.Atoi(vArr[1].(string)) - if err != nil { - feetInt = 0 - impl.Logger.Errorw("casting error", "err", err) - } - podCount = feetInt - } - } - } - } - return podCount -} - -// Returns map of running pod names -func (impl AppListingServiceImpl) PodListByAppLabel(appLabel string, namespace string, env string, proEndpoint string) map[string]string { - response := make(map[string]interface{}) - podList := make(map[string]string) - resultMap := make(map[string]interface{}) - if appLabel == "" || namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return podList - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return podList - } - - podCountQuery := "kube_pod_labels{label_app='" + appLabel + "', namespace='" + namespace + "'}" - out, _, err := prometheusAPI.Query(context.Background(), podCountQuery, time.Now()) - if err != nil { - impl.Logger.Errorw("pod list query failed in prometheus:", "error", err) - return podList - } - - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("pod count data unmarshal failed:", "error", err) - return podList - } - - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("pod count data unmarshal failed:", "error", err) - return podList - } - for _, value := range resultMap { - if value != nil { - data := value.([]interface{}) - - for _, item := range data { - - ito := item - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod"].(string) - podList[key] = "1" - } - if k == "value" { - } - } - } - } - } - return podList -} - -func (impl AppListingServiceImpl) CpuUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing cpuUsageGroupByPod:") - cpuUsageMetric := make(map[string]string) - - if namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return cpuUsageMetric - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return cpuUsageMetric - } - - query := "sum(rate (container_cpu_usage_seconds_total{image!='',pod_name!='',container_name!='POD',namespace='" + namespace + "'}[1m])) by (pod_name)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in getting CpuUsageGroupByPod:", "error", err) - return cpuUsageMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal CpuUsageGroupByPod:", "error", err) - return cpuUsageMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal CpuUsageGroupByPod:", "error", err) - return cpuUsageMetric - } - - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - cpuUsageMetric[key] = "1.0" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := cpuUsageMetric[temp]; ok { - cpuUsageMetric[temp] = vArr[1].(string) - } - } - } - } - } - return cpuUsageMetric -} - -func (impl AppListingServiceImpl) CpuRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing cpuUsageGroupByPod:") - cpuRequestMetric := make(map[string]string) - - if namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return cpuRequestMetric - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return cpuRequestMetric - } - - query := "sum(kube_pod_container_resource_requests_cpu_cores{namespace='" + namespace + "'}) by (pod)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return cpuRequestMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return cpuRequestMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return cpuRequestMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - - for _, item := range data { - - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod"].(string) - cpuRequestMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := cpuRequestMetric[temp]; ok { - cpuRequestMetric[temp] = vArr[1].(string) - } - } - } - } - } - return cpuRequestMetric -} - -func (impl AppListingServiceImpl) MemoryUsageGroupByPod(namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing memoryUsageGroupByPod") - memoryUsageMetric := make(map[string]string) - - if namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return memoryUsageMetric - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return memoryUsageMetric - } - - query := "sum(container_memory_usage_bytes{container_name!='POD', container_name!='', namespace='" + namespace + "'}) by (pod_name)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return memoryUsageMetric - } - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return memoryUsageMetric - } - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return memoryUsageMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - memoryUsageMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := memoryUsageMetric[temp]; ok { - memoryUsageMetric[temp] = vArr[1].(string) - } - } - } - } - } - return memoryUsageMetric -} - -func (impl AppListingServiceImpl) MemoryRequestGroupByPod(namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing memoryRequestGroupByPod") - memoryRequestMetric := make(map[string]string) - if namespace == "" || proEndpoint == "" || env == "" { - impl.Logger.Warnw("not a complete data found for prometheus call", "missing", "AppName or namespace or prometheus url or env") - return memoryRequestMetric - } - - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return memoryRequestMetric - } - - query := "sum(kube_pod_container_resource_requests_memory_bytes{container!='POD', container!='', namespace='" + namespace + "'}) by (pod)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return memoryRequestMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return memoryRequestMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return memoryRequestMetric - } - - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod"].(string) - memoryRequestMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := memoryRequestMetric[temp]; ok { - memoryRequestMetric[temp] = vArr[1].(string) - } - } - } - } - } - return memoryRequestMetric -} - -// Deprecated: Currently not in use -func (impl AppListingServiceImpl) CpuUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing cpuUsageGroupByPod:") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - cpuUsageMetric := make(map[string]string) - - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return cpuUsageMetric - } - - query := "sum(rate(container_cpu_usage_seconds_total{image!='', pod_name='" + podName + "',container_name!='POD', namespace='" + podName + "'}[1m])) by (container_name)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return cpuUsageMetric - } - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return cpuUsageMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return cpuUsageMetric - } - - for _, value := range resultMap { - data := value.([]interface{}) - - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - cpuUsageMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := cpuUsageMetric[temp]; ok { - cpuUsageMetric[temp] = vArr[1].(string) - } - } - } - } - } - - return cpuUsageMetric -} - -// Deprecated: Currently not in use -func (impl AppListingServiceImpl) CpuRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing cpuUsageGroupByPod:") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - cpuRequestMetric := make(map[string]string) - - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return cpuRequestMetric - } - - query := "sum(kube_pod_container_resource_requests_cpu_cores{namespace='" + namespace + "',pod='" + podName + "'}) by (container)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return cpuRequestMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return cpuRequestMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return cpuRequestMetric - } - - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod"].(string) - cpuRequestMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := cpuRequestMetric[temp]; ok { - cpuRequestMetric[temp] = vArr[1].(string) - } - } - } - } - } - return cpuRequestMetric -} - -// Deprecated: Currently not in use -func (impl AppListingServiceImpl) MemoryUsageGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing memoryUsageGroupByPod") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - memoryUsageMetric := make(map[string]string) - - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return memoryUsageMetric - } - - query := "sum(container_memory_usage_bytes{container_name!='POD', container_name!='',pod_name='" + podName + "', namespace='" + namespace + "'}) by (container_name)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return memoryUsageMetric - } - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return memoryUsageMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return memoryUsageMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - memoryUsageMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := memoryUsageMetric[temp]; ok { - memoryUsageMetric[temp] = vArr[1].(string) - } - } - } - } - } - return memoryUsageMetric -} - -// Deprecated: Currently not in use -func (impl AppListingServiceImpl) MemoryRequestGroupByContainer(podName string, namespace string, env string, proEndpoint string) map[string]string { - impl.Logger.Debug("executing memoryRequestGroupByPod") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - memoryRequestMetric := make(map[string]string) - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return memoryRequestMetric - } - - query := "sum(kube_pod_container_resource_requests_memory_bytes{container!='POD', container!='',pod='" + podName + "', namespace='" + namespace + "'}) by (container)" - out, _, err := prometheusAPI.Query(context.Background(), query, time.Now()) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return memoryRequestMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return memoryRequestMetric - } - - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return memoryRequestMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod"].(string) - memoryRequestMetric[key] = "1" - temp = key - } - if k == "value" { - vArr := v.([]interface{}) - if _, ok := memoryRequestMetric[temp]; ok { - memoryRequestMetric[temp] = vArr[1].(string) - } - } - } - } - } - return memoryRequestMetric -} - -// Deprecated: Currently not in use (intent to fetch graph data from prometheus) -func (impl AppListingServiceImpl) CpuUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{} { - impl.Logger.Debug("executing CpuUsageGroupByPodGraph:") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - cpuUsageMetric := make(map[string][]interface{}) - - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return cpuUsageMetric - } - - query := "sum(rate(container_cpu_usage_seconds_total{namespace='" + namespace + "', container_name!='POD'}[1m])) by (pod_name)" - time1 := time.Now() - r1 := v1.Range{ - Start: time1.Add(-time.Hour), - End: time1, - Step: time.Minute, - } - out, _, err := prometheusAPI.QueryRange(context.Background(), query, r1) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return cpuUsageMetric - } - - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return cpuUsageMetric - } - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return cpuUsageMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - cpuUsageMetric[key] = nil - temp = key - } - if k == "values" { - vArr := v.([]interface{}) - if _, ok := cpuUsageMetric[temp]; ok { - cpuUsageMetric[temp] = vArr - } - } - } - } - } - return cpuUsageMetric -} - -// Deprecated: Currently not in use (intent to fetch graph data from prometheus) -func (impl AppListingServiceImpl) MemoryUsageGroupByPodGraph(podName string, namespace string, env string, proEndpoint string, r v1.Range) map[string][]interface{} { - impl.Logger.Debug("executing MemoryUsageGroupByPodGraph") - prometheusAPI, err := prometheus.ContextByEnv(env, proEndpoint) - memoryUsageMetric := make(map[string][]interface{}) - - if err != nil { - impl.Logger.Errorw("error in getting prometheus api client:", "error", err) - return memoryUsageMetric - } - - query := "sum(container_memory_usage_bytes{namespace='" + namespace + "', container_name!='POD', container_name!=''}) by (pod_name)" - time1 := time.Now() - r1 := v1.Range{ - Start: time1.Add(-time.Hour), - End: time1, - Step: time.Minute, - } - out, _, err := prometheusAPI.QueryRange(context.Background(), query, r1) - if err != nil { - impl.Logger.Errorw("error in prometheus query:", "error", err) - return memoryUsageMetric - } - response := make(map[string]interface{}) - response["data"] = out - resJson, err := json.Marshal(response) - if err != nil { - impl.Logger.Errorw("error in marshal:", "error", err) - return memoryUsageMetric - } - resultMap := make(map[string]interface{}) - err = json.Unmarshal([]byte(resJson), &resultMap) - if err != nil { - impl.Logger.Errorw("error in unmarshal:", "error", err) - return memoryUsageMetric - } - for _, value := range resultMap { - data := value.([]interface{}) - for _, item := range data { - ito := item - temp := "" - for k, v := range ito.(map[string]interface{}) { - if k == "metric" { - vMap := v.(map[string]interface{}) - key := vMap["pod_name"].(string) - memoryUsageMetric[key] = nil - temp = key - } - if k == "values" { - vArr := v.([]interface{}) - if _, ok := memoryUsageMetric[temp]; ok { - memoryUsageMetric[temp] = vArr - } - } - } - } - } - return memoryUsageMetric -} - -// Deprecated: Currently not in use (intent to fetch graph data from prometheus) -func (impl AppListingServiceImpl) GraphAPI(appId int, envId int) error { - impl.Logger.Debug("reached at GraphAPI:") - /* - appDetailView, err := impl.appListingRepository.FetchAppDetail(appId, envId) - if err != nil { - impl.Logger.Errorw("Exception", err) - return err - } - - //calculating cpu and memory usage percent - appLabel := appDetailView.AppName - namespace := appDetailView.Namespace - proEndpoint := appDetailView.PrometheusEndpoint - env := appDetailView.EnvironmentName - podList := impl.PodListByAppLabel(appLabel, namespace, env, proEndpoint) - - //TODO - Pod List By Label- Release - - time1 := time.Time{} - r1 := v1.Range{ - Start: time1.Add(-time.Minute), - End: time1, - Step: time.Minute, - } - podName := "prometheus-monitoring-prometheus-oper-prometheus-0" - impl.CpuUsageGroupByPodGraph(podName, namespace, env, proEndpoint, r1) - //data := impl.MemoryUsageGroupByPodGraph(podName, "monitoring", env, proEndpoint, r1) - - for fKey, _ := range podList { - fmt.Println(fKey) - } - */ - return nil -} - func (impl AppListingServiceImpl) FetchAppTriggerView(appId int) ([]bean.TriggerView, error) { return impl.appListingRepository.FetchAppTriggerView(appId) } diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index a6b137ee05..f100d4023e 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -21,6 +21,7 @@ import ( "context" "encoding/json" "fmt" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" @@ -545,7 +546,7 @@ func (impl *AppServiceImpl) UpdateDeploymentStatusForPipeline(app *v1alpha1.Appl impl.logger.Errorw("error on update cd workflow runner", "CdWorkflowId", pipelineOverride.CdWorkflowId, "app", app, "err", err) return isSucceeded, err } - if application.Healthy == app.Status.Health.Status { + if argoApplication.Healthy == app.Status.Health.Status { isSucceeded = true } return isSucceeded, nil @@ -559,7 +560,7 @@ func (impl *AppServiceImpl) UpdateDeploymentStatusForAppStore(app *v1alpha1.Appl impl.logger.Errorw("error on update installed version history", "installedVersionHistoryId", installedVersionHistoryId, "app", app, "err", err) return isSucceeded, err } - if application.Healthy == app.Status.Health.Status { + if argoApplication.Healthy == app.Status.Health.Status { isSucceeded = true } return isSucceeded, nil diff --git a/pkg/app/DeploymentEventHandler.go b/pkg/app/DeploymentEventHandler.go index adbaa688fd..c931a526b6 100644 --- a/pkg/app/DeploymentEventHandler.go +++ b/pkg/app/DeploymentEventHandler.go @@ -18,11 +18,11 @@ package app import ( + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "strings" "time" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer/application" client "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/internal/sql/repository" util "github.com/devtron-labs/devtron/util/event" @@ -71,5 +71,5 @@ func (impl *DeploymentEventHandlerImpl) BuildPayload(appName string, deploymentF } func (impl *DeploymentEventHandlerImpl) isDeploymentFailed(ds repository.DeploymentStatus) bool { - return ds.Status == application.Degraded && time.Since(ds.UpdatedOn) > 5*time.Minute + return ds.Status == argoApplication.Degraded && time.Since(ds.UpdatedOn) > 5*time.Minute } diff --git a/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go index 34d7310b20..379efe1836 100644 --- a/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go +++ b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go @@ -21,13 +21,13 @@ import ( "encoding/json" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "time" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/pkg/appStatus" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" @@ -137,7 +137,7 @@ func (impl *InstalledAppDBExtendedServiceImpl) UpdateInstalledAppVersionStatus(a impl.Logger.Errorw("error while fetching installed version history", "error", err) return isHealthy, err } - if versionHistory.Status != (application2.Healthy) { + if versionHistory.Status != (argoApplication.Healthy) { versionHistory.Status = string(application.Status.Health.Status) versionHistory.UpdatedOn = time.Now() versionHistory.UpdatedBy = 1 diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index b4fba18f20..82923c5bc4 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -11,7 +11,7 @@ import ( "github.com/devtron-labs/devtron/api/bean" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/client/argocdServer/application" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/internal/sql/models" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" @@ -1006,7 +1006,7 @@ func (impl BulkUpdateServiceImpl) BulkHibernate(request *BulkApplicationForEnvir impl.logger.Infow("application already hibernated", "app_id", pipeline.AppId) pipelineResponse := response[appKey] pipelineResponse[pipelineKey] = false - if deploymentHistory.Status == application.HIBERNATING { + if deploymentHistory.Status == argoApplication.HIBERNATING { pipelineResponse[Skipped] = "Application is already hibernated" } else { pipelineResponse[Skipped] = "Hibernation already in progress" @@ -1165,7 +1165,7 @@ func (impl BulkUpdateServiceImpl) BulkUnHibernate(request *BulkApplicationForEnv impl.logger.Infow("application already UnHibernated", "app_id", pipeline.AppId) pipelineResponse := response[appKey] pipelineResponse[pipelineKey] = false - if deploymentHistory.Status == application.Healthy { + if deploymentHistory.Status == argoApplication.Healthy { pipelineResponse[Skipped] = "Application is already un-hibernated" } else { pipelineResponse[Skipped] = "Un-hibernation already in progress" diff --git a/pkg/pipeline/AppArtifactManager.go b/pkg/pipeline/AppArtifactManager.go index 7ec6f4d57d..994143bfe4 100644 --- a/pkg/pipeline/AppArtifactManager.go +++ b/pkg/pipeline/AppArtifactManager.go @@ -18,11 +18,11 @@ package pipeline import ( + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "sort" "strings" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/sql/repository" dockerArtifactStoreRegistry "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" @@ -135,7 +135,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsForCdStage(pipelineId int, sta deploymentArtifactId = wfr.CdWorkflow.CiArtifact.Id deploymentArtifactStatus = wfr.Status } - if wfr.Status == application.Healthy || wfr.Status == application.SUCCEEDED { + if wfr.Status == argoApplication.Healthy || wfr.Status == argoApplication.SUCCEEDED { lastSuccessfulTriggerOnParent := parent && index == 0 latest := !parent && index == 0 runningOnParentCd := parentCdRunningArtifactId == wfr.CdWorkflow.CiArtifact.Id @@ -360,7 +360,7 @@ func (impl *AppArtifactManagerImpl) BuildRollbackArtifactsList(artifactListingFi totalCount := 0 //1)get current deployed artifact on this pipeline - latestWf, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(artifactListingFilterOpts.PipelineId, artifactListingFilterOpts.StageType, 1, []string{application.Healthy, application.SUCCEEDED, application.Progressing}) + latestWf, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(artifactListingFilterOpts.PipelineId, artifactListingFilterOpts.StageType, 1, []string{argoApplication.Healthy, argoApplication.SUCCEEDED, argoApplication.Progressing}) if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in getting latest workflow by pipelineId", "pipelineId", artifactListingFilterOpts.PipelineId, "currentStageType", artifactListingFilterOpts.StageType) return deployedCiArtifacts, nil, totalCount, err @@ -776,7 +776,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsList(listingFilterOpts *bean.A var ciArtifacts []*bean2.CiArtifactBean totalCount := 0 //1)get current deployed artifact on this pipeline - latestWf, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(listingFilterOpts.PipelineId, listingFilterOpts.StageType, 1, []string{application.Healthy, application.SUCCEEDED, application.Progressing}) + latestWf, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(listingFilterOpts.PipelineId, listingFilterOpts.StageType, 1, []string{argoApplication.Healthy, argoApplication.SUCCEEDED, argoApplication.Progressing}) if err != nil && err != pg.ErrNoRows { impl.logger.Errorw("error in getting latest workflow by pipelineId", "pipelineId", listingFilterOpts.PipelineId, "currentStageType", listingFilterOpts.StageType) return ciArtifacts, 0, "", totalCount, err @@ -864,7 +864,7 @@ func (impl *AppArtifactManagerImpl) BuildArtifactsForCdStageV2(listingFilterOpts artifactRunningOnParentCd := 0 if listingFilterOpts.ParentCdId > 0 { //TODO: check if we can fetch LastSuccessfulTriggerOnParent wfr along with last running wf - parentCdWfrList, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(listingFilterOpts.ParentCdId, bean.CD_WORKFLOW_TYPE_DEPLOY, 1, []string{application.Healthy, application.SUCCEEDED, application.Progressing}) + parentCdWfrList, err := impl.cdWorkflowRepository.FindArtifactByPipelineIdAndRunnerType(listingFilterOpts.ParentCdId, bean.CD_WORKFLOW_TYPE_DEPLOY, 1, []string{argoApplication.Healthy, argoApplication.SUCCEEDED, argoApplication.Progressing}) if err != nil { impl.logger.Errorw("error in getting artifact for parent cd", "parentCdPipelineId", listingFilterOpts.ParentCdId) return ciArtifacts, totalCount, err diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index bb890e832a..501834298b 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -25,6 +25,7 @@ import ( bean6 "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client2 "github.com/devtron-labs/devtron/api/helm-app/service" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" @@ -44,7 +45,6 @@ import ( util5 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/common-lib/utils/k8s/health" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/client/argocdServer/application" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" gitSensorClient "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/internal/middleware" @@ -537,7 +537,7 @@ func (impl *WorkflowDagExecutorImpl) UpdateWorkflowRunnerStatusForDeployment(app return false } - if helmInstalledDevtronApp.GetApplicationStatus() == application.Healthy { + if helmInstalledDevtronApp.GetApplicationStatus() == argoApplication.Healthy { // mark the deployment as succeed wfr.Status = pipelineConfig.WorkflowSucceeded wfr.FinishedOn = time.Now() diff --git a/pkg/prometheus/prometheus_client.go b/pkg/prometheus/prometheus_client.go deleted file mode 100644 index 341f816f37..0000000000 --- a/pkg/prometheus/prometheus_client.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2020 Devtron Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package prometheus - -import ( - "fmt" - "github.com/prometheus/client_golang/api" - "github.com/prometheus/client_golang/api/prometheus/v1" -) - -var prometheusAPI v1.API -var prometheusAPIMap map[string]v1.API - -func Context(prometheusUrl string) (v1.API, error) { - - if prometheusAPI != nil { - return prometheusAPI, nil - } - - client, err := api.NewClient(api.Config{Address: prometheusUrl}) - if err != nil { - fmt.Println("Error creating client") - fmt.Println(err) - return nil, err - } - prometheusAPI = v1.NewAPI(client) - - return prometheusAPI, nil -} - -func ContextByEnv(env string, prometheusUrl string) (v1.API, error) { - if prometheusAPIMap == nil { - prometheusAPIMap = make(map[string]v1.API) - } - if _, ok := prometheusAPIMap[env]; ok { - prometheusAPI = prometheusAPIMap[env] - } else { - client, err := api.NewClient(api.Config{Address: prometheusUrl}) - if err != nil { - fmt.Println("Error creating client") - fmt.Println(err) - return nil, err - } - prometheusAPI = v1.NewAPI(client) - prometheusAPIMap[env] = prometheusAPI - } - return prometheusAPI, nil -} diff --git a/wire_gen.go b/wire_gen.go index 1b7bb8d3e5..991b106645 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -8,7 +8,7 @@ package main import ( "github.com/devtron-labs/authenticator/apiToken" - client2 "github.com/devtron-labs/authenticator/client" + "github.com/devtron-labs/authenticator/client" "github.com/devtron-labs/authenticator/middleware" "github.com/devtron-labs/common-lib/cloud-provider-identifier" "github.com/devtron-labs/common-lib/pubsub-lib" @@ -35,9 +35,26 @@ import ( capacity2 "github.com/devtron-labs/devtron/api/k8s/capacity" module2 "github.com/devtron-labs/devtron/api/module" "github.com/devtron-labs/devtron/api/restHandler" - app3 "github.com/devtron-labs/devtron/api/restHandler/app" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + "github.com/devtron-labs/devtron/api/restHandler/app/appList" + pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" + history2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history" + status2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook" + "github.com/devtron-labs/devtron/api/restHandler/app/workflow" "github.com/devtron-labs/devtron/api/restHandler/scopedVariable" "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/router/app/appList" + pipeline3 "github.com/devtron-labs/devtron/api/router/app/pipeline" + configure2 "github.com/devtron-labs/devtron/api/router/app/pipeline/configure" + history3 "github.com/devtron-labs/devtron/api/router/app/pipeline/history" + status3 "github.com/devtron-labs/devtron/api/router/app/pipeline/status" + trigger2 "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger" + workflow2 "github.com/devtron-labs/devtron/api/router/app/workflow" "github.com/devtron-labs/devtron/api/router/pubsub" server2 "github.com/devtron-labs/devtron/api/server" "github.com/devtron-labs/devtron/api/sse" @@ -49,16 +66,16 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/argocdServer/cluster" "github.com/devtron-labs/devtron/client/argocdServer/connection" - repository13 "github.com/devtron-labs/devtron/client/argocdServer/repository" + repository14 "github.com/devtron-labs/devtron/client/argocdServer/repository" cron2 "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/client/dashboard" - "github.com/devtron-labs/devtron/client/events" + client2 "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/client/gitSensor" "github.com/devtron-labs/devtron/client/grafana" "github.com/devtron-labs/devtron/client/lens" "github.com/devtron-labs/devtron/client/proxy" "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internal/sql/repository" + repository2 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" @@ -66,12 +83,11 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" repository5 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository14 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + repository12 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" "github.com/devtron-labs/devtron/internal/sql/repository/security" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/internal/util/ArgoUtil" "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" @@ -79,7 +95,7 @@ import ( "github.com/devtron-labs/devtron/pkg/appClone/batch" appStatus2 "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" - repository16 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + repository15 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service4 "github.com/devtron-labs/devtron/pkg/appStore/discover/service" @@ -104,24 +120,24 @@ import ( "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/chartRepo/repository" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" - repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" "github.com/devtron-labs/devtron/pkg/commonService" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" - repository11 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" + repository13 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" - repository7 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" + repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" "github.com/devtron-labs/devtron/pkg/dockerRegistry" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/genericNotes" - repository12 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" + repository6 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" git2 "github.com/devtron-labs/devtron/pkg/git" "github.com/devtron-labs/devtron/pkg/gitops" "github.com/devtron-labs/devtron/pkg/imageDigestPolicy" @@ -130,7 +146,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository15 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository16 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -138,11 +154,11 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/history" - repository8 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - repository9 "github.com/devtron-labs/devtron/pkg/pipeline/repository" + repository9 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + repository10 "github.com/devtron-labs/devtron/pkg/pipeline/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" - repository10 "github.com/devtron-labs/devtron/pkg/plugin/repository" + repository11 "github.com/devtron-labs/devtron/pkg/plugin/repository" resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" security2 "github.com/devtron-labs/devtron/pkg/security" @@ -155,7 +171,7 @@ import ( util3 "github.com/devtron-labs/devtron/pkg/util" "github.com/devtron-labs/devtron/pkg/variables" "github.com/devtron-labs/devtron/pkg/variables/parsers" - repository6 "github.com/devtron-labs/devtron/pkg/variables/repository" + repository7 "github.com/devtron-labs/devtron/pkg/variables/repository" "github.com/devtron-labs/devtron/pkg/webhook/helm" util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/argo" @@ -184,37 +200,19 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - envConfigOverrideRepositoryImpl := chartConfig.NewEnvConfigOverrideRepository(db) - pipelineOverrideRepositoryImpl := chartConfig.NewPipelineOverrideRepository(db) - mergeUtil := &util.MergeUtil{ - Logger: sugaredLogger, - } - pipelineRepositoryImpl := pipelineConfig.NewPipelineRepositoryImpl(db, sugaredLogger) - httpClient := util.NewHttpClient() - eventClientConfig, err := client.GetEventClientConfig() - if err != nil { - return nil, err - } - pubSubClientServiceImpl := pubsub_lib.NewPubSubClientServiceImpl(sugaredLogger) - ciPipelineRepositoryImpl := pipelineConfig.NewCiPipelineRepositoryImpl(db, sugaredLogger) - attributesRepositoryImpl := repository.NewAttributesRepositoryImpl(db) - serverEnvConfigServerEnvConfig, err := serverEnvConfig.ParseServerEnvConfig() - if err != nil { - return nil, err - } - moduleRepositoryImpl := moduleRepo.NewModuleRepositoryImpl(db) - moduleActionAuditLogRepositoryImpl := module.NewModuleActionAuditLogRepositoryImpl(db) - clusterRepositoryImpl := repository2.NewClusterRepositoryImpl(db, sugaredLogger) appStatusRepositoryImpl := appStatus.NewAppStatusRepositoryImpl(db, sugaredLogger) - environmentRepositoryImpl := repository2.NewEnvironmentRepositoryImpl(db, sugaredLogger, appStatusRepositoryImpl) + environmentRepositoryImpl := repository.NewEnvironmentRepositoryImpl(db, sugaredLogger, appStatusRepositoryImpl) + clusterRepositoryImpl := repository.NewClusterRepositoryImpl(db, sugaredLogger) + httpClient := util.NewHttpClient() grafanaClientConfig, err := grafana.GetGrafanaClientConfig() if err != nil { return nil, err } + attributesRepositoryImpl := repository2.NewAttributesRepositoryImpl(db) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) grafanaClientImpl := grafana.NewGrafanaClientImpl(sugaredLogger, httpClient, grafanaClientConfig, attributesServiceImpl) installedAppRepositoryImpl := repository3.NewInstalledAppRepositoryImpl(sugaredLogger, db) - runtimeConfig, err := client2.GetRuntimeConfig() + runtimeConfig, err := client.GetRuntimeConfig() if err != nil { return nil, err } @@ -227,6 +225,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } + moduleRepositoryImpl := moduleRepo.NewModuleRepositoryImpl(db) argoCDConnectionManagerImpl, err := connection.NewArgoCDConnectionManagerImpl(sugaredLogger, settingsManager, moduleRepositoryImpl) if err != nil { return nil, err @@ -239,16 +238,16 @@ func InitializeApp() (*App, error) { userAuthRepositoryImpl := repository4.NewUserAuthRepositoryImpl(db, sugaredLogger, defaultAuthPolicyRepositoryImpl, defaultAuthRoleRepositoryImpl) userRepositoryImpl := repository4.NewUserRepositoryImpl(db, sugaredLogger) roleGroupRepositoryImpl := repository4.NewRoleGroupRepositoryImpl(db, sugaredLogger) - gitOpsConfigRepositoryImpl := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - k8sClient, err := client2.NewK8sClient(runtimeConfig) + gitOpsConfigRepositoryImpl := repository2.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) + k8sClient, err := client.NewK8sClient(runtimeConfig) if err != nil { return nil, err } - dexConfig, err := client2.BuildDexConfig(k8sClient) + dexConfig, err := client.BuildDexConfig(k8sClient) if err != nil { return nil, err } - settings, err := client2.GetSettings(dexConfig) + settings, err := client.GetSettings(dexConfig) if err != nil { return nil, err } @@ -267,31 +266,90 @@ func InitializeApp() (*App, error) { } gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) clusterServiceImplExtended := cluster2.NewClusterServiceImplExtended(clusterRepositoryImpl, environmentRepositoryImpl, grafanaClientImpl, sugaredLogger, installedAppRepositoryImpl, k8sServiceImpl, serviceClientImpl, k8sInformerFactoryImpl, userAuthRepositoryImpl, userRepositoryImpl, roleGroupRepositoryImpl, gitOpsConfigReadServiceImpl) + loginService := middleware.NewUserLogin(sessionManager, k8sClient) + userAuthServiceImpl := user.NewUserAuthServiceImpl(userAuthRepositoryImpl, sessionManager, loginService, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userServiceImpl) + environmentServiceImpl := cluster2.NewEnvironmentServiceImpl(environmentRepositoryImpl, clusterServiceImplExtended, sugaredLogger, k8sServiceImpl, k8sInformerFactoryImpl, userAuthServiceImpl, attributesRepositoryImpl) + validate, err := util.IntValidator() + if err != nil { + return nil, err + } + syncedEnforcer := casbin.Create() + enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) + teamRepositoryImpl := team.NewTeamRepositoryImpl(db) + teamServiceImpl := team.NewTeamServiceImpl(sugaredLogger, teamRepositoryImpl, userAuthServiceImpl) + appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) + pipelineRepositoryImpl := pipelineConfig.NewPipelineRepositoryImpl(db, sugaredLogger) + chartRepoRepositoryImpl := chartRepoRepository.NewChartRepoRepositoryImpl(db) + acdAuthConfig, err := util3.GetACDAuthConfig() + if err != nil { + return nil, err + } + serverEnvConfigServerEnvConfig, err := serverEnvConfig.ParseServerEnvConfig() + if err != nil { + return nil, err + } + chartRepositoryServiceImpl := chartRepo.NewChartRepositoryServiceImpl(sugaredLogger, chartRepoRepositoryImpl, k8sServiceImpl, clusterServiceImplExtended, acdAuthConfig, httpClient, serverEnvConfigServerEnvConfig) helmClientConfig, err := gRPC.GetConfig() if err != nil { return nil, err } helmAppClientImpl := gRPC.NewHelmAppClientImpl(sugaredLogger, helmClientConfig) pumpImpl := connector.NewPumpImpl(sugaredLogger) - teamRepositoryImpl := team.NewTeamRepositoryImpl(db) - appRepositoryImpl := app.NewAppRepositoryImpl(db, sugaredLogger) enforcerUtilHelmImpl := rbac.NewEnforcerUtilHelmImpl(sugaredLogger, clusterRepositoryImpl, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, installedAppRepositoryImpl) serverDataStoreServerDataStore := serverDataStore.InitServerDataStore() appStoreApplicationVersionRepositoryImpl := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) - loginService := middleware.NewUserLogin(sessionManager, k8sClient) - userAuthServiceImpl := user.NewUserAuthServiceImpl(userAuthRepositoryImpl, sessionManager, loginService, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userServiceImpl) - environmentServiceImpl := cluster2.NewEnvironmentServiceImpl(environmentRepositoryImpl, clusterServiceImplExtended, sugaredLogger, k8sServiceImpl, k8sInformerFactoryImpl, userAuthServiceImpl, attributesRepositoryImpl) helmReleaseConfig, err := service.GetHelmReleaseConfig() if err != nil { return nil, err } helmAppServiceImpl := service.NewHelmAppServiceImpl(sugaredLogger, clusterServiceImplExtended, helmAppClientImpl, pumpImpl, enforcerUtilHelmImpl, serverDataStoreServerDataStore, serverEnvConfigServerEnvConfig, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, appRepositoryImpl, clusterRepositoryImpl, k8sServiceImpl, helmReleaseConfig) + dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) + dockerRegistryIpsConfigRepositoryImpl := repository5.NewDockerRegistryIpsConfigRepositoryImpl(db) + ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) + dockerRegistryConfigImpl := pipeline.NewDockerRegistryConfigImpl(sugaredLogger, helmAppServiceImpl, dockerArtifactStoreRepositoryImpl, dockerRegistryIpsConfigRepositoryImpl, ociRegistryConfigRepositoryImpl) + deleteServiceExtendedImpl := delete2.NewDeleteServiceExtendedImpl(sugaredLogger, teamServiceImpl, clusterServiceImplExtended, environmentServiceImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, chartRepositoryServiceImpl, installedAppRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) + k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sServiceImpl, clusterServiceImplExtended) + environmentRestHandlerImpl := cluster3.NewEnvironmentRestHandlerImpl(environmentServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceExtendedImpl, k8sServiceImpl, k8sCommonServiceImpl) + environmentRouterImpl := cluster3.NewEnvironmentRouterImpl(environmentRestHandlerImpl) + genericNoteRepositoryImpl := repository6.NewGenericNoteRepositoryImpl(db) + genericNoteHistoryRepositoryImpl := repository6.NewGenericNoteHistoryRepositoryImpl(db) + genericNoteHistoryServiceImpl := genericNotes.NewGenericNoteHistoryServiceImpl(genericNoteHistoryRepositoryImpl, sugaredLogger) + genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) + clusterDescriptionRepositoryImpl := repository.NewClusterDescriptionRepositoryImpl(db, sugaredLogger) + clusterDescriptionServiceImpl := cluster2.NewClusterDescriptionServiceImpl(clusterDescriptionRepositoryImpl, userRepositoryImpl, sugaredLogger) + devtronSecretConfig, err := util2.GetDevtronSecretName() + if err != nil { + return nil, err + } + versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) + argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl, gitOpsConfigReadServiceImpl) + if err != nil { + return nil, err + } + clusterRbacServiceImpl := cluster2.NewClusterRbacServiceImpl(environmentServiceImpl, enforcerImpl, clusterServiceImplExtended, sugaredLogger, userServiceImpl) + clusterRestHandlerImpl := cluster3.NewClusterRestHandlerImpl(clusterServiceImplExtended, genericNoteServiceImpl, clusterDescriptionServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceExtendedImpl, argoUserServiceImpl, environmentServiceImpl, clusterRbacServiceImpl) + clusterRouterImpl := cluster3.NewClusterRouterImpl(clusterRestHandlerImpl) + ciCdConfig, err := types.GetCiCdConfig() + if err != nil { + return nil, err + } + envConfigOverrideRepositoryImpl := chartConfig.NewEnvConfigOverrideRepository(db) + pipelineOverrideRepositoryImpl := chartConfig.NewPipelineOverrideRepository(db) + mergeUtil := &util.MergeUtil{ + Logger: sugaredLogger, + } + eventClientConfig, err := client2.GetEventClientConfig() + if err != nil { + return nil, err + } + pubSubClientServiceImpl := pubsub_lib.NewPubSubClientServiceImpl(sugaredLogger) + ciPipelineRepositoryImpl := pipelineConfig.NewCiPipelineRepositoryImpl(db, sugaredLogger) + moduleActionAuditLogRepositoryImpl := module.NewModuleActionAuditLogRepositoryImpl(db) serverCacheServiceImpl := server.NewServerCacheServiceImpl(sugaredLogger, serverEnvConfigServerEnvConfig, serverDataStoreServerDataStore, helmAppServiceImpl) moduleEnvConfig, err := module.ParseModuleEnvConfig() if err != nil { return nil, err } - teamServiceImpl := team.NewTeamServiceImpl(sugaredLogger, teamRepositoryImpl, userAuthServiceImpl) moduleCacheServiceImpl := module.NewModuleCacheServiceImpl(sugaredLogger, k8sServiceImpl, moduleEnvConfig, serverEnvConfigServerEnvConfig, serverDataStoreServerDataStore, moduleRepositoryImpl, teamServiceImpl) moduleServiceHelperImpl := module.NewModuleServiceHelperImpl(serverEnvConfigServerEnvConfig) moduleResourceStatusRepositoryImpl := moduleRepo.NewModuleResourceStatusRepositoryImpl(db) @@ -303,28 +361,18 @@ func InitializeApp() (*App, error) { } scanToolMetadataRepositoryImpl := security.NewScanToolMetadataRepositoryImpl(db, sugaredLogger) moduleServiceImpl := module.NewModuleServiceImpl(sugaredLogger, serverEnvConfigServerEnvConfig, moduleRepositoryImpl, moduleActionAuditLogRepositoryImpl, helmAppServiceImpl, serverDataStoreServerDataStore, serverCacheServiceImpl, moduleCacheServiceImpl, moduleCronServiceImpl, moduleServiceHelperImpl, moduleResourceStatusRepositoryImpl, scanToolMetadataRepositoryImpl) - eventRESTClientImpl := client.NewEventRESTClientImpl(sugaredLogger, httpClient, eventClientConfig, pubSubClientServiceImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, attributesRepositoryImpl, moduleServiceImpl) + eventRESTClientImpl := client2.NewEventRESTClientImpl(sugaredLogger, httpClient, eventClientConfig, pubSubClientServiceImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, attributesRepositoryImpl, moduleServiceImpl) cdWorkflowRepositoryImpl := pipelineConfig.NewCdWorkflowRepositoryImpl(db, sugaredLogger) ciWorkflowRepositoryImpl := pipelineConfig.NewCiWorkflowRepositoryImpl(db, sugaredLogger) ciPipelineMaterialRepositoryImpl := pipelineConfig.NewCiPipelineMaterialRepositoryImpl(db, sugaredLogger) - ciArtifactRepositoryImpl := repository.NewCiArtifactRepositoryImpl(db, sugaredLogger) - eventSimpleFactoryImpl := client.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, ciArtifactRepositoryImpl) + ciArtifactRepositoryImpl := repository2.NewCiArtifactRepositoryImpl(db, sugaredLogger) + eventSimpleFactoryImpl := client2.NewEventSimpleFactoryImpl(sugaredLogger, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, ciWorkflowRepositoryImpl, ciPipelineMaterialRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, userRepositoryImpl, ciArtifactRepositoryImpl) applicationServiceClientImpl := application.NewApplicationClientImpl(sugaredLogger, argoCDConnectionManagerImpl) configMapRepositoryImpl := chartConfig.NewConfigMapRepositoryImpl(sugaredLogger, db) chartRepositoryImpl := chartRepoRepository.NewChartRepository(db) - dockerArtifactStoreRepositoryImpl := repository5.NewDockerArtifactStoreRepositoryImpl(db) - gitProviderRepositoryImpl := repository.NewGitProviderRepositoryImpl(db) + gitProviderRepositoryImpl := repository2.NewGitProviderRepositoryImpl(db) commonServiceImpl := commonService.NewCommonServiceImpl(sugaredLogger, chartRepositoryImpl, envConfigOverrideRepositoryImpl, dockerArtifactStoreRepositoryImpl, attributesRepositoryImpl, gitProviderRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appRepositoryImpl) chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) - devtronSecretConfig, err := util2.GetDevtronSecretName() - if err != nil { - return nil, err - } - versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) - argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl, gitOpsConfigReadServiceImpl) - if err != nil { - return nil, err - } pipelineStatusTimelineRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineRepositoryImpl(db, sugaredLogger) pipelineStatusTimelineResourcesRepositoryImpl := pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl(db, sugaredLogger) pipelineStatusTimelineResourcesServiceImpl := status.NewPipelineStatusTimelineResourcesServiceImpl(db, sugaredLogger, pipelineStatusTimelineResourcesRepositoryImpl) @@ -336,16 +384,14 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - syncedEnforcer := casbin.Create() - enforcerImpl := casbin.NewEnforcerImpl(syncedEnforcer, sessionManager, sugaredLogger) enforcerUtilImpl := rbac.NewEnforcerUtilImpl(sugaredLogger, teamRepositoryImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, clusterRepositoryImpl, enforcerImpl) appStatusServiceImpl := appStatus2.NewAppStatusServiceImpl(appStatusRepositoryImpl, sugaredLogger, enforcerImpl, enforcerUtilImpl) - scopedVariableRepositoryImpl := repository6.NewScopedVariableRepository(db, sugaredLogger) + scopedVariableRepositoryImpl := repository7.NewScopedVariableRepository(db, sugaredLogger) qualifiersMappingRepositoryImpl, err := resourceQualifiers.NewQualifiersMappingRepositoryImpl(db, sugaredLogger) if err != nil { return nil, err } - devtronResourceSearchableKeyRepositoryImpl := repository7.NewDevtronResourceSearchableKeyRepositoryImpl(sugaredLogger, db) + devtronResourceSearchableKeyRepositoryImpl := repository8.NewDevtronResourceSearchableKeyRepositoryImpl(sugaredLogger, db) devtronResourceSearchableKeyServiceImpl, err := devtronResource.NewDevtronResourceSearchableKeyServiceImpl(sugaredLogger, devtronResourceSearchableKeyRepositoryImpl) if err != nil { return nil, err @@ -358,9 +404,9 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - variableEntityMappingRepositoryImpl := repository6.NewVariableEntityMappingRepository(sugaredLogger, db) + variableEntityMappingRepositoryImpl := repository7.NewVariableEntityMappingRepository(sugaredLogger, db) variableEntityMappingServiceImpl := variables.NewVariableEntityMappingServiceImpl(variableEntityMappingRepositoryImpl, sugaredLogger) - variableSnapshotHistoryRepositoryImpl := repository6.NewVariableSnapshotHistoryRepository(sugaredLogger, db) + variableSnapshotHistoryRepositoryImpl := repository7.NewVariableSnapshotHistoryRepository(sugaredLogger, db) variableSnapshotHistoryServiceImpl := variables.NewVariableSnapshotHistoryServiceImpl(variableSnapshotHistoryRepositoryImpl, sugaredLogger) variableTemplateParserImpl, err := parsers.NewVariableTemplateParserImpl(sugaredLogger) if err != nil { @@ -386,34 +432,36 @@ func InitializeApp() (*App, error) { } gitOperationServiceImpl := git.NewGitOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) - validate, err := util.IntValidator() - if err != nil { - return nil, err - } - ciCdConfig, err := types.GetCiCdConfig() - if err != nil { - return nil, err - } - globalCMCSRepositoryImpl := repository.NewGlobalCMCSRepositoryImpl(sugaredLogger, db) + globalCMCSRepositoryImpl := repository2.NewGlobalCMCSRepositoryImpl(sugaredLogger, db) globalCMCSServiceImpl := pipeline.NewGlobalCMCSServiceImpl(sugaredLogger, globalCMCSRepositoryImpl) argoWorkflowExecutorImpl := executors.NewArgoWorkflowExecutorImpl(sugaredLogger) systemWorkflowExecutorImpl := executors.NewSystemWorkflowExecutorImpl(sugaredLogger, k8sServiceImpl) - k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sServiceImpl, clusterServiceImplExtended) workflowServiceImpl, err := pipeline.NewWorkflowServiceImpl(sugaredLogger, environmentRepositoryImpl, ciCdConfig, appServiceImpl, globalCMCSServiceImpl, argoWorkflowExecutorImpl, k8sServiceImpl, systemWorkflowExecutorImpl, k8sCommonServiceImpl) if err != nil { return nil, err } - materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) - deploymentGroupRepositoryImpl := repository.NewDeploymentGroupRepositoryImpl(sugaredLogger, db) - cvePolicyRepositoryImpl := security.NewPolicyRepositoryImpl(db) - imageScanResultRepositoryImpl := security.NewImageScanResultRepositoryImpl(db, sugaredLogger) - appWorkflowRepositoryImpl := appWorkflow.NewAppWorkflowRepositoryImpl(sugaredLogger, db) - prePostCdScriptHistoryRepositoryImpl := repository8.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) - configMapHistoryRepositoryImpl := repository8.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db) - configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) - prePostCdScriptHistoryServiceImpl := history.NewPrePostCdScriptHistoryServiceImpl(sugaredLogger, prePostCdScriptHistoryRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl) + prePostCiScriptHistoryRepositoryImpl := repository9.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) + prePostCiScriptHistoryServiceImpl := history.NewPrePostCiScriptHistoryServiceImpl(sugaredLogger, prePostCiScriptHistoryRepositoryImpl) + pipelineStageRepositoryImpl := repository10.NewPipelineStageRepository(sugaredLogger, db) + globalPluginRepositoryImpl := repository11.NewGlobalPluginRepository(sugaredLogger, db) + scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) + if err != nil { + return nil, err + } + pipelineStageServiceImpl := pipeline.NewPipelineStageService(sugaredLogger, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, pipelineRepositoryImpl, scopedVariableManagerImpl) + ciBuildConfigRepositoryImpl := pipelineConfig.NewCiBuildConfigRepositoryImpl(db, sugaredLogger) + ciBuildConfigServiceImpl := pipeline.NewCiBuildConfigServiceImpl(sugaredLogger, ciBuildConfigRepositoryImpl) ciTemplateRepositoryImpl := pipelineConfig.NewCiTemplateRepositoryImpl(db, sugaredLogger) + ciTemplateOverrideRepositoryImpl := pipelineConfig.NewCiTemplateOverrideRepositoryImpl(db, sugaredLogger) + ciTemplateServiceImpl := pipeline.NewCiTemplateServiceImpl(sugaredLogger, ciBuildConfigServiceImpl, ciTemplateRepositoryImpl, ciTemplateOverrideRepositoryImpl) appLabelRepositoryImpl := pipelineConfig.NewAppLabelRepositoryImpl(db) + materialRepositoryImpl := pipelineConfig.NewMaterialRepositoryImpl(db) + appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, materialRepositoryImpl) + imageTagRepositoryImpl := repository2.NewImageTagRepository(db, sugaredLogger) + customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) + pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) + globalPluginServiceImpl := plugin.NewGlobalPluginService(sugaredLogger, globalPluginRepositoryImpl, pipelineStageRepositoryImpl) + ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) clientConfig, err := gitSensor.GetConfig() if err != nil { return nil, err @@ -422,157 +470,92 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - pipelineStageRepositoryImpl := repository9.NewPipelineStageRepository(sugaredLogger, db) - globalPluginRepositoryImpl := repository10.NewGlobalPluginRepository(sugaredLogger, db) - scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) + ciLogServiceImpl, err := pipeline.NewCiLogServiceImpl(sugaredLogger, ciServiceImpl, k8sServiceImpl) if err != nil { return nil, err } - pipelineStageServiceImpl := pipeline.NewPipelineStageService(sugaredLogger, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, pipelineRepositoryImpl, scopedVariableManagerImpl) - globalPluginServiceImpl := plugin.NewGlobalPluginService(sugaredLogger, globalPluginRepositoryImpl, pipelineStageRepositoryImpl) - dockerRegistryIpsConfigRepositoryImpl := repository5.NewDockerRegistryIpsConfigRepositoryImpl(db) - ociRegistryConfigRepositoryImpl := repository5.NewOCIRegistryConfigRepositoryImpl(db) - dockerRegistryConfigImpl := pipeline.NewDockerRegistryConfigImpl(sugaredLogger, helmAppServiceImpl, dockerArtifactStoreRepositoryImpl, dockerRegistryIpsConfigRepositoryImpl, ociRegistryConfigRepositoryImpl) - imageTagRepositoryImpl := repository.NewImageTagRepository(db, sugaredLogger) - customTagServiceImpl := pipeline.NewCustomTagService(sugaredLogger, imageTagRepositoryImpl) - pluginInputVariableParserImpl := pipeline.NewPluginInputVariableParserImpl(sugaredLogger, dockerRegistryConfigImpl, customTagServiceImpl) - deploymentTemplateHistoryRepositoryImpl := repository8.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) - appLevelMetricsRepositoryImpl := repository11.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) - envLevelAppMetricsRepositoryImpl := repository11.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) - deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRefServiceImpl) - deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) - pipelineStrategyHistoryRepositoryImpl := repository8.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) - pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) - manifestPushConfigRepositoryImpl := repository9.NewManifestPushConfigRepository(sugaredLogger, db) - gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) - imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) - imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) - genericNoteRepositoryImpl := repository12.NewGenericNoteRepositoryImpl(db) - genericNoteHistoryRepositoryImpl := repository12.NewGenericNoteHistoryRepositoryImpl(db) - genericNoteHistoryServiceImpl := genericNotes.NewGenericNoteHistoryServiceImpl(genericNoteHistoryRepositoryImpl, sugaredLogger) - genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) - appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, materialRepositoryImpl) - pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) - ciTemplateOverrideRepositoryImpl := pipelineConfig.NewCiTemplateOverrideRepositoryImpl(db, sugaredLogger) - dockerRegistryIpsConfigServiceImpl := dockerRegistry.NewDockerRegistryIpsConfigServiceImpl(sugaredLogger, dockerRegistryIpsConfigRepositoryImpl, k8sServiceImpl, clusterServiceImplExtended, ciPipelineRepositoryImpl, dockerArtifactStoreRepositoryImpl, ciTemplateOverrideRepositoryImpl) - argoK8sClientImpl := argocdServer.NewArgoK8sClientImpl(sugaredLogger) - repositoryServiceClientImpl := repository13.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) - argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) - pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - imageDigestPolicyServiceImpl := imageDigestPolicy.NewImageDigestPolicyServiceImpl(sugaredLogger, qualifierMappingServiceImpl, devtronResourceSearchableKeyServiceImpl) - workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, mergeUtil, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, imageDigestPolicyServiceImpl) - deploymentGroupAppRepositoryImpl := repository.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) - deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) - deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) - pipelineTriggerRestHandlerImpl := restHandler.NewPipelineRestHandler(appServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, workflowDagExecutorImpl, deploymentGroupServiceImpl, argoUserServiceImpl, deploymentConfigServiceImpl) - sseSSE := sse.NewSSE() - pipelineTriggerRouterImpl := router.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) appListingRepositoryQueryBuilder := helper.NewAppListingRepositoryQueryBuilder(sugaredLogger) - appListingRepositoryImpl := repository.NewAppListingRepositoryImpl(sugaredLogger, db, appListingRepositoryQueryBuilder, environmentRepositoryImpl) - prePostCiScriptHistoryRepositoryImpl := repository8.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) - prePostCiScriptHistoryServiceImpl := history.NewPrePostCiScriptHistoryServiceImpl(sugaredLogger, prePostCiScriptHistoryRepositoryImpl) - gitMaterialHistoryRepositoryImpl := repository8.NewGitMaterialHistoryRepositoyImpl(db) + appListingRepositoryImpl := repository2.NewAppListingRepositoryImpl(sugaredLogger, db, appListingRepositoryQueryBuilder, environmentRepositoryImpl) + resourceGroupRepositoryImpl := resourceGroup.NewResourceGroupRepositoryImpl(db) + resourceGroupMappingRepositoryImpl := resourceGroup.NewResourceGroupMappingRepositoryImpl(db) + resourceGroupServiceImpl := resourceGroup2.NewResourceGroupServiceImpl(sugaredLogger, resourceGroupRepositoryImpl, resourceGroupMappingRepositoryImpl, enforcerUtilImpl, devtronResourceSearchableKeyServiceImpl, appStatusRepositoryImpl) + imageTaggingRepositoryImpl := repository12.NewImageTaggingRepositoryImpl(db) + imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) + blobStorageConfigServiceImpl := pipeline.NewBlobStorageConfigServiceImpl(sugaredLogger, k8sServiceImpl, ciCdConfig) + appWorkflowRepositoryImpl := appWorkflow.NewAppWorkflowRepositoryImpl(sugaredLogger, db) + ciHandlerImpl := pipeline.NewCiHandlerImpl(sugaredLogger, ciServiceImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciWorkflowRepositoryImpl, workflowServiceImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, userServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl, ciPipelineRepositoryImpl, appListingRepositoryImpl, k8sServiceImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, environmentRepositoryImpl, imageTaggingServiceImpl, k8sCommonServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, appWorkflowRepositoryImpl, customTagServiceImpl, environmentServiceImpl) + gitWebhookRepositoryImpl := repository2.NewGitWebhookRepositoryImpl(db) + gitWebhookServiceImpl := git2.NewGitWebhookServiceImpl(sugaredLogger, ciHandlerImpl, gitWebhookRepositoryImpl) + gitWebhookRestHandlerImpl := restHandler.NewGitWebhookRestHandlerImpl(sugaredLogger, gitWebhookServiceImpl) + prePostCdScriptHistoryRepositoryImpl := repository9.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) + configMapHistoryRepositoryImpl := repository9.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db) + configMapHistoryServiceImpl := history.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) + prePostCdScriptHistoryServiceImpl := history.NewPrePostCdScriptHistoryServiceImpl(sugaredLogger, prePostCdScriptHistoryRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl) + gitMaterialHistoryRepositoryImpl := repository9.NewGitMaterialHistoryRepositoyImpl(db) gitMaterialHistoryServiceImpl := history.NewGitMaterialHistoryServiceImpl(gitMaterialHistoryRepositoryImpl, sugaredLogger) - ciPipelineHistoryRepositoryImpl := repository8.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) + ciPipelineHistoryRepositoryImpl := repository9.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) ciPipelineHistoryServiceImpl := history.NewCiPipelineHistoryServiceImpl(ciPipelineHistoryRepositoryImpl, sugaredLogger, ciPipelineRepositoryImpl) - ciBuildConfigRepositoryImpl := pipelineConfig.NewCiBuildConfigRepositoryImpl(db, sugaredLogger) - ciBuildConfigServiceImpl := pipeline.NewCiBuildConfigServiceImpl(sugaredLogger, ciBuildConfigRepositoryImpl) - ciTemplateServiceImpl := pipeline.NewCiTemplateServiceImpl(sugaredLogger, ciBuildConfigServiceImpl, ciTemplateRepositoryImpl, ciTemplateOverrideRepositoryImpl) - chartRepoRepositoryImpl := chartRepoRepository.NewChartRepoRepositoryImpl(db) + pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) configMapServiceImpl := pipeline.NewConfigMapServiceImpl(chartRepositoryImpl, sugaredLogger, chartRepoRepositoryImpl, utilMergeUtil, pipelineConfigRepositoryImpl, configMapRepositoryImpl, envConfigOverrideRepositoryImpl, commonServiceImpl, appRepositoryImpl, configMapHistoryServiceImpl, environmentRepositoryImpl, scopedVariableCMCSManagerImpl) ciCdPipelineOrchestratorImpl := pipeline.NewCiCdPipelineOrchestrator(appRepositoryImpl, sugaredLogger, materialRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciCdConfig, appWorkflowRepositoryImpl, environmentRepositoryImpl, attributesServiceImpl, appListingRepositoryImpl, appCrudOperationServiceImpl, userAuthServiceImpl, prePostCdScriptHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, ciTemplateOverrideRepositoryImpl, gitMaterialHistoryServiceImpl, ciPipelineHistoryServiceImpl, ciTemplateServiceImpl, dockerArtifactStoreRepositoryImpl, ciArtifactRepositoryImpl, configMapServiceImpl, customTagServiceImpl, genericNoteServiceImpl) ecrConfig, err := pipeline.GetEcrConfig() if err != nil { return nil, err } - ciTemplateHistoryRepositoryImpl := repository8.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) + ciTemplateHistoryRepositoryImpl := repository9.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) ciTemplateHistoryServiceImpl := history.NewCiTemplateHistoryServiceImpl(ciTemplateHistoryRepositoryImpl, sugaredLogger) - resourceGroupRepositoryImpl := resourceGroup.NewResourceGroupRepositoryImpl(db) - resourceGroupMappingRepositoryImpl := resourceGroup.NewResourceGroupMappingRepositoryImpl(db) - resourceGroupServiceImpl := resourceGroup2.NewResourceGroupServiceImpl(sugaredLogger, resourceGroupRepositoryImpl, resourceGroupMappingRepositoryImpl, enforcerUtilImpl, devtronResourceSearchableKeyServiceImpl, appStatusRepositoryImpl) buildPipelineSwitchServiceImpl := pipeline.NewBuildPipelineSwitchServiceImpl(sugaredLogger, ciPipelineRepositoryImpl, ciCdPipelineOrchestratorImpl, pipelineRepositoryImpl, ciWorkflowRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineHistoryServiceImpl, ciTemplateOverrideRepositoryImpl, ciPipelineMaterialRepositoryImpl) ciPipelineConfigServiceImpl := pipeline.NewCiPipelineConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, dockerArtifactStoreRepositoryImpl, materialRepositoryImpl, appRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ecrConfig, appWorkflowRepositoryImpl, ciCdConfig, attributesServiceImpl, pipelineStageServiceImpl, ciPipelineMaterialRepositoryImpl, ciTemplateServiceImpl, ciTemplateOverrideRepositoryImpl, ciTemplateHistoryServiceImpl, enforcerUtilImpl, ciWorkflowRepositoryImpl, resourceGroupServiceImpl, customTagServiceImpl, ciPipelineHistoryServiceImpl, cdWorkflowRepositoryImpl, buildPipelineSwitchServiceImpl) ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl) - imageTaggingRepositoryImpl := repository14.NewImageTaggingRepositoryImpl(db) - imageTaggingServiceImpl := pipeline.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) + deploymentGroupRepositoryImpl := repository2.NewDeploymentGroupRepositoryImpl(sugaredLogger, db) + pipelineStrategyHistoryRepositoryImpl := repository9.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) + pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) + deploymentTemplateHistoryRepositoryImpl := repository9.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) + appLevelMetricsRepositoryImpl := repository13.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) + envLevelAppMetricsRepositoryImpl := repository13.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) + deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRefServiceImpl) + deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) deploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() if err != nil { return nil, err } + pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) + repositoryServiceClientImpl := repository14.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) + argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) + imageDigestPolicyServiceImpl := imageDigestPolicy.NewImageDigestPolicyServiceImpl(sugaredLogger, qualifierMappingServiceImpl, devtronResourceSearchableKeyServiceImpl) cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, imageDigestPolicyServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) + cvePolicyRepositoryImpl := security.NewPolicyRepositoryImpl(db) + imageScanResultRepositoryImpl := security.NewImageScanResultRepositoryImpl(db, sugaredLogger) + manifestPushConfigRepositoryImpl := repository10.NewManifestPushConfigRepository(sugaredLogger, db) + gitOpsManifestPushServiceImpl := app2.NewGitOpsManifestPushServiceImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, pipelineStatusTimelineRepositoryImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + imageScanHistoryRepositoryImpl := security.NewImageScanHistoryRepositoryImpl(db, sugaredLogger) + imageScanDeployInfoRepositoryImpl := security.NewImageScanDeployInfoRepositoryImpl(db, sugaredLogger) + dockerRegistryIpsConfigServiceImpl := dockerRegistry.NewDockerRegistryIpsConfigServiceImpl(sugaredLogger, dockerRegistryIpsConfigRepositoryImpl, k8sServiceImpl, clusterServiceImplExtended, ciPipelineRepositoryImpl, dockerArtifactStoreRepositoryImpl, ciTemplateOverrideRepositoryImpl) + argoK8sClientImpl := argocdServer.NewArgoK8sClientImpl(sugaredLogger) + workflowDagExecutorImpl := pipeline.NewWorkflowDagExecutorImpl(sugaredLogger, pipelineRepositoryImpl, cdWorkflowRepositoryImpl, pubSubClientServiceImpl, appServiceImpl, workflowServiceImpl, ciArtifactRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl, pipelineOverrideRepositoryImpl, userServiceImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, enforcerUtilImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cvePolicyRepositoryImpl, imageScanResultRepositoryImpl, appWorkflowRepositoryImpl, prePostCdScriptHistoryServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineServiceImpl, ciTemplateRepositoryImpl, ciWorkflowRepositoryImpl, appLabelRepositoryImpl, clientImpl, pipelineStageServiceImpl, k8sCommonServiceImpl, globalPluginServiceImpl, pluginInputVariableParserImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, manifestPushConfigRepositoryImpl, gitOpsManifestPushServiceImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryRepositoryImpl, imageScanDeployInfoRepositoryImpl, appCrudOperationServiceImpl, pipelineConfigRepositoryImpl, dockerRegistryIpsConfigServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, pipelineStrategyHistoryRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, argoK8sClientImpl, configMapRepositoryImpl, configMapHistoryRepositoryImpl, helmAppServiceImpl, helmAppClientImpl, envConfigOverrideRepositoryImpl, mergeUtil, applicationServiceClientImpl, argoClientWrapperServiceImpl, pipelineConfigListenerServiceImpl, customTagServiceImpl, acdConfig, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, imageDigestPolicyServiceImpl) chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) appDeploymentTypeChangeManagerImpl := pipeline.NewAppDeploymentTypeChangeManagerImpl(sugaredLogger, pipelineRepositoryImpl, workflowDagExecutorImpl, appServiceImpl, appStatusRepositoryImpl, helmAppServiceImpl, applicationServiceClientImpl, appArtifactManagerImpl, cdPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl, chartServiceImpl) devtronAppConfigServiceImpl := pipeline.NewDevtronAppConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, appRepositoryImpl, pipelineRepositoryImpl, resourceGroupServiceImpl, enforcerUtilImpl, ciMaterialConfigServiceImpl) pipelineBuilderImpl := pipeline.NewPipelineBuilderImpl(sugaredLogger, materialRepositoryImpl, chartRepositoryImpl, ciPipelineConfigServiceImpl, ciMaterialConfigServiceImpl, appArtifactManagerImpl, devtronAppCMCSServiceImpl, devtronAppStrategyServiceImpl, appDeploymentTypeChangeManagerImpl, cdPipelineConfigServiceImpl, devtronAppConfigServiceImpl) deploymentTemplateValidationServiceImpl := deploymentTemplate.NewDeploymentTemplateValidationServiceImpl(sugaredLogger, chartRefServiceImpl, scopedVariableManagerImpl) - ciServiceImpl := pipeline.NewCiServiceImpl(sugaredLogger, workflowServiceImpl, ciPipelineMaterialRepositoryImpl, ciWorkflowRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, mergeUtil, ciPipelineRepositoryImpl, prePostCiScriptHistoryServiceImpl, pipelineStageServiceImpl, userServiceImpl, ciTemplateServiceImpl, appCrudOperationServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, customTagServiceImpl, pluginInputVariableParserImpl, globalPluginServiceImpl) - ciLogServiceImpl, err := pipeline.NewCiLogServiceImpl(sugaredLogger, ciServiceImpl, k8sServiceImpl) - if err != nil { - return nil, err - } - blobStorageConfigServiceImpl := pipeline.NewBlobStorageConfigServiceImpl(sugaredLogger, k8sServiceImpl, ciCdConfig) - ciHandlerImpl := pipeline.NewCiHandlerImpl(sugaredLogger, ciServiceImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciWorkflowRepositoryImpl, workflowServiceImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, userServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl, ciPipelineRepositoryImpl, appListingRepositoryImpl, k8sServiceImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, environmentRepositoryImpl, imageTaggingServiceImpl, k8sCommonServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, appWorkflowRepositoryImpl, customTagServiceImpl, environmentServiceImpl) - gitRegistryConfigImpl := pipeline.NewGitRegistryConfigImpl(sugaredLogger, gitProviderRepositoryImpl, clientImpl) appListingViewBuilderImpl := app2.NewAppListingViewBuilderImpl(sugaredLogger) - linkoutsRepositoryImpl := repository.NewLinkoutsRepositoryImpl(sugaredLogger, db) + linkoutsRepositoryImpl := repository2.NewLinkoutsRepositoryImpl(sugaredLogger, db) appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, argoUserServiceImpl, envConfigOverrideRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl, deployedAppMetricsServiceImpl) deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, userServiceImpl, cdWorkflowRepositoryImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, resourceGroupServiceImpl, imageTaggingServiceImpl, k8sServiceImpl, workflowServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, customTagServiceImpl, argoClientWrapperServiceImpl, appServiceConfig, acdConfig) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, ciPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl) - deploymentTemplateRepositoryImpl := repository.NewDeploymentTemplateRepositoryImpl(db, sugaredLogger) + deploymentTemplateRepositoryImpl := repository2.NewDeploymentTemplateRepositoryImpl(db, sugaredLogger) deploymentTemplateServiceImpl := generateManifest.NewDeploymentTemplateServiceImpl(sugaredLogger, chartServiceImpl, appListingServiceImpl, appListingRepositoryImpl, deploymentTemplateRepositoryImpl, helmAppServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, helmAppClientImpl, k8sServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, chartRefServiceImpl) imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) cveStoreRepositoryImpl := security.NewCveStoreRepositoryImpl(db, sugaredLogger) policyServiceImpl := security2.NewPolicyServiceImpl(environmentServiceImpl, sugaredLogger, appRepositoryImpl, pipelineOverrideRepositoryImpl, cvePolicyRepositoryImpl, clusterServiceImplExtended, pipelineRepositoryImpl, imageScanResultRepositoryImpl, imageScanDeployInfoRepositoryImpl, imageScanObjectMetaRepositoryImpl, httpClient, ciArtifactRepositoryImpl, ciCdConfig, imageScanHistoryRepositoryImpl, cveStoreRepositoryImpl, ciTemplateRepositoryImpl) - pipelineConfigRestHandlerImpl := app3.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, deploymentTemplateValidationServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) - appWorkflowRestHandlerImpl := restHandler.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) - webhookEventDataRepositoryImpl := repository.NewWebhookEventDataRepositoryImpl(db) - webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) - webhookDataRestHandlerImpl := restHandler.NewWebhookDataRestHandlerImpl(sugaredLogger, userServiceImpl, ciPipelineMaterialRepositoryImpl, enforcerUtilImpl, enforcerImpl, clientImpl, webhookEventDataConfigImpl) - deployedConfigurationHistoryServiceImpl := history.NewDeployedConfigurationHistoryServiceImpl(sugaredLogger, userServiceImpl, deploymentTemplateHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, cdWorkflowRepositoryImpl) - pipelineHistoryRestHandlerImpl := restHandler.NewPipelineHistoryRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, pipelineStrategyHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, prePostCdScriptHistoryServiceImpl, enforcerUtilImpl, deployedConfigurationHistoryServiceImpl) - pipelineStatusTimelineRestHandlerImpl := restHandler.NewPipelineStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) - pipelineConfigRouterImpl := router.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, appWorkflowRestHandlerImpl, webhookDataRestHandlerImpl, pipelineHistoryRestHandlerImpl, pipelineStatusTimelineRestHandlerImpl) - installedAppDBExtendedServiceImpl, err := FullMode.NewInstalledAppDBExtendedServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl, appStatusServiceImpl, pubSubClientServiceImpl) - if err != nil { - return nil, err - } - acdAuthConfig, err := util3.GetACDAuthConfig() - if err != nil { - return nil, err - } - k8sResourceHistoryRepositoryImpl := repository15.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) - k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) - ephemeralContainersRepositoryImpl := repository2.NewEphemeralContainersRepositoryImpl(db) - ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) - terminalSessionHandlerImpl := terminal.NewTerminalSessionHandlerImpl(environmentServiceImpl, clusterServiceImplExtended, sugaredLogger, k8sServiceImpl, ephemeralContainerServiceImpl) - k8sApplicationServiceImpl, err := application2.NewK8sApplicationServiceImpl(sugaredLogger, clusterServiceImplExtended, pumpImpl, helmAppServiceImpl, k8sServiceImpl, acdAuthConfig, k8sResourceHistoryServiceImpl, k8sCommonServiceImpl, terminalSessionHandlerImpl, ephemeralContainerServiceImpl, ephemeralContainersRepositoryImpl) - if err != nil { - return nil, err - } - installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl) - installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) - cdApplicationStatusUpdateHandlerImpl := cron2.NewCdApplicationStatusUpdateHandlerImpl(sugaredLogger, appServiceImpl, workflowDagExecutorImpl, installedAppDBServiceImpl, cdHandlerImpl, appServiceConfig, pubSubClientServiceImpl, pipelineStatusTimelineRepositoryImpl, eventRESTClientImpl, appListingRepositoryImpl, cdWorkflowRepositoryImpl, pipelineRepositoryImpl, installedAppVersionHistoryRepositoryImpl, installedAppRepositoryImpl, cronLoggerImpl) - appListingRestHandlerImpl := restHandler.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, clusterServiceImplExtended, helmAppServiceImpl, argoUserServiceImpl, k8sCommonServiceImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, environmentServiceImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, deploymentTemplateServiceImpl) - appListingRouterImpl := router.NewAppListingRouterImpl(appListingRestHandlerImpl) - chartRepositoryServiceImpl := chartRepo.NewChartRepositoryServiceImpl(sugaredLogger, chartRepoRepositoryImpl, k8sServiceImpl, clusterServiceImplExtended, acdAuthConfig, httpClient, serverEnvConfigServerEnvConfig) - deleteServiceExtendedImpl := delete2.NewDeleteServiceExtendedImpl(sugaredLogger, teamServiceImpl, clusterServiceImplExtended, environmentServiceImpl, appRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, chartRepositoryServiceImpl, installedAppRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) - environmentRestHandlerImpl := cluster3.NewEnvironmentRestHandlerImpl(environmentServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceExtendedImpl, k8sServiceImpl, k8sCommonServiceImpl) - environmentRouterImpl := cluster3.NewEnvironmentRouterImpl(environmentRestHandlerImpl) - clusterDescriptionRepositoryImpl := repository2.NewClusterDescriptionRepositoryImpl(db, sugaredLogger) - clusterDescriptionServiceImpl := cluster2.NewClusterDescriptionServiceImpl(clusterDescriptionRepositoryImpl, userRepositoryImpl, sugaredLogger) - clusterRbacServiceImpl := cluster2.NewClusterRbacServiceImpl(environmentServiceImpl, enforcerImpl, clusterServiceImplExtended, sugaredLogger, userServiceImpl) - clusterRestHandlerImpl := cluster3.NewClusterRestHandlerImpl(clusterServiceImplExtended, genericNoteServiceImpl, clusterDescriptionServiceImpl, sugaredLogger, userServiceImpl, validate, enforcerImpl, deleteServiceExtendedImpl, argoUserServiceImpl, environmentServiceImpl, clusterRbacServiceImpl) - clusterRouterImpl := cluster3.NewClusterRouterImpl(clusterRestHandlerImpl) - gitWebhookRepositoryImpl := repository.NewGitWebhookRepositoryImpl(db) - gitWebhookServiceImpl := git2.NewGitWebhookServiceImpl(sugaredLogger, ciHandlerImpl, gitWebhookRepositoryImpl) - gitWebhookRestHandlerImpl := restHandler.NewGitWebhookRestHandlerImpl(sugaredLogger, gitWebhookServiceImpl) + pipelineConfigRestHandlerImpl := configure.NewPipelineRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, deploymentTemplateValidationServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, deploymentTemplateServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, gitProviderRepositoryImpl, argoUserServiceImpl, ciPipelineMaterialRepositoryImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) webhookServiceImpl := pipeline.NewWebhookServiceImpl(ciArtifactRepositoryImpl, sugaredLogger, ciPipelineRepositoryImpl, appServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl, ciWorkflowRepositoryImpl, workflowDagExecutorImpl, ciHandlerImpl, pipelineStageRepositoryImpl, globalPluginRepositoryImpl, customTagServiceImpl) ciEventConfig, err := pubsub.GetCiEventConfig() if err != nil { @@ -590,35 +573,23 @@ func InitializeApp() (*App, error) { return nil, err } userAuthRouterImpl := user2.NewUserAuthRouterImpl(sugaredLogger, userAuthHandlerImpl, userAuthOidcHelperImpl) - argoApplicationRestHandlerImpl := restHandler.NewArgoApplicationRestHandlerImpl(applicationServiceClientImpl, pumpImpl, enforcerImpl, teamServiceImpl, environmentServiceImpl, sugaredLogger, enforcerUtilImpl, terminalSessionHandlerImpl, argoUserServiceImpl, k8sResourceHistoryServiceImpl, userServiceImpl) - applicationRouterImpl := router.NewApplicationRouterImpl(argoApplicationRestHandlerImpl, sugaredLogger) - argoConfig, err := ArgoUtil.GetArgoConfig() - if err != nil { - return nil, err - } - argoSession, err := ArgoUtil.NewArgoSession(argoConfig, sugaredLogger) - if err != nil { - return nil, err - } - resourceServiceImpl := ArgoUtil.NewResourceServiceImpl(argoSession) - cdRestHandlerImpl := restHandler.NewCDRestHandlerImpl(sugaredLogger, resourceServiceImpl) - cdRouterImpl := router.NewCDRouterImpl(sugaredLogger, cdRestHandlerImpl) + gitRegistryConfigImpl := pipeline.NewGitRegistryConfigImpl(sugaredLogger, gitProviderRepositoryImpl, clientImpl) deleteServiceFullModeImpl := delete2.NewDeleteServiceFullModeImpl(sugaredLogger, materialRepositoryImpl, gitRegistryConfigImpl, ciTemplateRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) gitProviderRestHandlerImpl := restHandler.NewGitProviderRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, deleteServiceFullModeImpl) gitProviderRouterImpl := router.NewGitProviderRouterImpl(gitProviderRestHandlerImpl) - gitHostRepositoryImpl := repository.NewGitHostRepositoryImpl(db) + gitHostRepositoryImpl := repository2.NewGitHostRepositoryImpl(db) gitHostConfigImpl := pipeline.NewGitHostConfigImpl(gitHostRepositoryImpl, sugaredLogger, attributesServiceImpl) gitHostRestHandlerImpl := restHandler.NewGitHostRestHandlerImpl(sugaredLogger, gitHostConfigImpl, userServiceImpl, validate, enforcerImpl, clientImpl, gitRegistryConfigImpl) gitHostRouterImpl := router.NewGitHostRouterImpl(gitHostRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) dockerRegRestHandlerExtendedImpl := restHandler.NewDockerRegRestHandlerExtendedImpl(dockerRegistryConfigImpl, sugaredLogger, chartProviderServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, deleteServiceExtendedImpl, deleteServiceFullModeImpl) dockerRegRouterImpl := router.NewDockerRegRouterImpl(dockerRegRestHandlerExtendedImpl) - notificationSettingsRepositoryImpl := repository.NewNotificationSettingsRepositoryImpl(db) + notificationSettingsRepositoryImpl := repository2.NewNotificationSettingsRepositoryImpl(db) notificationConfigBuilderImpl := notifier.NewNotificationConfigBuilderImpl(sugaredLogger) - slackNotificationRepositoryImpl := repository.NewSlackNotificationRepositoryImpl(db) - webhookNotificationRepositoryImpl := repository.NewWebhookNotificationRepositoryImpl(db) - sesNotificationRepositoryImpl := repository.NewSESNotificationRepositoryImpl(db) - smtpNotificationRepositoryImpl := repository.NewSMTPNotificationRepositoryImpl(db) + slackNotificationRepositoryImpl := repository2.NewSlackNotificationRepositoryImpl(db) + webhookNotificationRepositoryImpl := repository2.NewWebhookNotificationRepositoryImpl(db) + sesNotificationRepositoryImpl := repository2.NewSESNotificationRepositoryImpl(db) + smtpNotificationRepositoryImpl := repository2.NewSMTPNotificationRepositoryImpl(db) notificationConfigServiceImpl := notifier.NewNotificationConfigServiceImpl(sugaredLogger, notificationSettingsRepositoryImpl, notificationConfigBuilderImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, slackNotificationRepositoryImpl, webhookNotificationRepositoryImpl, sesNotificationRepositoryImpl, smtpNotificationRepositoryImpl, teamRepositoryImpl, environmentRepositoryImpl, appRepositoryImpl, userRepositoryImpl, ciPipelineMaterialRepositoryImpl) slackNotificationServiceImpl := notifier.NewSlackNotificationServiceImpl(sugaredLogger, slackNotificationRepositoryImpl, webhookNotificationRepositoryImpl, teamServiceImpl, userRepositoryImpl, notificationSettingsRepositoryImpl) webhookNotificationServiceImpl := notifier.NewWebhookNotificationServiceImpl(sugaredLogger, webhookNotificationRepositoryImpl, teamServiceImpl, userRepositoryImpl, notificationSettingsRepositoryImpl) @@ -630,7 +601,11 @@ func InitializeApp() (*App, error) { teamRouterImpl := team2.NewTeamRouterImpl(teamRestHandlerImpl) gitWebhookHandlerImpl := pubsub.NewGitWebhookHandler(sugaredLogger, pubSubClientServiceImpl, gitWebhookServiceImpl) workflowStatusUpdateHandlerImpl := pubsub.NewWorkflowStatusUpdateHandlerImpl(sugaredLogger, pubSubClientServiceImpl, ciHandlerImpl, cdHandlerImpl, eventSimpleFactoryImpl, eventRESTClientImpl, cdWorkflowRepositoryImpl) - chartGroupDeploymentRepositoryImpl := repository16.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) + installedAppDBExtendedServiceImpl, err := FullMode.NewInstalledAppDBExtendedServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl, appStatusServiceImpl, pubSubClientServiceImpl) + if err != nil { + return nil, err + } + chartGroupDeploymentRepositoryImpl := repository15.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) @@ -648,14 +623,26 @@ func InitializeApp() (*App, error) { chartRefRouterImpl := router.NewChartRefRouterImpl(chartRefRestHandlerImpl) configMapRestHandlerImpl := restHandler.NewConfigMapRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, pipelineRepositoryImpl, enforcerUtilImpl, configMapServiceImpl) configMapRouterImpl := router.NewConfigMapRouterImpl(configMapRestHandlerImpl) - chartGroupEntriesRepositoryImpl := repository16.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) - chartGroupReposotoryImpl := repository16.NewChartGroupReposotoryImpl(db, sugaredLogger) + k8sResourceHistoryRepositoryImpl := repository16.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) + ephemeralContainersRepositoryImpl := repository.NewEphemeralContainersRepositoryImpl(db) + ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) + terminalSessionHandlerImpl := terminal.NewTerminalSessionHandlerImpl(environmentServiceImpl, clusterServiceImplExtended, sugaredLogger, k8sServiceImpl, ephemeralContainerServiceImpl) + k8sApplicationServiceImpl, err := application2.NewK8sApplicationServiceImpl(sugaredLogger, clusterServiceImplExtended, pumpImpl, helmAppServiceImpl, k8sServiceImpl, acdAuthConfig, k8sResourceHistoryServiceImpl, k8sCommonServiceImpl, terminalSessionHandlerImpl, ephemeralContainerServiceImpl, ephemeralContainersRepositoryImpl) + if err != nil { + return nil, err + } + installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, helmAppClientImpl, helmAppServiceImpl, appStatusServiceImpl, k8sServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl) + chartGroupEntriesRepositoryImpl := repository15.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) + chartGroupReposotoryImpl := repository15.NewChartGroupReposotoryImpl(db, sugaredLogger) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) appStoreValuesServiceImpl := service3.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, environmentServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl) if err != nil { return nil, err } + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) + cdApplicationStatusUpdateHandlerImpl := cron2.NewCdApplicationStatusUpdateHandlerImpl(sugaredLogger, appServiceImpl, workflowDagExecutorImpl, installedAppDBServiceImpl, cdHandlerImpl, appServiceConfig, pubSubClientServiceImpl, pipelineStatusTimelineRepositoryImpl, eventRESTClientImpl, appListingRepositoryImpl, cdWorkflowRepositoryImpl, pipelineRepositoryImpl, installedAppVersionHistoryRepositoryImpl, installedAppRepositoryImpl, cronLoggerImpl) installedAppRestHandlerImpl := appStore.NewInstalledAppRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, chartGroupServiceImpl, validate, clusterServiceImplExtended, applicationServiceClientImpl, appStoreDeploymentServiceImpl, helmAppClientImpl, argoUserServiceImpl, cdApplicationStatusUpdateHandlerImpl, installedAppRepositoryImpl, appCrudOperationServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) @@ -681,6 +668,8 @@ func InitializeApp() (*App, error) { releaseDataServiceImpl := app2.NewReleaseDataServiceImpl(pipelineOverrideRepositoryImpl, sugaredLogger, ciPipelineMaterialRepositoryImpl, eventRESTClientImpl, lensClientImpl) releaseMetricsRestHandlerImpl := restHandler.NewReleaseMetricsRestHandlerImpl(sugaredLogger, enforcerImpl, releaseDataServiceImpl, userServiceImpl, teamServiceImpl, pipelineRepositoryImpl, enforcerUtilImpl) releaseMetricsRouterImpl := router.NewReleaseMetricsRouterImpl(sugaredLogger, releaseMetricsRestHandlerImpl) + deploymentGroupAppRepositoryImpl := repository2.NewDeploymentGroupAppRepositoryImpl(sugaredLogger, db) + deploymentGroupServiceImpl := deploymentGroup.NewDeploymentGroupServiceImpl(appRepositoryImpl, sugaredLogger, pipelineRepositoryImpl, ciPipelineRepositoryImpl, deploymentGroupRepositoryImpl, environmentRepositoryImpl, deploymentGroupAppRepositoryImpl, ciArtifactRepositoryImpl, appWorkflowRepositoryImpl, workflowDagExecutorImpl) deploymentGroupRestHandlerImpl := restHandler.NewDeploymentGroupRestHandlerImpl(deploymentGroupServiceImpl, sugaredLogger, validate, enforcerImpl, teamServiceImpl, userServiceImpl, enforcerUtilImpl) deploymentGroupRouterImpl := router.NewDeploymentGroupRouterImpl(deploymentGroupRestHandlerImpl) buildActionImpl := batch.NewBuildActionImpl(pipelineBuilderImpl, sugaredLogger, appRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineRepositoryImpl, materialRepositoryImpl) @@ -708,7 +697,7 @@ func InitializeApp() (*App, error) { dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) attributesRestHandlerImpl := restHandler.NewAttributesRestHandlerImpl(sugaredLogger, enforcerImpl, userServiceImpl, attributesServiceImpl) attributesRouterImpl := router.NewAttributesRouterImpl(attributesRestHandlerImpl) - userAttributesRepositoryImpl := repository.NewUserAttributesRepositoryImpl(db) + userAttributesRepositoryImpl := repository2.NewUserAttributesRepositoryImpl(db) userAttributesServiceImpl := attributes.NewUserAttributesServiceImpl(sugaredLogger, userAttributesRepositoryImpl) userAttributesRestHandlerImpl := restHandler.NewUserAttributesRestHandlerImpl(sugaredLogger, enforcerImpl, userServiceImpl, userAttributesServiceImpl) userAttributesRouterImpl := router.NewUserAttributesRouterImpl(userAttributesRestHandlerImpl) @@ -742,10 +731,32 @@ func InitializeApp() (*App, error) { bulkUpdateRestHandlerImpl := restHandler.NewBulkUpdateRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, bulkUpdateServiceImpl, chartServiceImpl, propertiesConfigServiceImpl, applicationServiceClientImpl, userServiceImpl, teamServiceImpl, enforcerImpl, ciHandlerImpl, validate, clientImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl, cdHandlerImpl, appCloneServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, policyServiceImpl, imageScanResultRepositoryImpl, argoUserServiceImpl) bulkUpdateRouterImpl := router.NewBulkUpdateRouterImpl(bulkUpdateRestHandlerImpl) webhookSecretValidatorImpl := git2.NewWebhookSecretValidatorImpl(sugaredLogger) + webhookEventDataRepositoryImpl := repository2.NewWebhookEventDataRepositoryImpl(db) + webhookEventDataConfigImpl := pipeline.NewWebhookEventDataConfigImpl(sugaredLogger, webhookEventDataRepositoryImpl) webhookEventHandlerImpl := restHandler.NewWebhookEventHandlerImpl(sugaredLogger, gitHostConfigImpl, eventRESTClientImpl, webhookSecretValidatorImpl, webhookEventDataConfigImpl) webhookListenerRouterImpl := router.NewWebhookListenerRouterImpl(webhookEventHandlerImpl) - appRestHandlerImpl := restHandler.NewAppRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) - appRouterImpl := router.NewAppRouterImpl(sugaredLogger, appRestHandlerImpl) + appFilteringRestHandlerImpl := appList.NewAppFilteringRestHandlerImpl(sugaredLogger, teamServiceImpl, enforcerImpl, userServiceImpl, clusterServiceImplExtended, environmentServiceImpl) + appFilteringRouterImpl := appList2.NewAppFilteringRouterImpl(appFilteringRestHandlerImpl) + appListingRestHandlerImpl := appList.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, helmAppServiceImpl, argoUserServiceImpl, k8sCommonServiceImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, deploymentTemplateServiceImpl) + appListingRouterImpl := appList2.NewAppListingRouterImpl(appListingRestHandlerImpl) + appInfoRestHandlerImpl := appInfo.NewAppInfoRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) + appInfoRouterImpl := appInfo2.NewAppInfoRouterImpl(sugaredLogger, appInfoRestHandlerImpl) + deploymentConfigServiceImpl := pipeline.NewDeploymentConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, pipelineRepositoryImpl, pipelineConfigRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl, scopedVariableCMCSManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) + pipelineTriggerRestHandlerImpl := trigger.NewPipelineRestHandler(appServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, sugaredLogger, enforcerUtilImpl, workflowDagExecutorImpl, deploymentGroupServiceImpl, argoUserServiceImpl, deploymentConfigServiceImpl) + sseSSE := sse.NewSSE() + pipelineTriggerRouterImpl := trigger2.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) + webhookDataRestHandlerImpl := webhook.NewWebhookDataRestHandlerImpl(sugaredLogger, userServiceImpl, ciPipelineMaterialRepositoryImpl, enforcerUtilImpl, enforcerImpl, clientImpl, webhookEventDataConfigImpl) + pipelineConfigRouterImpl := configure2.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, webhookDataRestHandlerImpl) + deployedConfigurationHistoryServiceImpl := history.NewDeployedConfigurationHistoryServiceImpl(sugaredLogger, userServiceImpl, deploymentTemplateHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, cdWorkflowRepositoryImpl) + pipelineHistoryRestHandlerImpl := history2.NewPipelineHistoryRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, pipelineStrategyHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, prePostCdScriptHistoryServiceImpl, enforcerUtilImpl, deployedConfigurationHistoryServiceImpl) + pipelineHistoryRouterImpl := history3.NewPipelineHistoryRouterImpl(pipelineHistoryRestHandlerImpl) + pipelineStatusTimelineRestHandlerImpl := status2.NewPipelineStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) + pipelineStatusRouterImpl := status3.NewPipelineStatusRouterImpl(pipelineStatusTimelineRestHandlerImpl) + appWorkflowRestHandlerImpl := workflow.NewAppWorkflowRestHandlerImpl(sugaredLogger, userServiceImpl, appWorkflowServiceImpl, teamServiceImpl, enforcerImpl, pipelineBuilderImpl, appRepositoryImpl, enforcerUtilImpl) + appWorkflowRouterImpl := workflow2.NewAppWorkflowRouterImpl(appWorkflowRestHandlerImpl) + devtronAppAutoCompleteRestHandlerImpl := pipeline2.NewDevtronAppAutoCompleteRestHandlerImpl(sugaredLogger, userServiceImpl, teamServiceImpl, enforcerImpl, enforcerUtilImpl, devtronAppConfigServiceImpl, environmentServiceImpl, gitRegistryConfigImpl, dockerRegistryConfigImpl) + devtronAppAutoCompleteRouterImpl := pipeline3.NewDevtronAppAutoCompleteRouterImpl(devtronAppAutoCompleteRestHandlerImpl) + appRouterImpl := app3.NewAppRouterImpl(appFilteringRouterImpl, appListingRouterImpl, appInfoRouterImpl, pipelineTriggerRouterImpl, pipelineConfigRouterImpl, pipelineHistoryRouterImpl, pipelineStatusRouterImpl, appWorkflowRouterImpl, devtronAppAutoCompleteRouterImpl, appWorkflowRestHandlerImpl, appListingRestHandlerImpl, appFilteringRestHandlerImpl) coreAppRestHandlerImpl := restHandler.NewCoreAppRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, appCrudOperationServiceImpl, pipelineBuilderImpl, gitRegistryConfigImpl, chartServiceImpl, configMapServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, appWorkflowServiceImpl, materialRepositoryImpl, gitProviderRepositoryImpl, appWorkflowRepositoryImpl, environmentRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, teamServiceImpl, argoUserServiceImpl, pipelineStageServiceImpl, ciPipelineRepositoryImpl) coreAppRouterImpl := router.NewCoreAppRouterImpl(coreAppRestHandlerImpl) helmAppRestHandlerImpl := client3.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImplExtended, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) @@ -794,7 +805,7 @@ func InitializeApp() (*App, error) { webhookHelmRouterImpl := webhookHelm2.NewWebhookHelmRouterImpl(webhookHelmRestHandlerImpl) globalCMCSRestHandlerImpl := restHandler.NewGlobalCMCSRestHandlerImpl(sugaredLogger, userServiceImpl, validate, enforcerImpl, globalCMCSServiceImpl) globalCMCSRouterImpl := router.NewGlobalCMCSRouterImpl(globalCMCSRestHandlerImpl) - terminalAccessRepositoryImpl := repository.NewTerminalAccessRepositoryImpl(db, sugaredLogger) + terminalAccessRepositoryImpl := repository2.NewTerminalAccessRepositoryImpl(db, sugaredLogger) userTerminalSessionConfig, err := clusterTerminalAccess.GetTerminalAccessConfig() if err != nil { return nil, err @@ -828,7 +839,7 @@ func InitializeApp() (*App, error) { return nil, err } proxyRouterImpl := proxy.NewProxyRouterImpl(sugaredLogger, proxyConfig, enforcerImpl) - muxRouter := router.NewMuxRouter(sugaredLogger, pipelineTriggerRouterImpl, pipelineConfigRouterImpl, appListingRouterImpl, environmentRouterImpl, clusterRouterImpl, webhookRouterImpl, userAuthRouterImpl, applicationRouterImpl, cdRouterImpl, gitProviderRouterImpl, gitHostRouterImpl, dockerRegRouterImpl, notificationRouterImpl, teamRouterImpl, gitWebhookHandlerImpl, workflowStatusUpdateHandlerImpl, applicationStatusHandlerImpl, ciEventHandlerImpl, pubSubClientServiceImpl, userRouterImpl, chartRefRouterImpl, configMapRouterImpl, appStoreRouterImpl, chartRepositoryRouterImpl, releaseMetricsRouterImpl, deploymentGroupRouterImpl, batchOperationRouterImpl, chartGroupRouterImpl, imageScanRouterImpl, policyRouterImpl, gitOpsConfigRouterImpl, dashboardRouterImpl, attributesRouterImpl, userAttributesRouterImpl, commonRouterImpl, grafanaRouterImpl, ssoLoginRouterImpl, telemetryRouterImpl, telemetryEventClientImplExtended, bulkUpdateRouterImpl, webhookListenerRouterImpl, appRouterImpl, coreAppRouterImpl, helmAppRouterImpl, k8sApplicationRouterImpl, pProfRouterImpl, deploymentConfigRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, globalPluginRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, cdApplicationStatusUpdateHandlerImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, globalCMCSRouterImpl, userTerminalAccessRouterImpl, jobRouterImpl, ciStatusUpdateCronImpl, resourceGroupingRouterImpl, rbacRoleRouterImpl, scopedVariableRouterImpl, ciTriggerCronImpl, proxyRouterImpl) + muxRouter := router.NewMuxRouter(sugaredLogger, environmentRouterImpl, clusterRouterImpl, webhookRouterImpl, userAuthRouterImpl, gitProviderRouterImpl, gitHostRouterImpl, dockerRegRouterImpl, notificationRouterImpl, teamRouterImpl, gitWebhookHandlerImpl, workflowStatusUpdateHandlerImpl, applicationStatusHandlerImpl, ciEventHandlerImpl, pubSubClientServiceImpl, userRouterImpl, chartRefRouterImpl, configMapRouterImpl, appStoreRouterImpl, chartRepositoryRouterImpl, releaseMetricsRouterImpl, deploymentGroupRouterImpl, batchOperationRouterImpl, chartGroupRouterImpl, imageScanRouterImpl, policyRouterImpl, gitOpsConfigRouterImpl, dashboardRouterImpl, attributesRouterImpl, userAttributesRouterImpl, commonRouterImpl, grafanaRouterImpl, ssoLoginRouterImpl, telemetryRouterImpl, telemetryEventClientImplExtended, bulkUpdateRouterImpl, webhookListenerRouterImpl, appRouterImpl, coreAppRouterImpl, helmAppRouterImpl, k8sApplicationRouterImpl, pProfRouterImpl, deploymentConfigRouterImpl, dashboardTelemetryRouterImpl, commonDeploymentRouterImpl, externalLinkRouterImpl, globalPluginRouterImpl, moduleRouterImpl, serverRouterImpl, apiTokenRouterImpl, cdApplicationStatusUpdateHandlerImpl, k8sCapacityRouterImpl, webhookHelmRouterImpl, globalCMCSRouterImpl, userTerminalAccessRouterImpl, jobRouterImpl, ciStatusUpdateCronImpl, resourceGroupingRouterImpl, rbacRoleRouterImpl, scopedVariableRouterImpl, ciTriggerCronImpl, proxyRouterImpl) loggingMiddlewareImpl := util4.NewLoggingMiddlewareImpl(userServiceImpl) mainApp := NewApp(muxRouter, sugaredLogger, sseSSE, syncedEnforcer, db, pubSubClientServiceImpl, sessionManager, posthogClient, loggingMiddlewareImpl) return mainApp, nil From 23ac4a7e798440c680a6d9cd23fbead9c11eaa08 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Thu, 1 Feb 2024 01:51:26 +0530 Subject: [PATCH 49/83] chore: sanity after ent sync --- pkg/appStore/deployment/adapter/Adapter.go | 20 ++++++++++++++----- .../tool/AppStoreDeploymentGitOpsService.go | 5 +---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pkg/appStore/deployment/adapter/Adapter.go b/pkg/appStore/deployment/adapter/Adapter.go index c21f87e8ff..75dd265781 100644 --- a/pkg/appStore/deployment/adapter/Adapter.go +++ b/pkg/appStore/deployment/adapter/Adapter.go @@ -5,6 +5,7 @@ import ( appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "k8s.io/helm/pkg/proto/hapi/chart" + "path" ) func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, repoURl string, tempRefChart string) *bean.PushChartToGitRequestDTO { @@ -18,9 +19,18 @@ func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersi } } -func ParseChartCreateRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, chartPath string) *util.ChartCreateRequest { - return &util.ChartCreateRequest{ChartMetaData: &chart.Metadata{ - Name: installAppRequestDTO.AppName, - Version: "1.0.1", - }, ChartPath: chartPath} +func ParseChartCreateRequest(appName string) *util.ChartCreateRequest { + chartPath := getRefProxyChartPath() + return &util.ChartCreateRequest{ + ChartMetaData: &chart.Metadata{ + Name: appName, + Version: "1.0.1", + }, + ChartPath: chartPath, + } +} + +func getRefProxyChartPath() string { + template := appStoreBean.CHART_PROXY_TEMPLATE + return path.Join(appStoreBean.RefChartProxyDirPath, template) } diff --git a/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go b/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go index 70f90401c9..4370d3e205 100644 --- a/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go +++ b/pkg/appStore/deployment/tool/AppStoreDeploymentGitOpsService.go @@ -16,7 +16,6 @@ import ( "github.com/microsoft/azure-devops-go-api/azuredevops" "github.com/xanzy/go-gitlab" "net/http" - "path" "regexp" ) @@ -201,9 +200,7 @@ func (impl AppStoreDeploymentArgoCdServiceImpl) updateRequirementYamlInGit(insta // createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml func (impl AppStoreDeploymentArgoCdServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { - template := appStoreBean.CHART_PROXY_TEMPLATE - chartPath := path.Join(appStoreBean.RefChartProxyDirPath, template) - chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest, chartPath) + chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest.AppName) chartCreateResponse, err := impl.appStoreDeploymentCommonService.CreateChartProxyAndGetPath(chartCreateRequest) if err != nil { impl.Logger.Errorw("Error in building chart proxy", "err", err) From a96ef3eed59d80ebd9976adc5959039325c8ce20 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Thu, 1 Feb 2024 13:17:29 +0530 Subject: [PATCH 50/83] added: todo comment --- pkg/chartRepo/ChartRepositoryService.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/chartRepo/ChartRepositoryService.go b/pkg/chartRepo/ChartRepositoryService.go index e529c28e6d..b722dee023 100644 --- a/pkg/chartRepo/ChartRepositoryService.go +++ b/pkg/chartRepo/ChartRepositoryService.go @@ -199,6 +199,14 @@ func (impl *ChartRepositoryServiceImpl) CreateChartRepo(request *ChartRepoDto) ( secretData := impl.CreateSecretDataForHelmChart(request, isPrivateChart) _, err = impl.K8sUtil.CreateSecret(impl.aCDAuthConfig.ACDConfigMapNamespace, nil, chartRepo.Name, "", client, secretLabel, secretData) if err != nil { + // TODO refactoring: Implement the below error handling if secret name already exists + //if statusError, ok := err.(*k8sErrors.StatusError); ok && + // statusError != nil && + // statusError.Status().Code == http.StatusConflict && + // statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists { + // impl.logger.Errorw("secret already exists", "err", statusError.Error()) + // return nil, fmt.Errorf(statusError.Error()) + //} continue } if err == nil { From 6df287a7b12d6e21da7d1bebd6ed1b93b55247ad Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Fri, 2 Feb 2024 14:36:20 +0530 Subject: [PATCH 51/83] added: todo comment --- pkg/appStore/chartGroup/ChartGroupService.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index d22b66a58d..17257ef629 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -606,6 +606,7 @@ func (impl *ChartGroupServiceImpl) DeployBulk(chartGroupInstallRequest *ChartGro } //nats event impl.triggerDeploymentEvent(installAppVersions) + // TODO refactoring: why empty obj ?? return &ChartGroupInstallAppRes{}, nil } @@ -870,7 +871,7 @@ func (impl *ChartGroupServiceImpl) deployDefaultComponent(chartGroupInstallReque } } } - + // TODO refactoring: why empty obj ?? return &ChartGroupInstallAppRes{}, nil } From 0bb64f8cfda0b005abb6c5554d7d772fe4993509 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 5 Feb 2024 14:53:28 +0530 Subject: [PATCH 52/83] chore: fixed gitops auto fix operations in upgrade helm charts --- .../service/AppStoreDeploymentService.go | 42 +---- .../service/EAMode/EAModeDeploymentService.go | 9 +- .../deployment/InstalledAppGitOpsService.go | 151 +++++++++++------- 3 files changed, 103 insertions(+), 99 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index a752b112f3..70aedf2bd5 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -1199,43 +1199,11 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex argocdAppName := installedApp.App.AppName + "-" + installedApp.Environment.Name installAppVersionRequest.ACDAppName = argocdAppName - var createRepoErr, requirementsCommitErr, valuesCommitErr error - var gitHash string - // TODO refactoring: move this logic to AppStoreDeploymentGitService.go - if monoRepoMigrationRequired { - // create new git repo if repo name changed - gitOpsResponse, createRepoErr = impl.fullModeDeploymentService.GitOpsOperations(manifest, installAppVersionRequest) - gitHash = gitOpsResponse.GitHash - - } else if isChartChanged || isVersionChanged { - // update dependency if chart or chart version is changed - _, _, requirementsCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.RequirementsConfig) - gitHash, _, valuesCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.ValuesConfig) - - } else { - // only values are changed in update, so commit values config - gitHash, _, valuesCommitErr = impl.fullModeDeploymentService.CommitValues(manifest.ValuesConfig) - } - - if valuesCommitErr != nil || requirementsCommitErr != nil { - - noTargetFoundForValues, _ := impl.fullModeDeploymentService.ParseGitRepoErrorResponse(valuesCommitErr) - noTargetFoundForRequirements, _ := impl.fullModeDeploymentService.ParseGitRepoErrorResponse(requirementsCommitErr) - - if noTargetFoundForRequirements || noTargetFoundForValues { - //create repo again and try again - auto fix - monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required - gitOpsResponse, createRepoErr = impl.fullModeDeploymentService.GitOpsOperations(manifest, installAppVersionRequest) - gitHash = gitOpsResponse.GitHash - } - - } - - if createRepoErr != nil || requirementsCommitErr != nil || valuesCommitErr != nil { - impl.logger.Errorw("error in doing gitops operation", "err", err) - _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", err), time.Now(), tx) - // TODO refactoring: return proper err object - return nil, err + gitHash, gitOpsErr := impl.fullModeDeploymentService.UpdateAppGitOpsOperations(manifest, installAppVersionRequest, &monoRepoMigrationRequired, isChartChanged || isVersionChanged) + if gitOpsErr != nil { + impl.logger.Errorw("error in performing GitOps operation", "err", gitOpsErr) + _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", gitOpsErr), time.Now(), tx) + return nil, gitOpsErr } installAppVersionRequest.GitHash = gitHash diff --git a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 583ade35d1..59e7e40dc1 100644 --- a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -9,7 +9,6 @@ import ( repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "time" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" @@ -344,10 +343,6 @@ func (impl *EAModeDeploymentServiceImpl) UpdateValuesDependencies(installAppVers return errors.New("this is not implemented") } -func (impl *EAModeDeploymentServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { - return false, errors.New("this is not implemented") -} - func (impl *EAModeDeploymentServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { return nil, errors.New("this is not implemented") } @@ -364,6 +359,6 @@ func (impl *EAModeDeploymentServiceImpl) CheckIfArgoAppExists(acdAppName string) return isFound, errors.New("this is not implemented") } -func (impl *EAModeDeploymentServiceImpl) CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) { - return commitHash, commitTime, errors.New("this is not implemented") +func (impl *EAModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) { + return "", errors.New("this is not implemented") } diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go index e7ba6f424b..7122da4dd5 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go @@ -17,72 +17,23 @@ import ( "github.com/xanzy/go-gitlab" "net/http" "regexp" - "time" ) type InstalledAppGitOpsService interface { - // CommitValues will commit git.ChartConfig and returns commitHash - CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) - // ParseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) - ParseGitRepoErrorResponse(err error) (bool, error) // GitOpsOperations performs git operations specific to helm app deployments GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) // GenerateManifest returns bean.AppStoreManifestResponse required in GitOps GenerateManifest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (manifestResponse *bean.AppStoreManifestResponse, err error) // GenerateManifestAndPerformGitOperations is a wrapper function for both GenerateManifest and GitOpsOperations GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) + // UpdateAppGitOpsOperations internally uses + // GitOpsOperations (If Repo is deleted OR Repo migration is required) OR + // git.GitOperationService.CommitValues (If repo exists and Repo migration is not needed) + // functions to perform GitOps during upgrade deployments (GitOps based Helm Apps) + UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) } -func (impl *FullModeDeploymentServiceImpl) CommitValues(chartGitAttr *git.ChartConfig) (commitHash string, commitTime time.Time, err error) { - return impl.gitOperationService.CommitValues(chartGitAttr) -} - -func (impl *FullModeDeploymentServiceImpl) ParseGitRepoErrorResponse(err error) (bool, error) { - //update values yaml in chart - noTargetFound := false - if err != nil { - if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.Logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { - impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) - noTargetFound = true - } - if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { - impl.Logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) - noTargetFound = true - } - if err.Error() == git.BITBUCKET_REPO_NOT_FOUND_ERROR { - impl.Logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) - noTargetFound = true - } - } - return noTargetFound, err -} - -func (impl *FullModeDeploymentServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { - appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} - manifest, err := impl.GenerateManifest(installAppVersionRequest) - if err != nil { - impl.Logger.Errorw("error in performing manifest and git operations", "err", err) - return nil, err - } - gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) - if err != nil { - impl.Logger.Errorw("error in performing gitops operation", "err", err) - return nil, err - } - installAppVersionRequest.GitHash = gitOpsResponse.GitHash - appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute - return appStoreGitOpsResponse, nil -} - -// GitOpsOperations handles all git operations for Helm App +// GitOpsOperations handles all git operations for Helm App; and ensures that the return param bean.AppStoreGitOpsResponse is not nil func (impl *FullModeDeploymentServiceImpl) GitOpsOperations(manifestResponse *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} chartGitAttribute, isNew, githash, err := impl.createGitOpsRepoAndPushChart(installAppVersionRequest, manifestResponse.ChartResponse.BuiltChartPath, manifestResponse.RequirementsConfig, manifestResponse.ValuesConfig) @@ -129,6 +80,96 @@ func (impl *FullModeDeploymentServiceImpl) GenerateManifest(installAppVersionReq return manifestResponse, nil } +func (impl *FullModeDeploymentServiceImpl) GenerateManifestAndPerformGitOperations(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*bean.AppStoreGitOpsResponse, error) { + appStoreGitOpsResponse := &bean.AppStoreGitOpsResponse{} + manifest, err := impl.GenerateManifest(installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("error in performing manifest and git operations", "err", err) + return nil, err + } + gitOpsResponse, err := impl.GitOpsOperations(manifest, installAppVersionRequest) + if err != nil { + impl.Logger.Errorw("error in performing gitops operation", "err", err) + return nil, err + } + installAppVersionRequest.GitHash = gitOpsResponse.GitHash + appStoreGitOpsResponse.ChartGitAttribute = gitOpsResponse.ChartGitAttribute + return appStoreGitOpsResponse, nil +} + +func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) { + var requirementsCommitErr, valuesCommitErr error + var gitHash string + + if *monoRepoMigrationRequired { + return impl.performGitOpsAutoFix(manifest, installAppVersionRequest) + } + + if commitRequirements { + // update dependency if chart or chart version is changed + _, _, requirementsCommitErr = impl.gitOperationService.CommitValues(manifest.RequirementsConfig) + gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) + } else { + // only values are changed in update, so commit values config + gitHash, _, valuesCommitErr = impl.gitOperationService.CommitValues(manifest.ValuesConfig) + } + + if valuesCommitErr != nil || requirementsCommitErr != nil { + noTargetFoundForValues, _ := impl.parseGitRepoErrorResponse(valuesCommitErr) + noTargetFoundForRequirements, _ := impl.parseGitRepoErrorResponse(requirementsCommitErr) + if noTargetFoundForRequirements || noTargetFoundForValues { + //create repo again and try again - auto fix + *monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required + return impl.performGitOpsAutoFix(manifest, installAppVersionRequest) + } + impl.Logger.Errorw("error in performing GitOps for upgrade deployment", "ValuesCommitErr", valuesCommitErr, "RequirementsCommitErr", requirementsCommitErr) + return "", fmt.Errorf("error in committing values and requirements to git repository") + } + + return gitHash, nil +} + +// performGitOpsAutoFix is used for +// creating new repo (if not existing) and commit values and requirements in it. +func (impl *FullModeDeploymentServiceImpl) performGitOpsAutoFix(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, error) { + // create new git repo if repo name changed + gitOpsResponse, gitOpsRepoErr := impl.GitOpsOperations(manifest, installAppVersionRequest) + if gitOpsRepoErr != nil { + impl.Logger.Errorw("error in migrating GitOps repo", "err", gitOpsRepoErr) + return "", gitOpsRepoErr + } + return gitOpsResponse.GitHash, nil +} + +// parseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) +func (impl *FullModeDeploymentServiceImpl) parseGitRepoErrorResponse(err error) (bool, error) { + //update values yaml in chart + noTargetFound := false + if err != nil { + if errorResponse, ok := err.(*github.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on github, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*azuredevops.WrappedError); ok && *errorResponse.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo on azure, do auto fix", "error", err) + noTargetFound = true + } + if errorResponse, ok := err.(*gitlab.ErrorResponse); ok && errorResponse.Response.StatusCode == http.StatusNotFound { + impl.Logger.Errorw("no content found while updating git repo gitlab, do auto fix", "error", err) + noTargetFound = true + } + if err.Error() == git.BITBUCKET_REPO_NOT_FOUND_ERROR { + impl.Logger.Errorw("no content found while updating git repo bitbucket, do auto fix", "error", err) + noTargetFound = true + } + } + return noTargetFound, err +} + // createGitOpsRepoAndPushChart is a wrapper for creating GitOps repo and pushing chart to created repo func (impl *FullModeDeploymentServiceImpl) createGitOpsRepoAndPushChart(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, builtChartPath string, requirementsConfig *git.ChartConfig, valuesConfig *git.ChartConfig) (*commonBean.ChartGitAttribute, bool, string, error) { repoURL, isNew, err := impl.createGitOpsRepo(installAppVersionRequest) From 799f9f1a9e681a56721b2f6b0d2f184cddfd7cbe Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 5 Feb 2024 15:01:32 +0530 Subject: [PATCH 53/83] added: nit pointer issue for argocd resource tree --- client/argocdServer/application/ApplicationUtil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/argocdServer/application/ApplicationUtil.go b/client/argocdServer/application/ApplicationUtil.go index cbf7df2b6b..c7da79a5d9 100644 --- a/client/argocdServer/application/ApplicationUtil.go +++ b/client/argocdServer/application/ApplicationUtil.go @@ -102,7 +102,7 @@ func parseResult(resp *v1alpha1.ApplicationTree, query *application.ResourcesQue } } } - if node.Kind == "Pod" { + if node.Kind == "Pod" && node.NetworkingInfo != nil && node.NetworkingInfo.Labels != nil { relevantCR[prefix+"-"+node.NetworkingInfo.Labels["controller-revision-hash"]] = true } } From 50e199899a9daf56222d0bf95f7509a9ff69c3d0 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 5 Feb 2024 17:48:03 +0530 Subject: [PATCH 54/83] fixed: nil poniter issue for gitops in upgrade deployment --- .../service/AppStoreDeploymentService.go | 7 +++-- .../service/EAMode/EAModeDeploymentService.go | 4 +-- .../deployment/InstalledAppGitOpsService.go | 28 ++++++------------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 70aedf2bd5..ff6bb40622 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -1199,19 +1199,20 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex argocdAppName := installedApp.App.AppName + "-" + installedApp.Environment.Name installAppVersionRequest.ACDAppName = argocdAppName - gitHash, gitOpsErr := impl.fullModeDeploymentService.UpdateAppGitOpsOperations(manifest, installAppVersionRequest, &monoRepoMigrationRequired, isChartChanged || isVersionChanged) + var gitOpsErr error + gitOpsResponse, gitOpsErr = impl.fullModeDeploymentService.UpdateAppGitOpsOperations(manifest, installAppVersionRequest, &monoRepoMigrationRequired, isChartChanged || isVersionChanged) if gitOpsErr != nil { impl.logger.Errorw("error in performing GitOps operation", "err", gitOpsErr) _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT_FAILED, fmt.Sprintf("Git commit failed - %v", gitOpsErr), time.Now(), tx) return nil, gitOpsErr } - installAppVersionRequest.GitHash = gitHash + installAppVersionRequest.GitHash = gitOpsResponse.GitHash _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_GIT_COMMIT, "Git commit done successfully.", time.Now(), tx) if !impl.aCDConfig.ArgoCDAutoSyncEnabled { _ = impl.fullModeDeploymentService.SaveTimelineForHelmApps(installAppVersionRequest, pipelineConfig.TIMELINE_STATUS_ARGOCD_SYNC_INITIATED, "Argocd sync initiated", time.Now(), tx) } - installedAppVersionHistory.GitHash = gitHash + installedAppVersionHistory.GitHash = gitOpsResponse.GitHash _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, tx) if err != nil { impl.logger.Errorw("error on updating history for chart deployment", "error", err, "installedAppVersion", installedAppVersion) diff --git a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 59e7e40dc1..36b4ced1b9 100644 --- a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -359,6 +359,6 @@ func (impl *EAModeDeploymentServiceImpl) CheckIfArgoAppExists(acdAppName string) return isFound, errors.New("this is not implemented") } -func (impl *EAModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) { - return "", errors.New("this is not implemented") +func (impl *EAModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (*bean.AppStoreGitOpsResponse, error) { + return nil, errors.New("this is not implemented") } diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go index 7122da4dd5..ebc33e917d 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go @@ -30,7 +30,7 @@ type InstalledAppGitOpsService interface { // GitOpsOperations (If Repo is deleted OR Repo migration is required) OR // git.GitOperationService.CommitValues (If repo exists and Repo migration is not needed) // functions to perform GitOps during upgrade deployments (GitOps based Helm Apps) - UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) + UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (*bean.AppStoreGitOpsResponse, error) } // GitOpsOperations handles all git operations for Helm App; and ensures that the return param bean.AppStoreGitOpsResponse is not nil @@ -97,14 +97,14 @@ func (impl *FullModeDeploymentServiceImpl) GenerateManifestAndPerformGitOperatio return appStoreGitOpsResponse, nil } -func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (string, error) { +func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, monoRepoMigrationRequired *bool, commitRequirements bool) (*bean.AppStoreGitOpsResponse, error) { var requirementsCommitErr, valuesCommitErr error var gitHash string - if *monoRepoMigrationRequired { - return impl.performGitOpsAutoFix(manifest, installAppVersionRequest) + return impl.GitOpsOperations(manifest, installAppVersionRequest) } + gitOpsResponse := &bean.AppStoreGitOpsResponse{} if commitRequirements { // update dependency if chart or chart version is changed _, _, requirementsCommitErr = impl.gitOperationService.CommitValues(manifest.RequirementsConfig) @@ -120,25 +120,13 @@ func (impl *FullModeDeploymentServiceImpl) UpdateAppGitOpsOperations(manifest *b if noTargetFoundForRequirements || noTargetFoundForValues { //create repo again and try again - auto fix *monoRepoMigrationRequired = true // since repo is created again, will use this flag to check if ACD patch operation required - return impl.performGitOpsAutoFix(manifest, installAppVersionRequest) + return impl.GitOpsOperations(manifest, installAppVersionRequest) } impl.Logger.Errorw("error in performing GitOps for upgrade deployment", "ValuesCommitErr", valuesCommitErr, "RequirementsCommitErr", requirementsCommitErr) - return "", fmt.Errorf("error in committing values and requirements to git repository") - } - - return gitHash, nil -} - -// performGitOpsAutoFix is used for -// creating new repo (if not existing) and commit values and requirements in it. -func (impl *FullModeDeploymentServiceImpl) performGitOpsAutoFix(manifest *bean.AppStoreManifestResponse, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (string, error) { - // create new git repo if repo name changed - gitOpsResponse, gitOpsRepoErr := impl.GitOpsOperations(manifest, installAppVersionRequest) - if gitOpsRepoErr != nil { - impl.Logger.Errorw("error in migrating GitOps repo", "err", gitOpsRepoErr) - return "", gitOpsRepoErr + return nil, fmt.Errorf("error in committing values and requirements to git repository") } - return gitOpsResponse.GitHash, nil + gitOpsResponse.GitHash = gitHash + return gitOpsResponse, nil } // parseGitRepoErrorResponse will return noTargetFound (if git API returns 404 status) From 6915961b8c5f42594917cb4187a37abb66bb7bea Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Wed, 7 Feb 2024 00:12:47 +0530 Subject: [PATCH 55/83] chore: install Helm chart flow refactoring --- Wire.go | 6 +- .../deployment/wire_appStoreDeployment.go | 2 +- cmd/external-app/wire.go | 6 +- cmd/external-app/wire_gen.go | 20 +-- internal/sql/repository/app/AppRepository.go | 6 - internal/util/ChartTemplateService_test.go | 32 +--- pkg/app/AppService.go | 4 +- pkg/appClone/AppCloneService.go | 6 +- pkg/appStore/bean/bean.go | 1 - pkg/appStore/chartGroup/ChartGroupService.go | 47 +++-- pkg/appStore/chartGroup/bean.go | 15 +- .../service/AppStoreDeploymentDBService.go | 165 +++++++++--------- .../service/AppStoreDeploymentService.go | 81 ++++----- .../service/AppStoreDeploymentService_test.go | 12 +- pkg/attributes/AttributesService.go | 26 +++ pkg/auth/sso/SSOLoginService.go | 4 +- .../gitOps/config/GitOpsConfigReadService.go | 4 +- .../DeploymentTypeOverrideService.go | 117 +++++++++++++ .../wire_deploymentProviderConfig.go | 10 ++ pkg/deployment/wire_deployment.go | 2 + pkg/gitops/GitOpsConfigService.go | 4 +- .../DeploymentPipelineConfigService.go | 91 ++-------- pkg/pipeline/DevtronAppCMCSService.go | 29 --- pkg/pipeline/GitopsOrHelmOption_test.go | 23 +-- pkg/pipeline/PipelineBuilder.go | 28 --- util/GlobalConfig.go | 32 ++-- util/argo/ArgoUserService.go | 4 +- wire_gen.go | 36 ++-- 28 files changed, 394 insertions(+), 419 deletions(-) create mode 100644 pkg/deployment/providerConfig/DeploymentTypeOverrideService.go create mode 100644 pkg/deployment/providerConfig/wire_deploymentProviderConfig.go diff --git a/Wire.go b/Wire.go index dce534c9ff..8ce7cde9d3 100644 --- a/Wire.go +++ b/Wire.go @@ -172,6 +172,7 @@ func InitializeApp() (*App, error) { appStoreDiscover.AppStoreDiscoverWireSet, chartProvider.AppStoreChartProviderWireSet, appStoreValues.AppStoreValuesWireSet, + util2.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, server.ServerWireSet, module.ModuleWireSet, @@ -189,7 +190,6 @@ func InitializeApp() (*App, error) { helper.NewAppListingRepositoryQueryBuilder, //sql.GetConfig, eClient.GetEventClientConfig, - util2.GetGlobalEnvVariables, //sql.NewDbConnection, //app.GetACDAuthConfig, util3.GetACDAuthConfig, @@ -243,7 +243,7 @@ func InitializeApp() (*App, error) { app2.NewAppRepositoryImpl, wire.Bind(new(app2.AppRepository), new(*app2.AppRepositoryImpl)), - pipeline.GetDeploymentServiceTypeConfig, + //util2.GetEnvironmentVariables, pipeline.NewPipelineBuilderImpl, wire.Bind(new(pipeline.PipelineBuilder), new(*pipeline.PipelineBuilderImpl)), @@ -812,7 +812,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(connection.ArgoCDConnectionManager), new(*connection.ArgoCDConnectionManagerImpl)), argo.NewArgoUserServiceImpl, wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)), - util2.GetDevtronSecretName, + //util2.GetEnvironmentVariables, // AuthWireSet, cron.NewCdApplicationStatusUpdateHandlerImpl, diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 7897c45032..9e242377b7 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -10,7 +10,7 @@ import ( ) var AppStoreDeploymentWireSet = wire.NewSet( - service.GetDeploymentServiceTypeConfig, + //util.GetDeploymentServiceTypeConfig, repository.NewClusterInstalledAppsRepositoryImpl, wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index b0e804d812..2badbf7dd8 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -50,6 +50,7 @@ import ( "github.com/devtron-labs/devtron/pkg/attributes" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/pipeline" @@ -81,6 +82,7 @@ func InitializeApp() (*App, error) { appStoreDiscover.AppStoreDiscoverWireSet, chartProvider.AppStoreChartProviderWireSet, appStoreValues.AppStoreValuesWireSet, + util3.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, server.ServerWireSet, module.ModuleWireSet, @@ -88,9 +90,9 @@ func InitializeApp() (*App, error) { webhookHelm.WebhookHelmWireSet, terminal.TerminalWireSet, gitOps.GitOpsEAWireSet, + providerConfig.DeploymentProviderConfigWireSet, NewApp, NewMuxRouter, - util3.GetGlobalEnvVariables, util.NewHttpClient, util.NewSugardLogger, util.IntValidator, @@ -180,7 +182,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(attributes.UserAttributesService), new(*attributes.UserAttributesServiceImpl)), repository.NewUserAttributesRepositoryImpl, wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)), - util3.GetDevtronSecretName, + //util3.GetEnvironmentVariables, repository2.NewK8sResourceHistoryRepositoryImpl, wire.Bind(new(repository2.K8sResourceHistoryRepository), new(*repository2.K8sResourceHistoryRepositoryImpl)), diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 639fb9d4de..19c74cfe84 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -76,6 +76,7 @@ import ( "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/devtron-labs/devtron/pkg/genericNotes" repository6 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" @@ -156,7 +157,7 @@ func InitializeApp() (*App, error) { userServiceImpl := user.NewUserServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, sessionManager, userCommonServiceImpl, userAuditServiceImpl) ssoLoginRepositoryImpl := sso.NewSSOLoginRepositoryImpl(db) k8sServiceImpl := k8s.NewK8sUtil(sugaredLogger, runtimeConfig) - devtronSecretConfig, err := util2.GetDevtronSecretName() + environmentVariables, err := util2.GetEnvironmentVariables() if err != nil { return nil, err } @@ -166,7 +167,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - ssoLoginServiceImpl := sso.NewSSOLoginServiceImpl(sugaredLogger, ssoLoginRepositoryImpl, k8sServiceImpl, devtronSecretConfig, userAuthOidcHelperImpl) + ssoLoginServiceImpl := sso.NewSSOLoginServiceImpl(sugaredLogger, ssoLoginRepositoryImpl, k8sServiceImpl, environmentVariables, userAuthOidcHelperImpl) ssoLoginRestHandlerImpl := sso2.NewSsoLoginRestHandlerImpl(validate, sugaredLogger, enforcerImpl, userServiceImpl, ssoLoginServiceImpl) ssoLoginRouterImpl := sso2.NewSsoLoginRouterImpl(ssoLoginRestHandlerImpl) teamRepositoryImpl := team.NewTeamRepositoryImpl(db) @@ -245,23 +246,16 @@ func InitializeApp() (*App, error) { chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) - deploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() - if err != nil { - return nil, err - } acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - globalEnvVariables, err := util2.GetGlobalEnvVariables() - if err != nil { - return nil, err - } - gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, deploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) - installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, environmentVariables) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) + deploymentTypeOverrideServiceImpl := providerConfig.NewDeploymentTypeOverrideServiceImpl(sugaredLogger, environmentVariables, attributesServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sServiceImpl, clusterServiceImpl) diff --git a/internal/sql/repository/app/AppRepository.go b/internal/sql/repository/app/AppRepository.go index 538eae2654..e448570707 100644 --- a/internal/sql/repository/app/AppRepository.go +++ b/internal/sql/repository/app/AppRepository.go @@ -42,7 +42,6 @@ type App struct { } type AppRepository interface { - Save(pipelineGroup *App) error SaveWithTxn(pipelineGroup *App, tx *pg.Tx) error Update(app *App) error UpdateWithTxn(app *App, tx *pg.Tx) error @@ -99,11 +98,6 @@ func (repo AppRepositoryImpl) GetConnection() *pg.DB { return repo.dbConnection } -func (repo AppRepositoryImpl) Save(pipelineGroup *App) error { - err := repo.dbConnection.Insert(pipelineGroup) - return err -} - func (repo AppRepositoryImpl) SaveWithTxn(pipelineGroup *App, tx *pg.Tx) error { err := tx.Insert(pipelineGroup) return err diff --git a/internal/util/ChartTemplateService_test.go b/internal/util/ChartTemplateService_test.go index 7454cba73e..7e3be11420 100644 --- a/internal/util/ChartTemplateService_test.go +++ b/internal/util/ChartTemplateService_test.go @@ -2,7 +2,6 @@ package util import ( "context" - "github.com/devtron-labs/devtron/util" "github.com/stretchr/testify/assert" "k8s.io/helm/pkg/chartutil" chart2 "k8s.io/helm/pkg/proto/hapi/chart" @@ -29,9 +28,8 @@ func TestChartTemplateService(t *testing.T) { logger, err := NewSugardLogger() assert.Nil(t, err) impl := ChartTemplateServiceImpl{ - logger: logger, - randSource: rand.NewSource(0), - chartWorkingDir: "/tmp/charts/", + logger: logger, + randSource: rand.NewSource(0), } chartMetaData := &chart2.Metadata{ Name: "sample-app", @@ -52,9 +50,8 @@ func TestChartTemplateService(t *testing.T) { logger, err := NewSugardLogger() assert.Nil(t, err) impl := ChartTemplateServiceImpl{ - logger: logger, - randSource: rand.NewSource(0), - chartWorkingDir: "/tmp/charts/", + logger: logger, + randSource: rand.NewSource(0), } chartMetaData := &chart2.Metadata{ Name: "sample-app", @@ -76,9 +73,8 @@ func TestChartTemplateService(t *testing.T) { logger, err := NewSugardLogger() assert.Nil(t, err) impl := ChartTemplateServiceImpl{ - logger: logger, - randSource: rand.NewSource(0), - chartWorkingDir: "/tmp/charts/", + logger: logger, + randSource: rand.NewSource(0), } chartMetaData := &chart2.Metadata{ Name: "sample-app", @@ -97,20 +93,4 @@ func TestChartTemplateService(t *testing.T) { assert.NotEqual(t, chartBytesLen, 0) }) - - t.Run("GetGitOpsRepoName", func(t *testing.T) { - logger, err := NewSugardLogger() - assert.Nil(t, err) - globalEnvVariables, err := util.GetGlobalEnvVariables() - globalEnvVariables.GitOpsRepoPrefix = "devtron" - impl := ChartTemplateServiceImpl{ - logger: logger, - globalEnvVariables: globalEnvVariables, - } - appName := "sample" - wantedRepoName := "devtron-sample" - gitOpsRepoName := impl.GetGitOpsRepoName(appName) - assert.Equal(t, wantedRepoName, gitOpsRepoName) - }) - } diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index f100d4023e..04bc927976 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -174,7 +174,7 @@ func NewAppService( appStatusService appStatus.AppStatusService, installedAppRepository repository4.InstalledAppRepository, installedAppVersionHistoryRepository repository4.InstalledAppVersionHistoryRepository, - globalEnvVariables *util2.GlobalEnvVariables, + envVariables *util2.EnvironmentVariables, scopedVariableManager variables.ScopedVariableCMCSManager, acdConfig *argocdServer.ACDConfig, chartRefService chartRef.ChartRefService, gitOpsConfigReadService config.GitOpsConfigReadService, @@ -203,7 +203,7 @@ func NewAppService( appStatusService: appStatusService, installedAppRepository: installedAppRepository, installedAppVersionHistoryRepository: installedAppVersionHistoryRepository, - globalEnvVariables: globalEnvVariables, + globalEnvVariables: envVariables.GlobalEnvVariables, scopedVariableManager: scopedVariableManager, acdConfig: acdConfig, chartRefService: chartRefService, diff --git a/pkg/appClone/AppCloneService.go b/pkg/appClone/AppCloneService.go index 651ba84efb..47caeea1c6 100644 --- a/pkg/appClone/AppCloneService.go +++ b/pkg/appClone/AppCloneService.go @@ -29,6 +29,7 @@ import ( "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appWorkflow" + "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" @@ -45,6 +46,7 @@ type AppCloneService interface { type AppCloneServiceImpl struct { logger *zap.SugaredLogger pipelineBuilder pipeline.PipelineBuilder + attributesService attributes.AttributesService chartService chart.ChartService configMapService pipeline.ConfigMapService appWorkflowService appWorkflow.AppWorkflowService @@ -61,6 +63,7 @@ type AppCloneServiceImpl struct { func NewAppCloneServiceImpl(logger *zap.SugaredLogger, pipelineBuilder pipeline.PipelineBuilder, + attributesService attributes.AttributesService, chartService chart.ChartService, configMapService pipeline.ConfigMapService, appWorkflowService appWorkflow.AppWorkflowService, @@ -74,6 +77,7 @@ func NewAppCloneServiceImpl(logger *zap.SugaredLogger, return &AppCloneServiceImpl{ logger: logger, pipelineBuilder: pipelineBuilder, + attributesService: attributesService, chartService: chartService, configMapService: configMapService, appWorkflowService: appWorkflowService, @@ -976,7 +980,7 @@ func (impl *AppCloneServiceImpl) CreateCdPipeline(req *cloneCdPipelineRequest, c util.PIPELINE_DEPLOYMENT_TYPE_ACD: true, util.PIPELINE_DEPLOYMENT_TYPE_HELM: true, } - DeploymentAppConfigForEnvironment, err := impl.pipelineBuilder.GetDeploymentConfigMap(refCdPipeline.EnvironmentId) + DeploymentAppConfigForEnvironment, err := impl.attributesService.GetDeploymentEnforcementConfig(refCdPipeline.EnvironmentId) if err != nil { impl.logger.Errorw("error in fetching deployment config for environment", "err", err) } diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 86456bcfb9..8966e94726 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -81,7 +81,6 @@ type InstallAppVersionDTO struct { ACDAppName string `json:"-"` Environment *repository2.Environment `json:"-"` ChartGroupEntryId int `json:"-"` - DefaultClusterComponent bool `json:"-"` Status AppstoreDeploymentStatus `json:"-"` AppStoreId int `json:"appStoreId"` AppStoreName string `json:"appStoreName"` diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index 17257ef629..1052869bb3 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -30,6 +30,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app/status" + "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" @@ -68,6 +69,7 @@ type ChartGroupServiceImpl struct { appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository environmentRepository repository5.EnvironmentRepository teamRepository repository4.TeamRepository + clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository appStoreValuesService service.AppStoreValuesService pubSubClient *pubsub.PubSubClientServiceImpl envService cluster2.EnvironmentService @@ -89,6 +91,7 @@ func NewChartGroupServiceImpl(logger *zap.SugaredLogger, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository repository5.EnvironmentRepository, teamRepository repository4.TeamRepository, + clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appStoreValuesService service.AppStoreValuesService, pubSubClient *pubsub.PubSubClientServiceImpl, envService cluster2.EnvironmentService, @@ -109,6 +112,7 @@ func NewChartGroupServiceImpl(logger *zap.SugaredLogger, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, environmentRepository: environmentRepository, teamRepository: teamRepository, + clusterInstalledAppsRepository: clusterInstalledAppsRepository, appStoreValuesService: appStoreValuesService, pubSubClient: pubSubClient, envService: envService, @@ -577,7 +581,7 @@ func (impl *ChartGroupServiceImpl) DeployBulk(chartGroupInstallRequest *ChartGro // Rollback tx on error. defer tx.Rollback() for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) + installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx) if err != nil { impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) return nil, err @@ -620,16 +624,15 @@ func (impl *ChartGroupServiceImpl) requestBuilderForBulkDeployment(installReques valYaml = valVersion.Values } req := &appStoreBean.InstallAppVersionDTO{ - AppName: installRequest.AppName, - TeamId: projectId, - EnvironmentId: installRequest.EnvironmentId, - AppStoreVersion: installRequest.AppStoreVersion, - ValuesOverrideYaml: valYaml, - UserId: userId, - ReferenceValueId: installRequest.ReferenceValueId, - ReferenceValueKind: installRequest.ReferenceValueKind, - ChartGroupEntryId: installRequest.ChartGroupEntryId, - DefaultClusterComponent: installRequest.DefaultClusterComponent, + AppName: installRequest.AppName, + TeamId: projectId, + EnvironmentId: installRequest.EnvironmentId, + AppStoreVersion: installRequest.AppStoreVersion, + ValuesOverrideYaml: valYaml, + UserId: userId, + ReferenceValueId: installRequest.ReferenceValueId, + ReferenceValueKind: installRequest.ReferenceValueKind, + ChartGroupEntryId: installRequest.ChartGroupEntryId, } return req, nil } @@ -785,13 +788,12 @@ func (impl *ChartGroupServiceImpl) DeployDefaultChartOnCluster(bean *cluster2.Cl return false, err } chartGroupInstallChartRequest := &ChartGroupInstallChartRequest{ - AppName: fmt.Sprintf("%d-%d-%s", bean.Id, env.Id, item.Name), - EnvironmentId: env.Id, - ValuesOverrideYaml: item.Values, - AppStoreVersion: appStore.AppStoreApplicationVersionId, - ReferenceValueId: appStore.AppStoreApplicationVersionId, - ReferenceValueKind: appStoreBean.REFERENCE_TYPE_DEFAULT, - DefaultClusterComponent: true, + AppName: fmt.Sprintf("%d-%d-%s", bean.Id, env.Id, item.Name), + EnvironmentId: env.Id, + ValuesOverrideYaml: item.Values, + AppStoreVersion: appStore.AppStoreApplicationVersionId, + ReferenceValueId: appStore.AppStoreApplicationVersionId, + ReferenceValueKind: appStoreBean.REFERENCE_TYPE_DEFAULT, } chartGroupInstallChartRequests = append(chartGroupInstallChartRequests, chartGroupInstallChartRequest) } @@ -832,11 +834,18 @@ func (impl *ChartGroupServiceImpl) deployDefaultComponent(chartGroupInstallReque // Rollback tx on error. defer tx.Rollback() for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx, false) + installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx) if err != nil { impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) return nil, err } + // save installed_app and cluster_id mapping for default chart installation requests + clusterInstalledAppsModel := adapter.NewClusterInstalledAppsModel(installAppVersionDTO, installAppVersionDTO.Environment.ClusterId) + err = impl.clusterInstalledAppsRepository.Save(clusterInstalledAppsModel, tx) + if err != nil { + impl.logger.Errorw("error while creating cluster install app", "error", err) + return nil, err + } installAppVersions = append(installAppVersions, installAppVersionDTO) } if chartGroupInstallRequest.ChartGroupId > 0 { diff --git a/pkg/appStore/chartGroup/bean.go b/pkg/appStore/chartGroup/bean.go index c385e358da..e8a02258a8 100644 --- a/pkg/appStore/chartGroup/bean.go +++ b/pkg/appStore/chartGroup/bean.go @@ -9,14 +9,13 @@ type ChartGroupInstallRequest struct { } type ChartGroupInstallChartRequest struct { - AppName string `json:"appName,omitempty" validate:"name-component,max=100" ` - EnvironmentId int `json:"environmentId,omitempty" validate:"required,number" ` - AppStoreVersion int `json:"appStoreVersion,omitempty,notnull" validate:"required,number" ` - ValuesOverrideYaml string `json:"valuesOverrideYaml,omitempty"` //optional - ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` - ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED"` - ChartGroupEntryId int `json:"chartGroupEntryId"` //optional - DefaultClusterComponent bool `json:"-"` + AppName string `json:"appName,omitempty" validate:"name-component,max=100" ` + EnvironmentId int `json:"environmentId,omitempty" validate:"required,number" ` + AppStoreVersion int `json:"appStoreVersion,omitempty,notnull" validate:"required,number" ` + ValuesOverrideYaml string `json:"valuesOverrideYaml,omitempty"` //optional + ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` + ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED"` + ChartGroupEntryId int `json:"chartGroupEntryId"` //optional } type ChartGroupInstallAppRes struct { diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index 513bbe1f7e..056282e1a1 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -9,99 +9,42 @@ import ( "github.com/devtron-labs/devtron/pkg/bean" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" - "net/http" ) -func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) { - - var isInternalUse = impl.deploymentTypeConfig.IsInternalUse - - isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() +func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { + err := impl.setEnvironmentForInstallAppRequest(installAppVersionRequest) if err != nil { - impl.logger.Errorw("error while checking IsGitOpsConfigured", "err", err) + impl.logger.Errorw("error in getting environment for install helm chart", "envId", installAppVersionRequest.EnvironmentId, "err", err) return nil, err } - - if isInternalUse && !isGitOpsConfigured && installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_ACD { - impl.logger.Errorw("gitops not configured but selected for CD") - err := &util.ApiError{ - HttpStatusCode: http.StatusBadRequest, - InternalMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", - UserMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", + // Stage 1: Create App in tx (Only if AppId is not set already) + if installAppVersionRequest.AppId <= 0 { + appCreateRequest := &bean.CreateAppDTO{ + AppName: installAppVersionRequest.AppName, + TeamId: installAppVersionRequest.TeamId, + UserId: installAppVersionRequest.UserId, } - return nil, err - } - - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - - var isOCIRepo bool - if appStoreAppVersion.AppStore.DockerArtifactStore != nil { - isOCIRepo = true - } else { - isOCIRepo = false - } - - var appInstallationMode string - if util2.IsBaseStack() || util2.IsHelmApp(installAppVersionRequest.AppOfferingMode) { - appInstallationMode = util2.SERVER_MODE_HYPERION - } else { - appInstallationMode = util2.SERVER_MODE_FULL - } - - // create env if env not exists for clusterId and namespace for hyperion mode - if util2.IsHelmApp(appInstallationMode) { - envId, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) + appCreateRequest, err = impl.createAppForAppStore(appCreateRequest, tx, getAppInstallationMode(installAppVersionRequest.AppOfferingMode)) if err != nil { + impl.logger.Errorw("error while creating app", "error", err) return nil, err } - installAppVersionRequest.EnvironmentId = envId - } - - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err - } - installAppVersionRequest.Environment = environment - installAppVersionRequest.ACDAppName = fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.Environment.Name) - installAppVersionRequest.ClusterId = environment.ClusterId - appCreateRequest := &bean.CreateAppDTO{ - Id: installAppVersionRequest.AppId, - AppName: installAppVersionRequest.AppName, - TeamId: installAppVersionRequest.TeamId, - UserId: installAppVersionRequest.UserId, + installAppVersionRequest.AppId = appCreateRequest.Id } + // Stage 1: ends - appCreateRequest, err = impl.createAppForAppStore(appCreateRequest, tx, appInstallationMode, skipAppCreation) + // Stage 2: validate deployment app type and override if ExternallyManagedDeploymentType + err = impl.validateAndOverrideDeploymentAppType(installAppVersionRequest) if err != nil { - impl.logger.Errorw("error while creating app", "error", err) + impl.logger.Errorw("error in validating deployment app type", "error", err) return nil, err } - installAppVersionRequest.AppId = appCreateRequest.Id + // Stage 2: ends - if !isInternalUse { - if isGitOpsConfigured && appInstallationMode == util2.SERVER_MODE_FULL && !isOCIRepo { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - if installAppVersionRequest.DeploymentAppType == "" { - if isGitOpsConfigured && !isOCIRepo { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - - if util2.IsFullStack() { + // Stage 3: save installed_apps model + if util2.IsFullStack() && util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { installAppVersionRequest.GitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) } - installedAppModel := adapter.NewInstallAppModel(installAppVersionRequest, appStoreBean.DEPLOY_INIT) installedApp, err := impl.installedAppRepository.CreateInstalledApp(installedAppModel, tx) if err != nil { @@ -109,17 +52,20 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppV return nil, err } installAppVersionRequest.InstalledAppId = installedApp.Id + // Stage 3: ends + // Stage 4: save installed_app_versions model installedAppVersions := adapter.NewInstallAppVersionsModel(installAppVersionRequest) _, err = impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersions, tx) if err != nil { impl.logger.Errorw("error while fetching from db", "error", err) return nil, err } - installAppVersionRequest.InstalledAppVersionId = installedAppVersions.Id installAppVersionRequest.Id = installedAppVersions.Id + // Stage 4: ends + // Stage 5: save installed_app_version_history model helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ InstallAppVersionHistoryId: 0, Message: "Install initiated", @@ -135,16 +81,8 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppV impl.logger.Errorw("error while fetching from db", "error", err) return nil, err } - installAppVersionRequest.InstalledAppVersionHistoryId = installedAppVersionHistory.Id - if installAppVersionRequest.DefaultClusterComponent { - clusterInstalledAppsModel := adapter.NewClusterInstalledAppsModel(installAppVersionRequest, environment.ClusterId) - err = impl.clusterInstalledAppsRepository.Save(clusterInstalledAppsModel, tx) - if err != nil { - impl.logger.Errorw("error while creating cluster install app", "error", err) - return nil, err - } - } + // Stage 5: ends return installAppVersionRequest, nil } @@ -174,3 +112,58 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(i } return true, nil } + +func (impl *AppStoreDeploymentServiceImpl) validateAndOverrideDeploymentAppType(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() + if err != nil { + impl.logger.Errorw("error while checking IsGitOpsConfigured", "err", err) + return err + } + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) + if err != nil { + impl.logger.Errorw("error in fetching app store application version", "err", err) + return err + } + isOCIRepo := appStoreAppVersion.AppStore.DockerArtifactStore != nil + if isOCIRepo || getAppInstallationMode(installAppVersionRequest.AppOfferingMode) == util2.SERVER_MODE_HYPERION { + installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM + } + err = impl.deploymentTypeOverrideService.SetAndValidateDeploymentAppType(&installAppVersionRequest.DeploymentAppType, isGitOpsConfigured, installAppVersionRequest.EnvironmentId) + if err != nil { + impl.logger.Errorw("validation error for the used deployment type", "appName", installAppVersionRequest.AppName, "err", err) + return err + } + return nil +} + +func (impl *AppStoreDeploymentServiceImpl) setEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { + + // create env if env not exists for clusterId and namespace for hyperion mode + if util2.IsHelmApp(getAppInstallationMode(installAppVersionRequest.AppOfferingMode)) { + // TODO refactoring: should it be in transaction + envId, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) + if err != nil { + return err + } + installAppVersionRequest.EnvironmentId = envId + } + + environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching environment error", "envId", installAppVersionRequest.EnvironmentId, "err", err) + return err + } + // setting additional env data required in appStoreBean.InstallAppVersionDTO + installAppVersionRequest.Environment = environment + installAppVersionRequest.ACDAppName = fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.Environment.Name) + installAppVersionRequest.ClusterId = environment.ClusterId + return nil +} + +func getAppInstallationMode(appOfferingMode string) string { + appInstallationMode := util2.SERVER_MODE_FULL + if util2.IsBaseStack() || util2.IsHelmApp(appOfferingMode) { + appInstallationMode = util2.SERVER_MODE_HYPERION + } + return appInstallationMode +} diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index ff6bb40622..f4dbb4bb20 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -22,7 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/caarlos0/env/v6" bean3 "github.com/devtron-labs/devtron/api/helm-app/bean" bean4 "github.com/devtron-labs/devtron/api/helm-app/gRPC" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" @@ -48,6 +47,7 @@ import ( cluster2 "github.com/devtron-labs/devtron/pkg/cluster" clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -59,7 +59,7 @@ import ( ) type AppStoreDeploymentService interface { - AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, skipAppCreation bool) (*appStoreBean.InstallAppVersionDTO, error) + AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) IsChartRepoActive(appStoreVersionId int) (bool, error) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) @@ -81,17 +81,6 @@ type AppStoreDeploymentService interface { MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error } -type DeploymentServiceTypeConfig struct { - IsInternalUse bool `env:"IS_INTERNAL_USE" envDefault:"false"` - HelmInstallASyncMode bool `env:"RUN_HELM_INSTALL_IN_ASYNC_MODE_HELM_APPS" envDefault:"false"` -} - -func GetDeploymentServiceTypeConfig() (*DeploymentServiceTypeConfig, error) { - cfg := &DeploymentServiceTypeConfig{} - err := env.Parse(cfg) - return cfg, err -} - type AppStoreDeploymentServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository.InstalledAppRepository @@ -107,20 +96,22 @@ type AppStoreDeploymentServiceImpl struct { helmAppService service.HelmAppService appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - deploymentTypeConfig *DeploymentServiceTypeConfig + deploymentTypeConfig *util2.DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService + deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, - chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, environmentRepository clusterRepository.EnvironmentRepository, - clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, - eaModeDeploymentService EAMode.EAModeDeploymentService, - fullModeDeploymentService deployment.FullModeDeploymentService, environmentService cluster.EnvironmentService, - clusterService cluster.ClusterService, helmAppService service.HelmAppService, appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, + chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, + environmentRepository clusterRepository.EnvironmentRepository, clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, + eaModeDeploymentService EAMode.EAModeDeploymentService, fullModeDeploymentService deployment.FullModeDeploymentService, + environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService service.HelmAppService, + appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, - deploymentTypeConfig *DeploymentServiceTypeConfig, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { + envVariables *util2.EnvironmentVariables, aCDConfig *argocdServer.ACDConfig, + gitOpsConfigReadService config.GitOpsConfigReadService, + deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService) *AppStoreDeploymentServiceImpl { return &AppStoreDeploymentServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -136,9 +127,10 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRep helmAppService: helmAppService, appStoreDeploymentCommonService: appStoreDeploymentCommonService, installedAppRepositoryHistory: installedAppRepositoryHistory, - deploymentTypeConfig: deploymentTypeConfig, + deploymentTypeConfig: envVariables.DeploymentServiceTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, + deploymentTypeOverrideService: deploymentTypeOverrideService, } } @@ -166,7 +158,7 @@ func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest * // Rollback tx on error. defer tx.Rollback() //step 1 db operation initiated - installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx, false) + installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx) if err != nil { impl.logger.Errorw(" error", "err", err) return nil, err @@ -301,7 +293,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryWithG return nil } -func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string, skipAppCreation bool) (*bean.CreateAppDTO, error) { +func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string) (*bean.CreateAppDTO, error) { app1, err := impl.appRepository.FindActiveByName(createRequest.AppName) if err != nil && err != pg.ErrNoRows { return nil, err @@ -313,15 +305,9 @@ func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *b InternalMessage: "app already exists", UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), } - - if !skipAppCreation { - return nil, err - } else { - createRequest.Id = app1.Id - return createRequest, nil - } + return nil, err } - pg := &app.App{ + appModel := &app.App{ Active: true, AppName: createRequest.AppName, TeamId: createRequest.TeamId, @@ -329,9 +315,9 @@ func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *b AppOfferingMode: appInstallationMode, AuditLog: sql.AuditLog{UpdatedBy: createRequest.UserId, CreatedBy: createRequest.UserId, UpdatedOn: time.Now(), CreatedOn: time.Now()}, } - err = impl.appRepository.SaveWithTxn(pg, tx) + err = impl.appRepository.SaveWithTxn(appModel, tx) if err != nil { - impl.logger.Errorw("error in saving entity ", "entity", pg) + impl.logger.Errorw("error in saving entity ", "entity", appModel) return nil, err } @@ -343,11 +329,11 @@ func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *b appLen := len(apps) if appLen > 1 { firstElement := apps[0] - if firstElement.Id != pg.Id { - pg.Active = false - err = impl.appRepository.UpdateWithTxn(pg, tx) + if firstElement.Id != appModel.Id { + appModel.Active = false + err = impl.appRepository.UpdateWithTxn(appModel, tx) if err != nil { - impl.logger.Errorw("error in saving entity ", "entity", pg) + impl.logger.Errorw("error in saving entity ", "entity", appModel) return nil, err } err = &util.ApiError{ @@ -355,14 +341,10 @@ func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *b InternalMessage: "app already exists", UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), } - - if !skipAppCreation { - return nil, err - } } } - createRequest.Id = pg.Id + createRequest.Id = appModel.Id return createRequest, nil } @@ -710,7 +692,16 @@ func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(insta // skipAppCreation - This flag will skip app creation if app already exists. //step 1 db operation initiated - installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx, true) + appModel, err := impl.appRepository.FindActiveByName(installAppVersionRequest.AppName) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Errorw("error in getting app", "appName", installAppVersionRequest.AppName) + return nil, err + } + if appModel != nil && appModel.Id > 0 { + impl.logger.Infow(" app already exists", "name", installAppVersionRequest.AppName) + installAppVersionRequest.AppId = appModel.Id + } + installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx) if err != nil { impl.logger.Errorw(" error", "err", err) return nil, err @@ -1363,7 +1354,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest UserId: updateAppRequest.UserId, TeamId: updateAppRequest.TeamId, } - _, err := impl.createAppForAppStore(&createAppRequest, tx, appInstallationMode, false) + _, err := impl.createAppForAppStore(&createAppRequest, tx, appInstallationMode) if err != nil { impl.logger.Errorw("error while creating app", "error", err) return err diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go index 912d80a659..3d98e947f1 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go @@ -5,7 +5,6 @@ import ( "github.com/devtron-labs/authenticator/client" util2 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" @@ -51,7 +50,6 @@ func TestAppStoreDeploymentService(t *testing.T) { ACDAppName: "", Environment: nil, ChartGroupEntryId: 0, - DefaultClusterComponent: false, Status: appStoreBean.WF_UNKNOWN, AppStoreId: 0, AppStoreName: "", @@ -68,7 +66,7 @@ func TestAppStoreDeploymentService(t *testing.T) { DeploymentAppType: "helm", } - installedAppVersion, err := AppStoreDeploymentService.AppStoreDeployOperationDB(&InstallAppVersionDTO, tx, false) + installedAppVersion, err := AppStoreDeploymentService.AppStoreDeployOperationDB(&InstallAppVersionDTO, tx) assert.Nil(t, err) assert.Equal(t, installedAppVersion.DeploymentAppType, "helm") @@ -101,7 +99,6 @@ func TestAppStoreDeploymentService(t *testing.T) { ACDAppName: "", Environment: nil, ChartGroupEntryId: 0, - DefaultClusterComponent: false, Status: appStoreBean.WF_UNKNOWN, AppStoreId: 0, AppStoreName: "", @@ -118,7 +115,7 @@ func TestAppStoreDeploymentService(t *testing.T) { DeploymentAppType: "helm", } - installedAppVersion, err := AppStoreDeploymentService.AppStoreDeployOperationDB(&InstallAppVersionDTO, tx, false) + installedAppVersion, err := AppStoreDeploymentService.AppStoreDeployOperationDB(&InstallAppVersionDTO, tx) assert.Nil(t, err) assert.Equal(t, installedAppVersion.DeploymentAppType, "argo_cd") @@ -133,7 +130,6 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl config, _ := sql.GetConfig() db, _ := sql.NewDbConnection(config, sugaredLogger) - gitOpsRepository := repository.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) chartGroupDeploymentRepository := repository6.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) appStoreDiscoverRepository := appStoreDiscoverRepository.NewAppStoreApplicationVersionRepositoryImpl(sugaredLogger, db) @@ -172,9 +168,7 @@ func initAppStoreDeploymentService(t *testing.T, internalUse bool) *AppStoreDepl nil, nil, InstalledAppVersionHistoryRepository, - gitOpsRepository, - &DeploymentServiceTypeConfig{IsInternalUse: internalUse}, - nil, + &DeploymentServiceTypeConfig{ExternallyManagedDeploymentType: internalUse}, nil, nil) diff --git a/pkg/attributes/AttributesService.go b/pkg/attributes/AttributesService.go index 1f7b24403b..53aefaefba 100644 --- a/pkg/attributes/AttributesService.go +++ b/pkg/attributes/AttributesService.go @@ -22,8 +22,10 @@ import ( "errors" "fmt" "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internal/util" "github.com/go-pg/pg" "go.uber.org/zap" + "net/http" "strconv" "time" ) @@ -36,6 +38,8 @@ type AttributesService interface { GetByKey(key string) (*AttributesDto, error) UpdateKeyValueByOne(key string) error AddDeploymentEnforcementConfig(request *AttributesDto) (*AttributesDto, error) + // GetDeploymentEnforcementConfig : Retrieves the deployment config values from the attributes table + GetDeploymentEnforcementConfig(environmentId int) (map[string]bool, error) } const ( @@ -311,3 +315,25 @@ func (impl AttributesServiceImpl) AddDeploymentEnforcementConfig(request *Attrib tx.Commit() return request, nil } + +func (impl AttributesServiceImpl) GetDeploymentEnforcementConfig(environmentId int) (map[string]bool, error) { + var deploymentConfig map[string]map[string]bool + var deploymentConfigEnv map[string]bool + deploymentConfigValues, err := impl.attributesRepository.FindByKey(ENFORCE_DEPLOYMENT_TYPE_CONFIG) + if util.IsErrNoRows(err) { + return deploymentConfigEnv, nil + } + //if empty config received(doesn't exist in table) which can't be parsed + if deploymentConfigValues.Value != "" { + if err := json.Unmarshal([]byte(deploymentConfigValues.Value), &deploymentConfig); err != nil { + apiError := &util.ApiError{ + HttpStatusCode: http.StatusInternalServerError, + InternalMessage: err.Error(), + UserMessage: "Failed to fetch deployment config values from the attributes table", + } + return deploymentConfigEnv, apiError + } + deploymentConfigEnv, _ = deploymentConfig[fmt.Sprintf("%d", environmentId)] + } + return deploymentConfigEnv, nil +} diff --git a/pkg/auth/sso/SSOLoginService.go b/pkg/auth/sso/SSOLoginService.go index 0c121be8c4..81bbe09721 100644 --- a/pkg/auth/sso/SSOLoginService.go +++ b/pkg/auth/sso/SSOLoginService.go @@ -61,12 +61,12 @@ const ClientSecret = "clientSecret" func NewSSOLoginServiceImpl( logger *zap.SugaredLogger, ssoLoginRepository SSOLoginRepository, - K8sUtil *k8s.K8sServiceImpl, devtronSecretConfig *util2.DevtronSecretConfig, userAuthOidcHelper authentication.UserAuthOidcHelper) *SSOLoginServiceImpl { + K8sUtil *k8s.K8sServiceImpl, envVariables *util2.EnvironmentVariables, userAuthOidcHelper authentication.UserAuthOidcHelper) *SSOLoginServiceImpl { serviceImpl := &SSOLoginServiceImpl{ logger: logger, ssoLoginRepository: ssoLoginRepository, K8sUtil: K8sUtil, - devtronSecretConfig: devtronSecretConfig, + devtronSecretConfig: envVariables.DevtronSecretConfig, userAuthOidcHelper: userAuthOidcHelper, } return serviceImpl diff --git a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go index 851cb22c48..fb10b283f6 100644 --- a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go +++ b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go @@ -33,12 +33,12 @@ type GitOpsConfigReadServiceImpl struct { func NewGitOpsConfigReadServiceImpl(logger *zap.SugaredLogger, gitOpsRepository repository.GitOpsConfigRepository, userService user.UserService, - globalEnvVariables *util.GlobalEnvVariables) *GitOpsConfigReadServiceImpl { + envVariables *util.EnvironmentVariables) *GitOpsConfigReadServiceImpl { return &GitOpsConfigReadServiceImpl{ logger: logger, gitOpsRepository: gitOpsRepository, userService: userService, - globalEnvVariables: globalEnvVariables, + globalEnvVariables: envVariables.GlobalEnvVariables, } } diff --git a/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go new file mode 100644 index 0000000000..720dae4eb5 --- /dev/null +++ b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go @@ -0,0 +1,117 @@ +package providerConfig + +import ( + util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/attributes" + "github.com/devtron-labs/devtron/util" + "go.uber.org/zap" + "net/http" +) + +type DeploymentTypeOverrideService interface { + // SetAndValidateDeploymentAppType : Set deployment application (helm/argo) types based on the enforcement configurations + SetAndValidateDeploymentAppType(deploymentType *string, isGitOpsConfigured bool, environmentId int) error +} + +type DeploymentTypeOverrideServiceImpl struct { + logger *zap.SugaredLogger + deploymentConfig *util.DeploymentServiceTypeConfig + attributesService attributes.AttributesService +} + +func NewDeploymentTypeOverrideServiceImpl(logger *zap.SugaredLogger, + envVariables *util.EnvironmentVariables, + attributesService attributes.AttributesService) *DeploymentTypeOverrideServiceImpl { + return &DeploymentTypeOverrideServiceImpl{ + logger: logger, + deploymentConfig: envVariables.DeploymentServiceTypeConfig, + attributesService: attributesService, + } +} + +func (impl *DeploymentTypeOverrideServiceImpl) SetAndValidateDeploymentAppType(deploymentType *string, isGitOpsConfigured bool, environmentId int) error { + // if no deployment app type sent from user then we'll not validate + deploymentTypeValidationConfig, err := impl.attributesService.GetDeploymentEnforcementConfig(environmentId) + if err != nil { + impl.logger.Errorw("error in getting enforcement config for deployment", "err", err) + return err + } + // by default both deployment app type are allowed + AllowedDeploymentAppTypes := map[string]bool{ + util2.PIPELINE_DEPLOYMENT_TYPE_ACD: true, + util2.PIPELINE_DEPLOYMENT_TYPE_HELM: true, + } + for k, v := range deploymentTypeValidationConfig { + // rewriting allowed deployment types based on config provided by user + AllowedDeploymentAppTypes[k] = v + } + if !impl.deploymentConfig.ExternallyManagedDeploymentType { + if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_ACD] { + *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD + } else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] { + *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM + } + } + if *deploymentType == "" { + if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_ACD] { + *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD + } else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] { + *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM + } + } + if err := impl.validateDeploymentAppType(*deploymentType, deploymentTypeValidationConfig); err != nil { + impl.logger.Errorw("validation error for the given deployment type", "deploymentType", *deploymentType, "err", err) + return err + } + if !isGitOpsConfigured && util2.IsAcdApp(*deploymentType) { + impl.logger.Errorw("GitOps not configured but selected as a deployment app type") + err = &util2.ApiError{ + HttpStatusCode: http.StatusBadRequest, + InternalMessage: "GitOps integration is not installed/configured. Please install/configure GitOps or use helm option.", + UserMessage: "GitOps integration is not installed/configured. Please install/configure GitOps or use helm option.", + } + return err + } + return nil +} + +func (impl *DeploymentTypeOverrideServiceImpl) validateDeploymentAppType(deploymentType string, deploymentConfig map[string]bool) error { + + // Config value doesn't exist in attribute table + if deploymentConfig == nil { + return nil + } + //Config value found to be true for ArgoCD and Helm both + if allDeploymentConfigTrue(deploymentConfig) { + return nil + } + //Case : {ArgoCD : false, Helm: true, HGF : true} + if validDeploymentConfigReceived(deploymentConfig, deploymentType) { + return nil + } + + err := &util2.ApiError{ + HttpStatusCode: http.StatusBadRequest, + InternalMessage: "Received deployment app type doesn't match with the allowed deployment app type for this environment.", + UserMessage: "Received deployment app type doesn't match with the allowed deployment app type for this environment.", + } + return err +} + +func allDeploymentConfigTrue(deploymentConfig map[string]bool) bool { + for _, value := range deploymentConfig { + if !value { + return false + } + } + return true +} + +func validDeploymentConfigReceived(deploymentConfig map[string]bool, deploymentTypeSent string) bool { + for key, value := range deploymentConfig { + if value && key == deploymentTypeSent { + return true + } + } + return false +} diff --git a/pkg/deployment/providerConfig/wire_deploymentProviderConfig.go b/pkg/deployment/providerConfig/wire_deploymentProviderConfig.go new file mode 100644 index 0000000000..768216717c --- /dev/null +++ b/pkg/deployment/providerConfig/wire_deploymentProviderConfig.go @@ -0,0 +1,10 @@ +package providerConfig + +import ( + "github.com/google/wire" +) + +var DeploymentProviderConfigWireSet = wire.NewSet( + NewDeploymentTypeOverrideServiceImpl, + wire.Bind(new(DeploymentTypeOverrideService), new(*DeploymentTypeOverrideServiceImpl)), +) diff --git a/pkg/deployment/wire_deployment.go b/pkg/deployment/wire_deployment.go index 5a959cd701..e7ae5fbaca 100644 --- a/pkg/deployment/wire_deployment.go +++ b/pkg/deployment/wire_deployment.go @@ -3,6 +3,7 @@ package deployment import ( "github.com/devtron-labs/devtron/pkg/deployment/gitOps" "github.com/devtron-labs/devtron/pkg/deployment/manifest" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/google/wire" ) @@ -11,4 +12,5 @@ import ( var DeploymentWireSet = wire.NewSet( gitOps.GitOpsWireSet, manifest.DeploymentManifestWireSet, + providerConfig.DeploymentProviderConfigWireSet, ) diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index 5925bf06de..9b2334ac24 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -103,7 +103,7 @@ type GitOpsConfigServiceImpl struct { } func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, - globalEnvVariables *util2.GlobalEnvVariables, + envVariables *util2.EnvironmentVariables, gitOpsRepository repository.GitOpsConfigRepository, K8sUtil *util4.K8sServiceImpl, aCDAuthConfig *util3.ACDAuthConfig, clusterService cluster.ClusterService, gitFactory *git.GitFactory, argoUserService argo.ArgoUserService, @@ -111,7 +111,7 @@ func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger, return &GitOpsConfigServiceImpl{ randSource: rand.NewSource(time.Now().UnixNano()), logger: Logger, - globalEnvVariables: globalEnvVariables, + globalEnvVariables: envVariables.GlobalEnvVariables, gitOpsRepository: gitOpsRepository, K8sUtil: K8sUtil, aCDAuthConfig: aCDAuthConfig, diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 30723f8417..83ca9c4b7a 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -45,6 +45,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" + config2 "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/imageDigestPolicy" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -108,8 +109,6 @@ type CdPipelineConfigService interface { GetBulkActionImpactedPipelines(dto *bean.CdBulkActionRequestDto) ([]*pipelineConfig.Pipeline, error) //no usage //IsGitOpsRequiredForCD : Determine if GitOps is required for CD based on the provided pipeline creation request IsGitOpsRequiredForCD(pipelineCreateRequest *bean.CdPipelines) bool - //SetPipelineDeploymentAppType : Set pipeline deployment application(helm/argo) types based on the provided configuration - SetPipelineDeploymentAppType(pipelineCreateRequest *bean.CdPipelines, isGitOpsConfigured bool, deploymentTypeValidationConfig map[string]bool) MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDeleted(appId int, envId int, acdToken string, pipeline *pipelineConfig.Pipeline) (bool, error) //GetEnvironmentListForAutocompleteFilter : lists environment for given configuration GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*cluster.ResourceGroupingResponse, error) @@ -139,11 +138,10 @@ type CdPipelineConfigServiceImpl struct { propertiesConfigService PropertiesConfigService deploymentTemplateHistoryService history.DeploymentTemplateHistoryService scopedVariableManager variables.ScopedVariableManager - deploymentConfig *DeploymentServiceTypeConfig + deploymentConfig *util2.DeploymentServiceTypeConfig application application.ServiceClient customTagService CustomTagService pipelineConfigListenerService PipelineConfigListenerService - devtronAppCMCSService DevtronAppCMCSService ciPipelineConfigService CiPipelineConfigService buildPipelineSwitchService BuildPipelineSwitchService argoClientWrapperService argocdServer.ArgoClientWrapperService @@ -151,6 +149,7 @@ type CdPipelineConfigServiceImpl struct { gitOpsConfigReadService config.GitOpsConfigReadService gitOperationService git.GitOperationService imageDigestPolicyService imageDigestPolicy.ImageDigestPolicyService + deploymentTypeOverrideService config2.DeploymentTypeOverrideService } func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepository pipelineConfig.PipelineRepository, @@ -164,15 +163,16 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor chartRepository chartRepoRepository.ChartRepository, resourceGroupService resourceGroup2.ResourceGroupService, propertiesConfigService PropertiesConfigService, deploymentTemplateHistoryService history.DeploymentTemplateHistoryService, - scopedVariableManager variables.ScopedVariableManager, deploymentConfig *DeploymentServiceTypeConfig, + scopedVariableManager variables.ScopedVariableManager, envVariables *util2.EnvironmentVariables, application application.ServiceClient, customTagService CustomTagService, - pipelineConfigListenerService PipelineConfigListenerService, devtronAppCMCSService DevtronAppCMCSService, + pipelineConfigListenerService PipelineConfigListenerService, ciPipelineConfigService CiPipelineConfigService, buildPipelineSwitchService BuildPipelineSwitchService, argoClientWrapperService argocdServer.ArgoClientWrapperService, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, gitOpsConfigReadService config.GitOpsConfigReadService, gitOperationService git.GitOperationService, - imageDigestPolicyService imageDigestPolicy.ImageDigestPolicyService) *CdPipelineConfigServiceImpl { + imageDigestPolicyService imageDigestPolicy.ImageDigestPolicyService, + deploymentTypeOverrideService config2.DeploymentTypeOverrideService) *CdPipelineConfigServiceImpl { return &CdPipelineConfigServiceImpl{ logger: logger, pipelineRepository: pipelineRepository, @@ -196,10 +196,9 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor propertiesConfigService: propertiesConfigService, deploymentTemplateHistoryService: deploymentTemplateHistoryService, scopedVariableManager: scopedVariableManager, - deploymentConfig: deploymentConfig, + deploymentConfig: envVariables.DeploymentServiceTypeConfig, application: application, pipelineConfigListenerService: pipelineConfigListenerService, - devtronAppCMCSService: devtronAppCMCSService, customTagService: customTagService, ciPipelineConfigService: ciPipelineConfigService, buildPipelineSwitchService: buildPipelineSwitchService, @@ -208,6 +207,7 @@ func NewCdPipelineConfigServiceImpl(logger *zap.SugaredLogger, pipelineRepositor gitOpsConfigReadService: gitOpsConfigReadService, gitOperationService: gitOperationService, imageDigestPolicyService: imageDigestPolicyService, + deploymentTypeOverrideService: deploymentTypeOverrideService, } } @@ -366,13 +366,8 @@ func (impl *CdPipelineConfigServiceImpl) CreateCdPipelines(pipelineCreateRequest if pipeline.EnvironmentId <= 0 { continue } - // if no deployment app type sent from user then we'll not validate - deploymentConfig, err := impl.devtronAppCMCSService.GetDeploymentConfigMap(pipeline.EnvironmentId) + err = impl.deploymentTypeOverrideService.SetAndValidateDeploymentAppType(&pipeline.DeploymentAppType, isGitOpsConfigured, pipeline.EnvironmentId) if err != nil { - return nil, err - } - impl.SetPipelineDeploymentAppType(pipelineCreateRequest, isGitOpsConfigured, deploymentConfig) - if err := impl.validateDeploymentAppType(pipeline, deploymentConfig); err != nil { impl.logger.Errorw("validation error in creating pipeline", "name", pipeline.Name, "err", err) return nil, err } @@ -384,7 +379,7 @@ func (impl *CdPipelineConfigServiceImpl) CreateCdPipelines(pipelineCreateRequest impl.logger.Errorw("app not found", "err", err, "appId", pipelineCreateRequest.AppId) return nil, err } - _, err = impl.ValidateCDPipelineRequest(pipelineCreateRequest, isGitOpsConfigured, isGitOpsRequiredForCD) + _, err = impl.ValidateCDPipelineRequest(pipelineCreateRequest) if err != nil { return nil, err } @@ -1382,34 +1377,6 @@ func (impl *CdPipelineConfigServiceImpl) IsGitOpsRequiredForCD(pipelineCreateReq return haveAtLeastOneGitOps } -func (impl *CdPipelineConfigServiceImpl) SetPipelineDeploymentAppType(pipelineCreateRequest *bean.CdPipelines, isGitOpsConfigured bool, deploymentTypeValidationConfig map[string]bool) { - for _, pipeline := range pipelineCreateRequest.Pipelines { - // by default both deployment app type are allowed - AllowedDeploymentAppTypes := map[string]bool{ - util.PIPELINE_DEPLOYMENT_TYPE_ACD: true, - util.PIPELINE_DEPLOYMENT_TYPE_HELM: true, - } - for k, v := range deploymentTypeValidationConfig { - // rewriting allowed deployment types based on config provided by user - AllowedDeploymentAppTypes[k] = v - } - if !impl.deploymentConfig.IsInternalUse { - if isGitOpsConfigured && AllowedDeploymentAppTypes[util.PIPELINE_DEPLOYMENT_TYPE_ACD] { - pipeline.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else if AllowedDeploymentAppTypes[util.PIPELINE_DEPLOYMENT_TYPE_HELM] { - pipeline.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - if pipeline.DeploymentAppType == "" { - if isGitOpsConfigured && AllowedDeploymentAppTypes[util.PIPELINE_DEPLOYMENT_TYPE_ACD] { - pipeline.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_ACD - } else if AllowedDeploymentAppTypes[util.PIPELINE_DEPLOYMENT_TYPE_HELM] { - pipeline.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - } - } - } -} - func (impl *CdPipelineConfigServiceImpl) MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDeleted(appId int, envId int, acdToken string, pipeline *pipelineConfig.Pipeline) (bool, error) { acdAppFound := false @@ -1533,41 +1500,7 @@ func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter return result, nil } -func (impl *CdPipelineConfigServiceImpl) validateDeploymentAppType(pipeline *bean.CDPipelineConfigObject, deploymentConfig map[string]bool) error { - - // Config value doesn't exist in attribute table - if deploymentConfig == nil { - return nil - } - //Config value found to be true for ArgoCD and Helm both - if allDeploymentConfigTrue(deploymentConfig) { - return nil - } - //Case : {ArgoCD : false, Helm: true, HGF : true} - if validDeploymentConfigReceived(deploymentConfig, pipeline.DeploymentAppType) { - return nil - } - - err := &util.ApiError{ - HttpStatusCode: http.StatusBadRequest, - InternalMessage: "Received deployment app type doesn't match with the allowed deployment app type for this environment.", - UserMessage: "Received deployment app type doesn't match with the allowed deployment app type for this environment.", - } - return err -} - -func (impl *CdPipelineConfigServiceImpl) ValidateCDPipelineRequest(pipelineCreateRequest *bean.CdPipelines, isGitOpsConfigured, haveAtleastOneGitOps bool) (bool, error) { - - if isGitOpsConfigured == false && haveAtleastOneGitOps { - impl.logger.Errorw("Gitops not configured but selected in creating cd pipeline") - err := &util.ApiError{ - HttpStatusCode: http.StatusBadRequest, - InternalMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", - UserMessage: "Gitops integration is not installed/configured. Please install/configure gitops or use helm option.", - } - return false, err - } - +func (impl *CdPipelineConfigServiceImpl) ValidateCDPipelineRequest(pipelineCreateRequest *bean.CdPipelines) (bool, error) { envPipelineMap := make(map[int]string) for _, pipeline := range pipelineCreateRequest.Pipelines { if envPipelineMap[pipeline.EnvironmentId] != "" { diff --git a/pkg/pipeline/DevtronAppCMCSService.go b/pkg/pipeline/DevtronAppCMCSService.go index 421c2cda25..2a210817e2 100644 --- a/pkg/pipeline/DevtronAppCMCSService.go +++ b/pkg/pipeline/DevtronAppCMCSService.go @@ -19,21 +19,14 @@ package pipeline import ( "encoding/json" - "fmt" "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" - "github.com/devtron-labs/devtron/pkg/attributes" - "github.com/go-pg/pg" "go.uber.org/zap" - "net/http" ) type DevtronAppCMCSService interface { //FetchConfigmapSecretsForCdStages : Delegating the request to appService for fetching cm/cs FetchConfigmapSecretsForCdStages(appId, envId, cdPipelineId int) (ConfigMapSecretsResponse, error) - //GetDeploymentConfigMap : Retrieve deployment config values from the attributes table - GetDeploymentConfigMap(environmentId int) (map[string]bool, error) } type DevtronAppCMCSServiceImpl struct { @@ -68,25 +61,3 @@ func (impl *DevtronAppCMCSServiceImpl) FetchConfigmapSecretsForCdStages(appId, e } return existingConfigMapSecrets, nil } - -func (impl *DevtronAppCMCSServiceImpl) GetDeploymentConfigMap(environmentId int) (map[string]bool, error) { - var deploymentConfig map[string]map[string]bool - var deploymentConfigEnv map[string]bool - deploymentConfigValues, err := impl.attributesRepository.FindByKey(attributes.ENFORCE_DEPLOYMENT_TYPE_CONFIG) - if err == pg.ErrNoRows { - return deploymentConfigEnv, nil - } - //if empty config received(doesn't exist in table) which can't be parsed - if deploymentConfigValues.Value != "" { - if err := json.Unmarshal([]byte(deploymentConfigValues.Value), &deploymentConfig); err != nil { - rerr := &util.ApiError{ - HttpStatusCode: http.StatusInternalServerError, - InternalMessage: err.Error(), - UserMessage: "Failed to fetch deployment config values from the attributes table", - } - return deploymentConfigEnv, rerr - } - deploymentConfigEnv, _ = deploymentConfig[fmt.Sprintf("%d", environmentId)] - } - return deploymentConfigEnv, nil -} diff --git a/pkg/pipeline/GitopsOrHelmOption_test.go b/pkg/pipeline/GitopsOrHelmOption_test.go index cccbd64e90..fac5c7c9c5 100644 --- a/pkg/pipeline/GitopsOrHelmOption_test.go +++ b/pkg/pipeline/GitopsOrHelmOption_test.go @@ -4,6 +4,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/mocks" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/bean" + util2 "github.com/devtron-labs/devtron/util" "github.com/stretchr/testify/assert" "testing" ) @@ -15,16 +16,10 @@ func TestGitopsOrHelmOption(t *testing.T) { sugaredLogger, err := util.NewSugardLogger() assert.Nil(t, err) - pipelineBuilderService := NewPipelineBuilderImpl(sugaredLogger, nil, nil, nil, nil, - nil, nil, nil, - nil, nil, nil, nil, nil, - nil, nil, nil, nil, util.MergeUtil{Logger: sugaredLogger}, nil, - nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, + pipelineBuilderService := NewPipelineBuilderImpl(sugaredLogger, nil, nil, nil, nil, nil, - nil, nil, nil, nil, - nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, + util.MergeUtil{Logger: sugaredLogger}, &util2.DeploymentServiceTypeConfig{ExternallyManagedDeploymentType: false}, nil) pipelineCreateRequest := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ @@ -79,7 +74,7 @@ func TestGitopsOrHelmOption(t *testing.T) { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, nil, nil, nil, nil, nil, nil, &util2.DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) pipelineCreateRequest := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ @@ -135,7 +130,7 @@ func TestGitopsOrHelmOption(t *testing.T) { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, nil, nil, nil, nil, nil, nil, &util2.DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) pipelineCreateRequest := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ @@ -190,7 +185,7 @@ func TestGitopsOrHelmOption(t *testing.T) { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, nil, nil, nil, nil, nil, nil, &util2.DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) pipelineCreateRequestHelm := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ @@ -284,7 +279,7 @@ func TestGitopsOrHelmOption(t *testing.T) { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, nil, nil, nil, nil, nil, nil, &util2.DeploymentServiceTypeConfig{IsInternalUse: false}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) pipelineCreateRequest := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ @@ -341,7 +336,7 @@ func TestGitopsOrHelmOption(t *testing.T) { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, &DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) + nil, nil, nil, nil, nil, nil, nil, nil, &util2.DeploymentServiceTypeConfig{IsInternalUse: true}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil) pipelineCreateRequest := &bean.CdPipelines{ Pipelines: []*bean.CDPipelineConfigObject{ diff --git a/pkg/pipeline/PipelineBuilder.go b/pkg/pipeline/PipelineBuilder.go index 06dc8d03bc..d47d08411f 100644 --- a/pkg/pipeline/PipelineBuilder.go +++ b/pkg/pipeline/PipelineBuilder.go @@ -49,22 +49,12 @@ func GetEcrConfig() (*EcrConfig, error) { return cfg, err } -type DeploymentServiceTypeConfig struct { - IsInternalUse bool `env:"IS_INTERNAL_USE" envDefault:"false"` -} - type SecurityConfig struct { //FORCE_SECURITY_SCANNING flag is being maintained in both dashboard and orchestrator CM's //TODO: rishabh will remove FORCE_SECURITY_SCANNING from dashboard's CM. ForceSecurityScanning bool `env:"FORCE_SECURITY_SCANNING" envDefault:"false"` } -func GetDeploymentServiceTypeConfig() (*DeploymentServiceTypeConfig, error) { - cfg := &DeploymentServiceTypeConfig{} - err := env.Parse(cfg) - return cfg, err -} - type PipelineBuilder interface { DevtronAppConfigService CiPipelineConfigService @@ -211,24 +201,6 @@ func getPatchMessage(err error) string { return "" } -func allDeploymentConfigTrue(deploymentConfig map[string]bool) bool { - for _, value := range deploymentConfig { - if !value { - return false - } - } - return true -} - -func validDeploymentConfigReceived(deploymentConfig map[string]bool, deploymentTypeSent string) bool { - for key, value := range deploymentConfig { - if value && key == deploymentTypeSent { - return true - } - } - return false -} - func (impl *PipelineBuilderImpl) isGitRepoUrlPresent(appId int) bool { fetchedChart, err := impl.chartRepository.FindLatestByAppId(appId) diff --git a/util/GlobalConfig.go b/util/GlobalConfig.go index faee25ef9e..6292e3ea35 100644 --- a/util/GlobalConfig.go +++ b/util/GlobalConfig.go @@ -1,35 +1,35 @@ package util import ( - "fmt" "github.com/caarlos0/env" - "github.com/juju/errors" ) +type EnvironmentVariables struct { + GlobalEnvVariables *GlobalEnvVariables + DevtronSecretConfig *DevtronSecretConfig + DeploymentServiceTypeConfig *DeploymentServiceTypeConfig +} + +type DeploymentServiceTypeConfig struct { + ExternallyManagedDeploymentType bool `env:"IS_INTERNAL_USE" envDefault:"false"` + HelmInstallASyncMode bool `env:"RUN_HELM_INSTALL_IN_ASYNC_MODE_HELM_APPS" envDefault:"false"` +} + type GlobalEnvVariables struct { GitOpsRepoPrefix string `env:"GITOPS_REPO_PREFIX" envDefault:""` SkipGitOpsValidation bool `env:"SKIP_GITOPS_VALIDATION" envDefault:"false"` } -func GetGlobalEnvVariables() (*GlobalEnvVariables, error) { - cfg := &GlobalEnvVariables{} - err := env.Parse(cfg) - if err != nil { - return nil, err - } - return cfg, err -} - type DevtronSecretConfig struct { DevtronSecretName string `env:"DEVTRON_SECRET_NAME" envDefault:"devtron-secret"` DevtronDexSecretNamespace string `env:"DEVTRON_DEX_SECRET_NAMESPACE" envDefault:"devtroncd"` } -func GetDevtronSecretName() (*DevtronSecretConfig, error) { - secretConfig := &DevtronSecretConfig{} - err := env.Parse(secretConfig) +func GetEnvironmentVariables() (*EnvironmentVariables, error) { + cfg := &EnvironmentVariables{} + err := env.Parse(cfg) if err != nil { - return nil, errors.New(fmt.Sprintf("could not get devtron secret name from environment : %v", err)) + return nil, err } - return secretConfig, err + return cfg, err } diff --git a/util/argo/ArgoUserService.go b/util/argo/ArgoUserService.go index 75715dd704..c4a3f3df6d 100644 --- a/util/argo/ArgoUserService.go +++ b/util/argo/ArgoUserService.go @@ -54,13 +54,13 @@ type ArgoUserServiceImpl struct { } func NewArgoUserServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.ClusterService, - devtronSecretConfig *util2.DevtronSecretConfig, runTimeConfig *client.RuntimeConfig, + envVariables *util2.EnvironmentVariables, runTimeConfig *client.RuntimeConfig, argoCDConnectionManager connection.ArgoCDConnectionManager, versionService argocdServer.VersionService, k8sUtil *k8s.K8sServiceImpl, gitOpsConfigReadService config.GitOpsConfigReadService) (*ArgoUserServiceImpl, error) { argoUserServiceImpl := &ArgoUserServiceImpl{ logger: Logger, clusterService: clusterService, - devtronSecretConfig: devtronSecretConfig, + devtronSecretConfig: envVariables.DevtronSecretConfig, runTimeConfig: runTimeConfig, argoCDConnectionManager: argoCDConnectionManager, versionService: versionService, diff --git a/wire_gen.go b/wire_gen.go index 991b106645..2771a93149 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -130,6 +130,7 @@ import ( repository13 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" repository8 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" @@ -260,11 +261,11 @@ func InitializeApp() (*App, error) { userAuditRepositoryImpl := repository4.NewUserAuditRepositoryImpl(db) userAuditServiceImpl := user.NewUserAuditServiceImpl(sugaredLogger, userAuditRepositoryImpl) userServiceImpl := user.NewUserServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, sessionManager, userCommonServiceImpl, userAuditServiceImpl) - globalEnvVariables, err := util2.GetGlobalEnvVariables() + environmentVariables, err := util2.GetEnvironmentVariables() if err != nil { return nil, err } - gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, globalEnvVariables) + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, environmentVariables) clusterServiceImplExtended := cluster2.NewClusterServiceImplExtended(clusterRepositoryImpl, environmentRepositoryImpl, grafanaClientImpl, sugaredLogger, installedAppRepositoryImpl, k8sServiceImpl, serviceClientImpl, k8sInformerFactoryImpl, userAuthRepositoryImpl, userRepositoryImpl, roleGroupRepositoryImpl, gitOpsConfigReadServiceImpl) loginService := middleware.NewUserLogin(sessionManager, k8sClient) userAuthServiceImpl := user.NewUserAuthServiceImpl(userAuthRepositoryImpl, sessionManager, loginService, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userServiceImpl) @@ -317,12 +318,8 @@ func InitializeApp() (*App, error) { genericNoteServiceImpl := genericNotes.NewGenericNoteServiceImpl(genericNoteRepositoryImpl, genericNoteHistoryServiceImpl, userRepositoryImpl, sugaredLogger) clusterDescriptionRepositoryImpl := repository.NewClusterDescriptionRepositoryImpl(db, sugaredLogger) clusterDescriptionServiceImpl := cluster2.NewClusterDescriptionServiceImpl(clusterDescriptionRepositoryImpl, userRepositoryImpl, sugaredLogger) - devtronSecretConfig, err := util2.GetDevtronSecretName() - if err != nil { - return nil, err - } versionServiceImpl := argocdServer.NewVersionServiceImpl(sugaredLogger, argoCDConnectionManagerImpl) - argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, devtronSecretConfig, runtimeConfig, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl, gitOpsConfigReadServiceImpl) + argoUserServiceImpl, err := argo.NewArgoUserServiceImpl(sugaredLogger, clusterServiceImplExtended, environmentVariables, runtimeConfig, argoCDConnectionManagerImpl, versionServiceImpl, k8sServiceImpl, gitOpsConfigReadServiceImpl) if err != nil { return nil, err } @@ -431,7 +428,7 @@ func InitializeApp() (*App, error) { return nil, err } gitOperationServiceImpl := git.NewGitOperationServiceImpl(sugaredLogger, gitFactory, gitOpsConfigReadServiceImpl, chartTemplateServiceImpl) - appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, globalEnvVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) + appServiceImpl := app2.NewAppService(envConfigOverrideRepositoryImpl, pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, argoUserServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, scopedVariableCMCSManagerImpl, acdConfig, chartRefServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl) globalCMCSRepositoryImpl := repository2.NewGlobalCMCSRepositoryImpl(sugaredLogger, db) globalCMCSServiceImpl := pipeline.NewGlobalCMCSServiceImpl(sugaredLogger, globalCMCSRepositoryImpl) argoWorkflowExecutorImpl := executors.NewArgoWorkflowExecutorImpl(sugaredLogger) @@ -516,17 +513,14 @@ func InitializeApp() (*App, error) { deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRefServiceImpl) deploymentTemplateHistoryServiceImpl := history.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl) - deploymentServiceTypeConfig, err := pipeline.GetDeploymentServiceTypeConfig() - if err != nil { - return nil, err - } pipelineConfigListenerServiceImpl := pipeline.NewPipelineConfigListenerServiceImpl(sugaredLogger) - devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) repositoryServiceClientImpl := repository14.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl) imageDigestPolicyServiceImpl := imageDigestPolicy.NewImageDigestPolicyServiceImpl(sugaredLogger, qualifierMappingServiceImpl, devtronResourceSearchableKeyServiceImpl) - cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deploymentServiceTypeConfig, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, devtronAppCMCSServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, imageDigestPolicyServiceImpl) + deploymentTypeOverrideServiceImpl := providerConfig.NewDeploymentTypeOverrideServiceImpl(sugaredLogger, environmentVariables, attributesServiceImpl) + cdPipelineConfigServiceImpl := pipeline.NewCdPipelineConfigServiceImpl(sugaredLogger, pipelineRepositoryImpl, environmentRepositoryImpl, pipelineConfigRepositoryImpl, appWorkflowRepositoryImpl, pipelineStageServiceImpl, appRepositoryImpl, appServiceImpl, deploymentGroupRepositoryImpl, ciCdPipelineOrchestratorImpl, appStatusRepositoryImpl, ciPipelineRepositoryImpl, prePostCdScriptHistoryServiceImpl, clusterRepositoryImpl, helmAppServiceImpl, enforcerUtilImpl, pipelineStrategyHistoryServiceImpl, chartRepositoryImpl, resourceGroupServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, environmentVariables, applicationServiceClientImpl, customTagServiceImpl, pipelineConfigListenerServiceImpl, ciPipelineConfigServiceImpl, buildPipelineSwitchServiceImpl, argoClientWrapperServiceImpl, deployedAppMetricsServiceImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, imageDigestPolicyServiceImpl, deploymentTypeOverrideServiceImpl) appArtifactManagerImpl := pipeline.NewAppArtifactManagerImpl(sugaredLogger, cdWorkflowRepositoryImpl, userServiceImpl, imageTaggingServiceImpl, ciArtifactRepositoryImpl, ciWorkflowRepositoryImpl, pipelineStageServiceImpl, cdPipelineConfigServiceImpl, dockerArtifactStoreRepositoryImpl, ciPipelineRepositoryImpl, ciTemplateServiceImpl) + devtronAppCMCSServiceImpl := pipeline.NewDevtronAppCMCSServiceImpl(sugaredLogger, appServiceImpl, attributesRepositoryImpl) globalStrategyMetadataChartRefMappingRepositoryImpl := chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl(db, sugaredLogger) devtronAppStrategyServiceImpl := pipeline.NewDevtronAppStrategyServiceImpl(sugaredLogger, chartRepositoryImpl, globalStrategyMetadataChartRefMappingRepositoryImpl, ciCdPipelineOrchestratorImpl, cdPipelineConfigServiceImpl) cvePolicyRepositoryImpl := security.NewPolicyRepositoryImpl(db) @@ -549,7 +543,7 @@ func InitializeApp() (*App, error) { deploymentEventHandlerImpl := app2.NewDeploymentEventHandlerImpl(sugaredLogger, appListingServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl) cdHandlerImpl := pipeline.NewCdHandlerImpl(sugaredLogger, userServiceImpl, cdWorkflowRepositoryImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, ciPipelineMaterialRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, ciWorkflowRepositoryImpl, helmAppServiceImpl, pipelineOverrideRepositoryImpl, workflowDagExecutorImpl, appListingServiceImpl, appListingRepositoryImpl, pipelineStatusTimelineRepositoryImpl, applicationServiceClientImpl, argoUserServiceImpl, deploymentEventHandlerImpl, eventRESTClientImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceImpl, appStatusServiceImpl, enforcerUtilImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, appRepositoryImpl, resourceGroupServiceImpl, imageTaggingServiceImpl, k8sServiceImpl, workflowServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, customTagServiceImpl, argoClientWrapperServiceImpl, appServiceConfig, acdConfig) appWorkflowServiceImpl := appWorkflow2.NewAppWorkflowServiceImpl(sugaredLogger, appWorkflowRepositoryImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, appRepositoryImpl, userAuthServiceImpl) - appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, ciPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl) + appCloneServiceImpl := appClone.NewAppCloneServiceImpl(sugaredLogger, pipelineBuilderImpl, attributesServiceImpl, chartServiceImpl, configMapServiceImpl, appWorkflowServiceImpl, appListingServiceImpl, propertiesConfigServiceImpl, pipelineStageServiceImpl, ciTemplateServiceImpl, appRepositoryImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, ciPipelineConfigServiceImpl, gitOpsConfigReadServiceImpl) deploymentTemplateRepositoryImpl := repository2.NewDeploymentTemplateRepositoryImpl(db, sugaredLogger) deploymentTemplateServiceImpl := generateManifest.NewDeploymentTemplateServiceImpl(sugaredLogger, chartServiceImpl, appListingServiceImpl, appListingRepositoryImpl, deploymentTemplateRepositoryImpl, helmAppServiceImpl, chartRepositoryImpl, chartTemplateServiceImpl, helmAppClientImpl, k8sServiceImpl, propertiesConfigServiceImpl, deploymentTemplateHistoryServiceImpl, environmentRepositoryImpl, appRepositoryImpl, scopedVariableManagerImpl, chartRefServiceImpl) imageScanObjectMetaRepositoryImpl := security.NewImageScanObjectMetaRepositoryImpl(db, sugaredLogger) @@ -610,11 +604,7 @@ func InitializeApp() (*App, error) { eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - serviceDeploymentServiceTypeConfig, err := service2.GetDeploymentServiceTypeConfig() - if err != nil { - return nil, err - } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, serviceDeploymentServiceTypeConfig, acdConfig, gitOpsConfigReadServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) @@ -637,7 +627,7 @@ func InitializeApp() (*App, error) { chartGroupReposotoryImpl := repository15.NewChartGroupReposotoryImpl(db, sugaredLogger) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) appStoreValuesServiceImpl := service3.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) - chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, environmentServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl) + chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, clusterInstalledAppsRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, environmentServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl) if err != nil { return nil, err } @@ -687,7 +677,7 @@ func InitializeApp() (*App, error) { imageScanRouterImpl := router.NewImageScanRouterImpl(imageScanRestHandlerImpl) policyRestHandlerImpl := restHandler.NewPolicyRestHandlerImpl(sugaredLogger, policyServiceImpl, userServiceImpl, userAuthServiceImpl, enforcerImpl, enforcerUtilImpl, environmentServiceImpl) policyRouterImpl := router.NewPolicyRouterImpl(policyRestHandlerImpl) - gitOpsConfigServiceImpl := gitops.NewGitOpsConfigServiceImpl(sugaredLogger, globalEnvVariables, gitOpsConfigRepositoryImpl, k8sServiceImpl, acdAuthConfig, clusterServiceImplExtended, gitFactory, argoUserServiceImpl, serviceClientImpl, gitOpsConfigReadServiceImpl) + gitOpsConfigServiceImpl := gitops.NewGitOpsConfigServiceImpl(sugaredLogger, environmentVariables, gitOpsConfigRepositoryImpl, k8sServiceImpl, acdAuthConfig, clusterServiceImplExtended, gitFactory, argoUserServiceImpl, serviceClientImpl, gitOpsConfigReadServiceImpl) gitOpsConfigRestHandlerImpl := restHandler.NewGitOpsConfigRestHandlerImpl(sugaredLogger, gitOpsConfigServiceImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl) gitOpsConfigRouterImpl := router.NewGitOpsConfigRouterImpl(gitOpsConfigRestHandlerImpl) dashboardConfig, err := dashboard.GetConfig() @@ -709,7 +699,7 @@ func InitializeApp() (*App, error) { } grafanaRouterImpl := router.NewGrafanaRouterImpl(sugaredLogger, grafanaConfig) ssoLoginRepositoryImpl := sso.NewSSOLoginRepositoryImpl(db) - ssoLoginServiceImpl := sso.NewSSOLoginServiceImpl(sugaredLogger, ssoLoginRepositoryImpl, k8sServiceImpl, devtronSecretConfig, userAuthOidcHelperImpl) + ssoLoginServiceImpl := sso.NewSSOLoginServiceImpl(sugaredLogger, ssoLoginRepositoryImpl, k8sServiceImpl, environmentVariables, userAuthOidcHelperImpl) ssoLoginRestHandlerImpl := sso2.NewSsoLoginRestHandlerImpl(validate, sugaredLogger, enforcerImpl, userServiceImpl, ssoLoginServiceImpl) ssoLoginRouterImpl := sso2.NewSsoLoginRouterImpl(ssoLoginRestHandlerImpl) posthogClient, err := telemetry.NewPosthogClient(sugaredLogger) From 29a7d471443a30a6b63510c29d92b596a8825045 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Wed, 7 Feb 2024 11:05:41 +0530 Subject: [PATCH 56/83] removed: comments --- api/router/app/appList/AppListingRouter.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/router/app/appList/AppListingRouter.go b/api/router/app/appList/AppListingRouter.go index 008d79236a..fa1c6c8f24 100644 --- a/api/router/app/appList/AppListingRouter.go +++ b/api/router/app/appList/AppListingRouter.go @@ -47,7 +47,6 @@ func (router AppListingRouterImpl) InitAppListingRouter(appListingRouter *mux.Ro Methods("POST") appListingRouter.Path("/group/{env-id}"). - //Queries("size", "{size}", "offset", "{offset}"). HandlerFunc(router.appListingRestHandler.FetchOverviewAppsByEnvironment). Methods("GET") } From 9eeb9114fe86abc8545143d0a5beda81e1f14419 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Fri, 9 Feb 2024 19:49:06 +0530 Subject: [PATCH 57/83] chore: broken down AppStoreDeploymentService interface --- api/appStore/InstalledAppRestHandler.go | 11 +- .../AppStoreDeploymentRestHandler.go | 69 +- .../deployment/wire_appStoreDeployment.go | 2 + api/cluster/EnvironmentRestHandler.go | 19 +- .../app/appList/AppFilteringRestHandler.go | 3 +- .../app/appList/AppListingRestHandler.go | 5 +- api/router/pubsub/ApplicationStatusHandler.go | 2 +- client/argocdServer/k8sClient.go | 4 +- cmd/external-app/wire.go | 12 +- cmd/external-app/wire_gen.go | 21 +- pkg/app/AppService.go | 2 +- pkg/appClone/batch/DataHolder.go | 9 +- pkg/appClone/batch/Deployment.go | 3 +- pkg/appClone/batch/Mocks_test.go | 17 +- pkg/appStore/adapter/Adapter.go | 98 +- pkg/appStore/bean/bean.go | 17 +- pkg/appStore/chartGroup/ChartGroupService.go | 68 +- pkg/appStore/installedApp/adapter/Adapter.go | 2 +- .../service/AppStoreDeploymentDBService.go | 442 ++++++++- .../service/AppStoreDeploymentService.go | 886 +++--------------- .../service/EAMode/EAModeDeploymentService.go | 2 +- .../service/EAMode/InstalledAppDBService.go | 81 +- .../deployment/DeploymentStatusService.go | 5 +- .../deployment/InstalledAppArgoCdService.go | 13 +- pkg/cluster/ClusterService.go | 1 - pkg/cluster/EnvironmentService.go | 183 ++-- pkg/cluster/adapter/Adapter.go | 31 + pkg/cluster/repository/bean/bean.go | 46 + pkg/delete/DeleteService.go | 5 +- pkg/delete/DeleteServiceExtended.go | 3 +- .../DeploymentTypeOverrideService.go | 32 +- pkg/pipeline/CdHandler.go | 7 +- .../DeploymentPipelineConfigService.go | 15 +- pkg/pipeline/WorkflowDagExecutor.go | 2 +- pkg/pipeline/mock_pipeline/PipelineBuilder.go | 6 +- pkg/security/ImageScanService.go | 3 +- wire_gen.go | 11 +- 37 files changed, 1085 insertions(+), 1053 deletions(-) create mode 100644 pkg/cluster/adapter/Adapter.go create mode 100644 pkg/cluster/repository/bean/bean.go diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index a209d1f5b0..91e7149975 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -84,6 +84,7 @@ type InstalledAppRestHandlerImpl struct { clusterService cluster.ClusterService acdServiceClient application.ServiceClient appStoreDeploymentService service.AppStoreDeploymentService + appStoreDeploymentDBService service.AppStoreDeploymentDBService helmAppClient client.HelmAppClient argoUserService argo.ArgoUserService cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler @@ -137,7 +138,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppOverview(w http.ResponseWrit } token := r.Header.Get("token") handler.Logger.Infow("request payload, FindAppOverview", "installedAppId", installedAppId) - installedApp, err := handler.installedAppService.CheckAppExistsByInstalledAppId(installedAppId) + installedApp, err := handler.installedAppService.GetInstalledAppById(installedAppId) appOverview, err := handler.appCrudOperationService.GetAppMetaInfo(installedApp.AppId, installedAppId, installedApp.EnvironmentId) if err != nil { handler.Logger.Errorw("service err, FetchAppOverview", "err", err, "appId", installedApp.AppId, "installedAppId", installedAppId) @@ -367,7 +368,7 @@ func (handler *InstalledAppRestHandlerImpl) DeployBulk(w http.ResponseWriter, r } else { visited[item.AppName] = true } - isChartRepoActive, err := handler.appStoreDeploymentService.IsChartRepoActive(item.AppStoreVersion) + isChartRepoActive, err := handler.appStoreDeploymentDBService.IsChartProviderActive(item.AppStoreVersion) if err != nil { handler.Logger.Errorw("service err, CreateInstalledApp", "err", err, "payload", request) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -506,7 +507,7 @@ func (handler *InstalledAppRestHandlerImpl) DeleteArgoInstalledAppWithNonCascade return } } - installedApp, err := handler.appStoreDeploymentService.GetInstalledApp(installedAppId) + installedApp, err := handler.appStoreDeploymentDBService.GetInstalledApp(installedAppId) if err != nil { handler.Logger.Error("request err, NonCascadeDeleteCdPipeline", "err", err) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -590,7 +591,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledApp(w htt } handler.Logger.Infow("request payload, FetchAppDetailsForInstalledApp, app store", "installedAppId", installedAppId, "envId", envId) - installedApp, err := handler.installedAppService.CheckAppExistsByInstalledAppId(installedAppId) + installedApp, err := handler.installedAppService.GetInstalledAppById(installedAppId) if err == pg.ErrNoRows { common.WriteJsonResp(w, err, "App not found in database", http.StatusBadRequest) return @@ -711,7 +712,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri return } handler.Logger.Infow("request payload, FetchAppDetailsForInstalledAppV2, app store", "installedAppId", installedAppId, "envId", envId) - installedApp, err := handler.installedAppService.CheckAppExistsByInstalledAppId(installedAppId) + installedApp, err := handler.installedAppService.GetInstalledAppById(installedAppId) if err == pg.ErrNoRows { common.WriteJsonResp(w, err, "App not found in database", http.StatusBadRequest) return diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index ab7faf4943..882108592f 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -23,7 +23,7 @@ import ( "errors" "fmt" service2 "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "net/http" "strconv" "strings" @@ -60,36 +60,39 @@ type AppStoreDeploymentRestHandler interface { } type AppStoreDeploymentRestHandlerImpl struct { - Logger *zap.SugaredLogger - userAuthService user.UserService - enforcer casbin.Enforcer - enforcerUtil rbac.EnforcerUtil - enforcerUtilHelm rbac.EnforcerUtilHelm - appStoreDeploymentService service.AppStoreDeploymentService - appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService - validator *validator.Validate - helmAppService service2.HelmAppService - helmAppRestHandler client.HelmAppRestHandler - argoUserService argo.ArgoUserService - attributesService attributes.AttributesService + Logger *zap.SugaredLogger + userAuthService user.UserService + enforcer casbin.Enforcer + enforcerUtil rbac.EnforcerUtil + enforcerUtilHelm rbac.EnforcerUtilHelm + appStoreDeploymentService service.AppStoreDeploymentService + appStoreDeploymentDBService service.AppStoreDeploymentDBService + validator *validator.Validate + helmAppService service2.HelmAppService + helmAppRestHandler client.HelmAppRestHandler + argoUserService argo.ArgoUserService + attributesService attributes.AttributesService + installAppService EAMode.InstalledAppDBService } func NewAppStoreDeploymentRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService user.UserService, - enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, appStoreDeploymentService service.AppStoreDeploymentService, - validator *validator.Validate, helmAppService service2.HelmAppService, appStoreDeploymentServiceC appStoreDeploymentCommon.AppStoreDeploymentCommonService, - argoUserService argo.ArgoUserService, attributesService attributes.AttributesService) *AppStoreDeploymentRestHandlerImpl { + enforcer casbin.Enforcer, enforcerUtil rbac.EnforcerUtil, enforcerUtilHelm rbac.EnforcerUtilHelm, + appStoreDeploymentService service.AppStoreDeploymentService, validator *validator.Validate, + helmAppService service2.HelmAppService, argoUserService argo.ArgoUserService, + attributesService attributes.AttributesService, installAppService EAMode.InstalledAppDBService, +) *AppStoreDeploymentRestHandlerImpl { return &AppStoreDeploymentRestHandlerImpl{ - Logger: Logger, - userAuthService: userAuthService, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - enforcerUtilHelm: enforcerUtilHelm, - appStoreDeploymentService: appStoreDeploymentService, - validator: validator, - helmAppService: helmAppService, - appStoreDeploymentServiceC: appStoreDeploymentServiceC, - argoUserService: argoUserService, - attributesService: attributesService, + Logger: Logger, + userAuthService: userAuthService, + enforcer: enforcer, + enforcerUtil: enforcerUtil, + enforcerUtilHelm: enforcerUtilHelm, + appStoreDeploymentService: appStoreDeploymentService, + validator: validator, + helmAppService: helmAppService, + argoUserService: argoUserService, + attributesService: attributesService, + installAppService: installAppService, } } @@ -141,7 +144,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) InstallApp(w http.ResponseWrite } //rbac block ends here - isChartRepoActive, err := handler.appStoreDeploymentService.IsChartRepoActive(request.AppStoreVersion) + isChartRepoActive, err := handler.appStoreDeploymentDBService.IsChartProviderActive(request.AppStoreVersion) if err != nil { handler.Logger.Errorw("service err, CreateInstalledApp", "err", err, "payload", request) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -205,7 +208,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) GetInstalledAppsByAppStoreId(w } token := r.Header.Get("token") handler.Logger.Infow("request payload, GetInstalledAppsByAppStoreId", "appStoreId", appStoreId) - res, err := handler.appStoreDeploymentService.GetAllInstalledAppsByAppStoreId(w, r, token, appStoreId) + res, err := handler.appStoreDeploymentDBService.GetAllInstalledAppsByAppStoreId(appStoreId) if err != nil { handler.Logger.Errorw("service err, GetInstalledAppsByAppStoreId", "err", err, "appStoreId", appStoreId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -291,7 +294,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) DeleteInstalledApp(w http.Respo handler.Logger.Infow("request payload, DeleteInstalledApp", "installAppId", installAppId) token := r.Header.Get("token") - installedApp, err := handler.appStoreDeploymentService.GetInstalledApp(installAppId) + installedApp, err := handler.appStoreDeploymentDBService.GetInstalledApp(installAppId) if err != nil { handler.Logger.Error(err) if err == pg.ErrNoRows { @@ -434,7 +437,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateInstalledApp(w http.Respo } token := r.Header.Get("token") handler.Logger.Debugw("request payload, UpdateInstalledApp", "payload", request) - installedApp, err := handler.appStoreDeploymentService.GetInstalledApp(request.InstalledAppId) + installedApp, err := handler.appStoreDeploymentDBService.GetInstalledApp(request.InstalledAppId) if err != nil { handler.Logger.Errorw("service err, UpdateInstalledApp", "err", err, "payload", request) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -522,7 +525,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) GetInstalledAppVersion(w http.R } token := r.Header.Get("token") handler.Logger.Infow("request payload, GetInstalledAppVersion", "installedAppVersionId", installedAppId) - dto, err := handler.appStoreDeploymentService.GetInstalledAppVersion(installedAppId, userId) + dto, err := handler.installAppService.GetInstalledAppVersion(installedAppId, userId) if err != nil { handler.Logger.Errorw("service err, GetInstalledAppVersion", "err", err, "installedAppVersionId", installedAppId) common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) @@ -587,7 +590,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res return } } else { - installedApp, err := handler.appStoreDeploymentService.GetInstalledApp(request.InstalledAppId) + installedApp, err := handler.appStoreDeploymentDBService.GetInstalledApp(request.InstalledAppId) if err != nil { handler.Logger.Errorw("service err, InstalledAppId", "err", err, "InstalledAppId", request.InstalledAppId) common.WriteJsonResp(w, fmt.Errorf("Unable to fetch installed app details"), nil, http.StatusBadRequest) diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 9e242377b7..57cce85f84 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -19,6 +19,8 @@ var AppStoreDeploymentWireSet = wire.NewSet( wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), NewAppStoreDeploymentRestHandlerImpl, wire.Bind(new(AppStoreDeploymentRestHandler), new(*AppStoreDeploymentRestHandlerImpl)), NewAppStoreDeploymentRouterImpl, diff --git a/api/cluster/EnvironmentRestHandler.go b/api/cluster/EnvironmentRestHandler.go index 0535a7f70f..9112b81fe5 100644 --- a/api/cluster/EnvironmentRestHandler.go +++ b/api/cluster/EnvironmentRestHandler.go @@ -20,6 +20,7 @@ package cluster import ( "context" "encoding/json" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "net/http" "strconv" "strings" @@ -103,7 +104,7 @@ func (impl EnvironmentRestHandlerImpl) Create(w http.ResponseWriter, r *http.Req common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) return } - var bean request.EnvironmentBean + var bean bean2.EnvironmentBean err = decoder.Decode(&bean) if err != nil { impl.logger.Errorw("request err, Create", "err", err, "payload", bean) @@ -177,10 +178,10 @@ func (impl EnvironmentRestHandlerImpl) GetAll(w http.ResponseWriter, r *http.Req common.WriteJsonResp(w, err, environments, http.StatusOK) return } - grantedEnvironments := make([]*request.EnvironmentBean, 0) + grantedEnvironments := make([]*bean2.EnvironmentBean, 0) var envIdentifierList []string - envIdentifierMap := make(map[string]*request.EnvironmentBean) + envIdentifierMap := make(map[string]*bean2.EnvironmentBean) for _, item := range environments { envIdentifier := strings.ToLower(item.EnvironmentIdentifier) envIdentifierList = append(envIdentifierList, envIdentifier) @@ -206,7 +207,7 @@ func (impl EnvironmentRestHandlerImpl) GetAllActive(w http.ResponseWriter, r *ht return } - var result []request.EnvironmentBean + var result []bean2.EnvironmentBean token := r.Header.Get("token") for _, item := range bean { // RBAC enforcer applying @@ -227,7 +228,7 @@ func (impl EnvironmentRestHandlerImpl) Update(w http.ResponseWriter, r *http.Req return } - var bean request.EnvironmentBean + var bean bean2.EnvironmentBean err = decoder.Decode(&bean) if err != nil { impl.logger.Errorw("service err, Update", "err", err, "payload", bean) @@ -313,7 +314,7 @@ func (impl EnvironmentRestHandlerImpl) GetEnvironmentListForAutocomplete(w http. var grantedEnvironment = environments start = time.Now() if !impl.cfg.IgnoreAuthCheck { - grantedEnvironment = make([]request.EnvironmentBean, 0) + grantedEnvironment = make([]bean2.EnvironmentBean, 0) // RBAC enforcer applying var envIdentifierList []string for _, item := range environments { @@ -360,7 +361,7 @@ func (impl EnvironmentRestHandlerImpl) GetCombinedEnvironmentListForDropDown(w h return } if len(clusters) == 0 { - clusters = make([]*request.ClusterEnvDto, 0) + clusters = make([]*bean2.ClusterEnvDto, 0) } common.WriteJsonResp(w, err, clusters, http.StatusOK) } @@ -387,7 +388,7 @@ func (impl EnvironmentRestHandlerImpl) DeleteEnvironment(w http.ResponseWriter, common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized) return } - var bean request.EnvironmentBean + var bean bean2.EnvironmentBean err = decoder.Decode(&bean) if err != nil { impl.logger.Errorw("request err, Delete", "err", err, "payload", bean) @@ -449,7 +450,7 @@ func (impl EnvironmentRestHandlerImpl) GetCombinedEnvironmentListForDropDownByCl } if len(clusters) == 0 { - clusters = make([]*request.ClusterEnvDto, 0) + clusters = make([]*bean2.ClusterEnvDto, 0) } common.WriteJsonResp(w, err, clusters, http.StatusOK) } diff --git a/api/restHandler/app/appList/AppFilteringRestHandler.go b/api/restHandler/app/appList/AppFilteringRestHandler.go index c0e6faf87a..568bc2a644 100644 --- a/api/restHandler/app/appList/AppFilteringRestHandler.go +++ b/api/restHandler/app/appList/AppFilteringRestHandler.go @@ -24,6 +24,7 @@ import ( "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/team" "go.uber.org/zap" "net/http" @@ -133,7 +134,7 @@ func (handler AppFilteringRestHandlerImpl) GetClusterTeamAndEnvListForAutocomple start = time.Now() println(dbElapsedTime, grantedEnvironment) if !handler.cfg.IgnoreAuthCheck { - grantedEnvironment = make([]cluster.EnvironmentBean, 0) + grantedEnvironment = make([]bean2.EnvironmentBean, 0) // RBAC enforcer applying var envIdentifierList []string for index, item := range environments { diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 82a10e10c6..373f14bf85 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -27,6 +27,7 @@ import ( argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "net/http" "strconv" "time" @@ -120,7 +121,7 @@ type AppStatus struct { type AppAutocomplete struct { Teams []team.TeamRequest - Environments []cluster.EnvironmentBean + Environments []bean2.EnvironmentBean Clusters []cluster.ClusterBean } @@ -894,7 +895,7 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } - installedApp, err := handler.installedAppService.CheckAppExistsByInstalledAppId(installedAppId) + installedApp, err := handler.installedAppService.GetInstalledAppById(installedAppId) if err == pg.ErrNoRows { common.WriteJsonResp(w, err, "App not found in database", http.StatusBadRequest) return diff --git a/api/router/pubsub/ApplicationStatusHandler.go b/api/router/pubsub/ApplicationStatusHandler.go index df6a20cbab..0bd555d283 100644 --- a/api/router/pubsub/ApplicationStatusHandler.go +++ b/api/router/pubsub/ApplicationStatusHandler.go @@ -244,7 +244,7 @@ func (impl *ApplicationStatusHandlerImpl) updateArgoAppDeleteStatus(app *v1alpha } // Check to ensure that delete request for app was received - installedApp, err := impl.installedAppService.CheckAppExistsByInstalledAppId(model.InstalledAppId) + installedApp, err := impl.installedAppService.GetInstalledAppById(model.InstalledAppId) if err == pg.ErrNoRows { impl.logger.Errorw("App not found in database", "installedAppId", model.InstalledAppId, "err", err) return fmt.Errorf("app not found in database %s", err) diff --git a/client/argocdServer/k8sClient.go b/client/argocdServer/k8sClient.go index a1bd115356..ddad37e464 100644 --- a/client/argocdServer/k8sClient.go +++ b/client/argocdServer/k8sClient.go @@ -35,7 +35,7 @@ const ( ) type ArgoK8sClient interface { - CreateAcdApp(appRequest *AppTemplate, cluster *repository.Cluster, applicationTemplatePath string) (string, error) + CreateAcdApp(appRequest *AppTemplate, applicationTemplatePath string) (string, error) GetArgoApplication(namespace string, appName string, cluster *repository.Cluster) (map[string]interface{}, error) } type ArgoK8sClientImpl struct { @@ -62,7 +62,7 @@ func (impl ArgoK8sClientImpl) tprintf(tmpl string, data interface{}) (string, er return buf.String(), nil } -func (impl ArgoK8sClientImpl) CreateAcdApp(appRequest *AppTemplate, cluster *repository.Cluster, applicationTemplatePath string) (string, error) { +func (impl ArgoK8sClientImpl) CreateAcdApp(appRequest *AppTemplate, applicationTemplatePath string) (string, error) { chartYamlContent, err := ioutil.ReadFile(filepath.Clean(applicationTemplatePath)) if err != nil { impl.logger.Errorw("err in reading template", "err", err) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 3fad639c47..38b4458512 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -102,10 +102,10 @@ func InitializeApp() (*App, error) { pipelineConfig.NewMaterialRepositoryImpl, wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), - //appStatus + // appStatus appStatus.NewAppStatusRepositoryImpl, wire.Bind(new(appStatus.AppStatusRepository), new(*appStatus.AppStatusRepositoryImpl)), - //appStatus ends + // appStatus ends rbac.NewEnforcerUtilImpl, wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), @@ -126,7 +126,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), pipelineConfig.NewAppLabelRepositoryImpl, wire.Bind(new(pipelineConfig.AppLabelRepository), new(*pipelineConfig.AppLabelRepositoryImpl)), - //acd session client bind with authenticator login + // acd session client bind with authenticator login wire.Bind(new(session.ServiceClient), new(*middleware.LoginService)), connector.NewPumpImpl, wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), @@ -153,7 +153,7 @@ func InitializeApp() (*App, error) { wire.Bind(new(repository.AttributesRepository), new(*repository.AttributesRepositoryImpl)), pipelineConfig.NewCiPipelineRepositoryImpl, wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), - // // needed for enforcer util ends + // needed for enforcer util ends // binding gitops to helm (for hyperion) wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), @@ -189,12 +189,8 @@ func InitializeApp() (*App, error) { kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl, wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)), - util.NewChartTemplateServiceImpl, - wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - security2.NewScanToolMetadataRepositoryImpl, wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), - //pubsub_lib.NewPubSubClientServiceImpl, // start: docker registry wire set injection router.NewDockerRegRouterImpl, diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 7fc8d00c6f..7c03e1c531 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -60,7 +60,6 @@ import ( repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/appStore/values/repository" service4 "github.com/devtron-labs/devtron/pkg/appStore/values/service" "github.com/devtron-labs/devtron/pkg/attributes" @@ -242,22 +241,20 @@ func InitializeApp() (*App, error) { return nil, err } dashboardRouterImpl := dashboard.NewDashboardRouterImpl(sugaredLogger, dashboardConfig) + installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, environmentServiceImpl, installedAppVersionHistoryRepositoryImpl) + gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) + gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, environmentVariables) + attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) + deploymentTypeOverrideServiceImpl := providerConfig.NewDeploymentTypeOverrideServiceImpl(sugaredLogger, environmentVariables, attributesServiceImpl) + appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) chartGroupDeploymentRepositoryImpl := repository7.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - clusterInstalledAppsRepositoryImpl := repository4.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) - chartTemplateServiceImpl := util.NewChartTemplateServiceImpl(sugaredLogger) - appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) - installedAppVersionHistoryRepositoryImpl := repository4.NewInstalledAppVersionHistoryRepositoryImpl(sugaredLogger, db) acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } - gitOpsConfigRepositoryImpl := repository3.NewGitOpsConfigRepositoryImpl(sugaredLogger, db) - gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, environmentVariables) - attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) - deploymentTypeOverrideServiceImpl := providerConfig.NewDeploymentTypeOverrideServiceImpl(sugaredLogger, environmentVariables, attributesServiceImpl) - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImpl, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) - installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) k8sCommonServiceImpl := k8s2.NewK8sCommonServiceImpl(sugaredLogger, k8sServiceImpl, clusterServiceImpl) @@ -285,7 +282,7 @@ func InitializeApp() (*App, error) { appStoreValuesServiceImpl := service4.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) appStoreValuesRouterImpl := appStoreValues.NewAppStoreValuesRouterImpl(appStoreValuesRestHandlerImpl) - appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, helmUserServiceImpl, attributesServiceImpl) + appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, helmUserServiceImpl, attributesServiceImpl, installedAppDBServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) chartProviderServiceImpl := chartProvider.NewChartProviderServiceImpl(sugaredLogger, chartRepoRepositoryImpl, chartRepositoryServiceImpl, dockerArtifactStoreRepositoryImpl, ociRegistryConfigRepositoryImpl) chartProviderRestHandlerImpl := chartProvider2.NewChartProviderRestHandlerImpl(sugaredLogger, userServiceImpl, validate, chartProviderServiceImpl, enforcerImpl) diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 04bc927976..447765ebf3 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -1196,7 +1196,7 @@ func (impl *AppServiceImpl) UpdateInstalledAppVersionHistoryByACDObject(app *v1a } else { if string(app.Status.Health.Status) == string(health.HealthStatusHealthy) { installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - installedAppVersionHistory.FinishedOn = time.Now() + installedAppVersionHistory.SetFinishedOn() } else { installedAppVersionHistory.Status = pipelineConfig.WorkflowInProgress } diff --git a/pkg/appClone/batch/DataHolder.go b/pkg/appClone/batch/DataHolder.go index 4b216aebbe..0c8e499ff1 100644 --- a/pkg/appClone/batch/DataHolder.go +++ b/pkg/appClone/batch/DataHolder.go @@ -23,6 +23,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/cluster" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/util" @@ -92,8 +93,8 @@ func executeDataHolderClone(impl DataHolderActionImpl, holder *v1.DataHolder, da if err != nil { return err } - var envSrc *cluster.EnvironmentBean - var envDest *cluster.EnvironmentBean + var envSrc *bean2.EnvironmentBean + var envDest *bean2.EnvironmentBean var configData *bean.ConfigDataRequest if holder.Source.Environment != nil { if envSrc, err = impl.envService.FindOne(*holder.Source.Environment); err != nil { @@ -218,7 +219,7 @@ func executeDataHolderDelete(impl DataHolderActionImpl, holder *v1.DataHolder, d if err != nil { return err } - var env *cluster.EnvironmentBean + var env *bean2.EnvironmentBean if holder.Destination.Environment != nil { if env, err = impl.envService.FindOne(*holder.Destination.Environment); err != nil { return err @@ -364,7 +365,7 @@ func executeDataHolderCreate(impl DataHolderActionImpl, holder *v1.DataHolder, d if err != nil { return err } - var env *cluster.EnvironmentBean + var env *bean2.EnvironmentBean var name string if dataType == v1.ConfigMap { name = *holder.Destination.ConfigMap diff --git a/pkg/appClone/batch/Deployment.go b/pkg/appClone/batch/Deployment.go index 3d3eaf9e88..69eba1a8e5 100644 --- a/pkg/appClone/batch/Deployment.go +++ b/pkg/appClone/batch/Deployment.go @@ -27,6 +27,7 @@ import ( "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/util" uuid "github.com/satori/go.uuid" @@ -170,7 +171,7 @@ func executeDeploymentCreate(impl DeploymentActionImpl, deployment *v1.Deploymen return util.GetErrorOrNil(errs) } -func transformToDeploymentConfig(deployment *v1.Deployment, env *cluster.EnvironmentBean, workflow []*appWorkflow.AppWorkflow, ciPipeline *pc.CiPipeline) (pipelineConfig *bean.CDPipelineConfigObject, err error) { +func transformToDeploymentConfig(deployment *v1.Deployment, env *bean2.EnvironmentBean, workflow []*appWorkflow.AppWorkflow, ciPipeline *pc.CiPipeline) (pipelineConfig *bean.CDPipelineConfigObject, err error) { pipelineConfig = &bean.CDPipelineConfigObject{} var pipelineName string if deployment.Destination.Pipeline == nil || len(*deployment.Destination.Pipeline) == 0 { diff --git a/pkg/appClone/batch/Mocks_test.go b/pkg/appClone/batch/Mocks_test.go index a6c52d5cc8..2814607341 100644 --- a/pkg/appClone/batch/Mocks_test.go +++ b/pkg/appClone/batch/Mocks_test.go @@ -26,6 +26,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" + bean3 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "go.uber.org/zap" ) @@ -155,24 +156,24 @@ func (impl ConfigMapServiceMock) CSEnvironmentFetchForEdit(name string, id int, type EnvironmentServiceMock struct{} -func (impl EnvironmentServiceMock) Create(mappings *cluster.EnvironmentBean, userId int32) (*cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) Create(mappings *bean3.EnvironmentBean, userId int32) (*bean3.EnvironmentBean, error) { panic("implement me") } -func (impl EnvironmentServiceMock) FindOne(environment string) (*cluster.EnvironmentBean, error) { - return &cluster.EnvironmentBean{Id: 1}, nil +func (impl EnvironmentServiceMock) FindOne(environment string) (*bean3.EnvironmentBean, error) { + return &bean3.EnvironmentBean{Id: 1}, nil //panic("implement me") } -func (impl EnvironmentServiceMock) GetAll() ([]cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) GetAll() ([]bean3.EnvironmentBean, error) { panic("implement me") } -func (impl EnvironmentServiceMock) GetAllActive() ([]cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) GetAllActive() ([]bean3.EnvironmentBean, error) { panic("implement me") } -func (impl EnvironmentServiceMock) FindById(id int) (*cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) FindById(id int) (*bean3.EnvironmentBean, error) { panic("implement me") } @@ -180,7 +181,7 @@ func (impl EnvironmentServiceMock) getClusterConfig(cluster *cluster.ClusterBean panic("implement me") } -func (impl EnvironmentServiceMock) Update(mappings *cluster.EnvironmentBean, userId int32) (*cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) Update(mappings *bean3.EnvironmentBean, userId int32) (*bean3.EnvironmentBean, error) { panic("implement me") } @@ -188,7 +189,7 @@ func (impl EnvironmentServiceMock) FindClusterByEnvId(id int) (*cluster.ClusterB panic("implement me") } -func (impl EnvironmentServiceMock) GetEnvironmentListForAutocomplete() ([]cluster.EnvironmentBean, error) { +func (impl EnvironmentServiceMock) GetEnvironmentListForAutocomplete() ([]bean3.EnvironmentBean, error) { panic("implement me") } diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go index e24837b9e2..bd62a16bda 100644 --- a/pkg/appStore/adapter/Adapter.go +++ b/pkg/appStore/adapter/Adapter.go @@ -3,9 +3,12 @@ package adapter import ( "encoding/json" "fmt" + "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" ) // NewInstallAppModel is used to generate new repository.InstalledApps model to be saved; @@ -41,20 +44,21 @@ func NewInstallAppVersionsModel(chart *appStoreBean.InstallAppVersionDTO) *repos } // NewInstallAppVersionHistoryModel is used to generate new repository.InstalledAppVersionHistory model to be saved; -// Note: Do not use for update operations -func NewInstallAppVersionHistoryModel(chart *appStoreBean.InstallAppVersionDTO, status string, helmInstallConfigDTO appStoreBean.HelmReleaseStatusConfig) (*repository.InstalledAppVersionHistory, error) { +// GitHash and FinishedOn are not provided by NewInstallAppVersionHistoryModel; since it is used only on update operations; +// Note: Do not use for update operations; +func NewInstallAppVersionHistoryModel(request *appStoreBean.InstallAppVersionDTO, status string, helmInstallConfigDTO appStoreBean.HelmReleaseStatusConfig) (*repository.InstalledAppVersionHistory, error) { installedAppVersions := &repository.InstalledAppVersionHistory{ - InstalledAppVersionId: chart.InstalledAppVersionId, - ValuesYamlRaw: chart.ValuesOverrideYaml, + InstalledAppVersionId: request.InstalledAppVersionId, + ValuesYamlRaw: request.ValuesOverrideYaml, } - helmInstallConfig, err := json.Marshal(helmInstallConfigDTO) + helmReleaseStatus, err := getHelmReleaseStatusConfig(helmInstallConfigDTO) if err != nil { return nil, err } - installedAppVersions.HelmReleaseStatusConfig = string(helmInstallConfig) + installedAppVersions.HelmReleaseStatusConfig = helmReleaseStatus installedAppVersions.SetStartedOn() installedAppVersions.SetStatus(status) - installedAppVersions.CreateAuditLog(chart.UserId) + installedAppVersions.CreateAuditLog(request.UserId) return installedAppVersions, nil } @@ -158,3 +162,83 @@ func GenerateInstallAppVersionMinDTO(chart *repository.InstalledApps) *appStoreB DeploymentAppType: chart.DeploymentAppType, } } + +// NewInstalledAppVersionModel will generate a new repository.InstalledAppVersions for the given appStoreBean.InstallAppVersionDTO +func NewInstalledAppVersionModel(request *appStoreBean.InstallAppVersionDTO) *repository.InstalledAppVersions { + installedAppVersion := &repository.InstalledAppVersions{ + InstalledAppId: request.InstalledAppId, + AppStoreApplicationVersionId: request.AppStoreVersion, + ValuesYaml: request.ValuesOverrideYaml, + ReferenceValueId: request.ReferenceValueId, + ReferenceValueKind: request.ReferenceValueKind, + } + installedAppVersion.CreateAuditLog(request.UserId) + installedAppVersion.MarkActive() + return installedAppVersion +} + +// UpdateInstalledAppVersionModel will update the same repository.InstalledAppVersions model object for the given appStoreBean.InstallAppVersionDTO +func UpdateInstalledAppVersionModel(model *repository.InstalledAppVersions, request *appStoreBean.InstallAppVersionDTO) { + if model == nil || request == nil { + return + } + model.Id = request.Id + model.ValuesYaml = request.ValuesOverrideYaml + model.ReferenceValueId = request.ReferenceValueId + model.ReferenceValueKind = request.ReferenceValueKind + model.UpdateAuditLog(request.UserId) + return +} + +// UpdateAdditionalEnvDetails update cluster.EnvironmentBean data into the same InstallAppVersionDTO +func UpdateAdditionalEnvDetails(request *appStoreBean.InstallAppVersionDTO, envBean *bean.EnvironmentBean) { + if request == nil { + return + } + request.Environment = envBean + request.ClusterId = envBean.ClusterId + request.Namespace = envBean.Namespace + request.UpdateACDAppName() +} + +// UpdateAppDetails update app.App data into the same InstallAppVersionDTO +func UpdateAppDetails(request *appStoreBean.InstallAppVersionDTO, app *app.App) { + if request == nil { + return + } + request.AppId = app.Id + request.AppName = app.AppName + request.TeamId = app.TeamId + request.AppOfferingMode = app.AppOfferingMode +} + +// UpdateInstallAppDetails update repository.InstalledApps data into the same InstallAppVersionDTO +func UpdateInstallAppDetails(request *appStoreBean.InstallAppVersionDTO, installedApp *repository.InstalledApps) { + if request == nil { + return + } + request.AppId = installedApp.AppId + request.EnvironmentId = installedApp.EnvironmentId + request.Status = installedApp.Status + request.GitOpsRepoName = installedApp.GitOpsRepoName + request.DeploymentAppType = installedApp.DeploymentAppType +} + +// UpdateAppStoreApplicationDetails update appStoreDiscoverRepository.AppStoreApplicationVersion data into the same InstallAppVersionDTO +func UpdateAppStoreApplicationDetails(request *appStoreBean.InstallAppVersionDTO, appStoreApplicationVersion *appStoreDiscoverRepository.AppStoreApplicationVersion) { + if request == nil { + return + } + request.AppStoreId = appStoreApplicationVersion.AppStoreId + request.AppStoreName = appStoreApplicationVersion.AppStore.Name + request.Deprecated = appStoreApplicationVersion.Deprecated + request.Readme = appStoreApplicationVersion.Readme +} + +func getHelmReleaseStatusConfig(helmInstallConfigDTO appStoreBean.HelmReleaseStatusConfig) (string, error) { + helmInstallConfig, err := json.Marshal(helmInstallConfigDTO) + if err != nil { + return "", err + } + return string(helmInstallConfig), nil +} diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 8966e94726..c85c0bfb55 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -19,7 +19,8 @@ package appStoreBean import ( "encoding/json" - repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + "fmt" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "time" ) @@ -79,7 +80,7 @@ type InstallAppVersionDTO struct { ReferenceValueId int `json:"referenceValueId, omitempty" validate:"required,number"` // TODO: ineffective usage of omitempty; can be removed ReferenceValueKind string `json:"referenceValueKind, omitempty" validate:"oneof=DEFAULT TEMPLATE DEPLOYED EXISTING"` // TODO: ineffective usage of omitempty; can be removed ACDAppName string `json:"-"` - Environment *repository2.Environment `json:"-"` + Environment *bean.EnvironmentBean `json:"-"` ChartGroupEntryId int `json:"-"` Status AppstoreDeploymentStatus `json:"-"` AppStoreId int `json:"appStoreId"` @@ -101,10 +102,22 @@ type InstallAppVersionDTO struct { AppStoreApplicationVersionId int } +// UpdateDeploymentAppType updates deploymentAppType to InstallAppVersionDTO func (chart *InstallAppVersionDTO) UpdateDeploymentAppType(deploymentAppType string) { + if chart == nil { + return + } chart.DeploymentAppType = deploymentAppType } +// UpdateACDAppName updates ArgoCd app object name to InstallAppVersionDTO +func (chart *InstallAppVersionDTO) UpdateACDAppName() { + if chart == nil || chart.Environment == nil { + return + } + chart.ACDAppName = fmt.Sprintf("%s-%s", chart.AppName, chart.Environment.Environment) +} + // InstalledAppDeploymentAction is an internal struct for Helm App deployment; used to decide the deployment steps to be performed type InstalledAppDeploymentAction struct { PerformGitOpsForHelmApp bool diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index 1052869bb3..1099f1917e 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -33,10 +33,11 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" service2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/appStore/values/service" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" - repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" repository4 "github.com/devtron-labs/devtron/pkg/team" @@ -67,18 +68,19 @@ type ChartGroupServiceImpl struct { appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository userAuthService user.UserAuthService appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository repository5.EnvironmentRepository + environmentService cluster2.EnvironmentService teamRepository repository4.TeamRepository clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository appStoreValuesService service.AppStoreValuesService pubSubClient *pubsub.PubSubClientServiceImpl - envService cluster2.EnvironmentService appStoreDeploymentService service2.AppStoreDeploymentService + appStoreDeploymentDBService service2.AppStoreDeploymentDBService argoUserService argo.ArgoUserService pipelineStatusTimelineService status.PipelineStatusTimelineService acdConfig *argocdServer.ACDConfig fullModeDeploymentService deployment.FullModeDeploymentService gitOperationService git.GitOperationService + installAppService FullMode.InstalledAppDBExtendedService } func NewChartGroupServiceImpl(logger *zap.SugaredLogger, @@ -89,18 +91,18 @@ func NewChartGroupServiceImpl(logger *zap.SugaredLogger, appStoreVersionValuesRepository appStoreValuesRepository.AppStoreVersionValuesRepository, userAuthService user.UserAuthService, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository repository5.EnvironmentRepository, + environmentService cluster2.EnvironmentService, teamRepository repository4.TeamRepository, clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appStoreValuesService service.AppStoreValuesService, pubSubClient *pubsub.PubSubClientServiceImpl, - envService cluster2.EnvironmentService, appStoreDeploymentService service2.AppStoreDeploymentService, argoUserService argo.ArgoUserService, pipelineStatusTimelineService status.PipelineStatusTimelineService, acdConfig *argocdServer.ACDConfig, fullModeDeploymentService deployment.FullModeDeploymentService, - gitOperationService git.GitOperationService) (*ChartGroupServiceImpl, error) { + gitOperationService git.GitOperationService, + installAppService FullMode.InstalledAppDBExtendedService) (*ChartGroupServiceImpl, error) { impl := &ChartGroupServiceImpl{ logger: logger, chartGroupEntriesRepository: chartGroupEntriesRepository, @@ -110,18 +112,18 @@ func NewChartGroupServiceImpl(logger *zap.SugaredLogger, appStoreVersionValuesRepository: appStoreVersionValuesRepository, userAuthService: userAuthService, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, + environmentService: environmentService, teamRepository: teamRepository, clusterInstalledAppsRepository: clusterInstalledAppsRepository, appStoreValuesService: appStoreValuesService, pubSubClient: pubSubClient, - envService: envService, appStoreDeploymentService: appStoreDeploymentService, argoUserService: argoUserService, pipelineStatusTimelineService: pipelineStatusTimelineService, acdConfig: acdConfig, fullModeDeploymentService: fullModeDeploymentService, gitOperationService: gitOperationService, + installAppService: installAppService, } err := impl.subscribe() @@ -581,7 +583,7 @@ func (impl *ChartGroupServiceImpl) DeployBulk(chartGroupInstallRequest *ChartGro // Rollback tx on error. defer tx.Rollback() for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx) + installAppVersionDTO, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationDB(installAppVersionDTO, tx) if err != nil { impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) return nil, err @@ -692,7 +694,7 @@ func (impl *ChartGroupServiceImpl) triggerDeploymentEvent(installAppVersions []* } if versions.Status == appStoreBean.DEPLOY_INIT || versions.Status == appStoreBean.QUE_ERROR || versions.Status == appStoreBean.ENQUEUED { impl.logger.Debugw("status for bulk app-store deploy", "status", installedAppDeploymentStatus) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(payload.InstalledAppVersionId, installedAppDeploymentStatus) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(payload.InstalledAppVersionId, installedAppDeploymentStatus) if err != nil { impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) } @@ -704,19 +706,19 @@ func (impl *ChartGroupServiceImpl) DeployDefaultChartOnCluster(bean *cluster2.Cl // STEP 1 - create environment with name "devton" impl.logger.Infow("STEP 1", "create environment for cluster component", bean) envName := fmt.Sprintf("%d-%s", bean.Id, appStoreBean.DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT) - env, err := impl.envService.FindOne(envName) + env, err := impl.environmentService.FindOne(envName) if err != nil && err != pg.ErrNoRows { return false, err } if err == pg.ErrNoRows { - env = &cluster2.EnvironmentBean{ + env = &bean2.EnvironmentBean{ Environment: envName, ClusterId: bean.Id, Namespace: envName, Default: false, Active: true, } - _, err := impl.envService.Create(env, userId) + _, err := impl.environmentService.Create(env, userId) if err != nil { impl.logger.Errorw("DeployDefaultChartOnCluster, error in creating environment", "data", env, "err", err) return false, err @@ -834,7 +836,7 @@ func (impl *ChartGroupServiceImpl) deployDefaultComponent(chartGroupInstallReque // Rollback tx on error. defer tx.Rollback() for _, installAppVersionDTO := range installAppVersionDTOList { - installAppVersionDTO, err = impl.appStoreDeploymentService.AppStoreDeployOperationDB(installAppVersionDTO, tx) + installAppVersionDTO, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationDB(installAppVersionDTO, tx) if err != nil { impl.logger.Errorw("DeployBulk, error while app store deploy db operation", "err", err) return nil, err @@ -874,7 +876,7 @@ func (impl *ChartGroupServiceImpl) deployDefaultComponent(chartGroupInstallReque _, err := impl.performDeployStage(versions.InstalledAppVersionId, versions.InstalledAppVersionHistoryId, chartGroupInstallRequest.UserId) if err != nil { impl.logger.Errorw("error in performing deploy stage", "deployPayload", versions, "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(versions.InstalledAppVersionId, appStoreBean.QUE_ERROR) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(versions.InstalledAppVersionId, appStoreBean.QUE_ERROR) if err != nil { impl.logger.Errorw("error while bulk app-store deploy status update", "err", err) } @@ -920,7 +922,7 @@ func (impl *ChartGroupServiceImpl) subscribe() error { func (impl *ChartGroupServiceImpl) performDeployStage(installedAppVersionId int, installedAppVersionHistoryId int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { ctx := context.Background() - installedAppVersion, err := impl.appStoreDeploymentService.GetInstalledAppVersion(installedAppVersionId, userId) + installedAppVersion, err := impl.installAppService.GetInstalledAppVersion(installedAppVersionId, userId) if err != nil { return nil, err } @@ -959,7 +961,7 @@ func (impl *ChartGroupServiceImpl) performDeployStage(installedAppVersionId int, _, err = impl.appStoreDeploymentService.InstallAppByHelm(installedAppVersion, ctx) if err != nil { impl.logger.Errorw("error", "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.HELM_ERROR) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.HELM_ERROR) if err != nil { impl.logger.Errorw("error", "err", err) return nil, err @@ -969,7 +971,7 @@ func (impl *ChartGroupServiceImpl) performDeployStage(installedAppVersionId int, } //step 4 db operation status triggered - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) if err != nil { impl.logger.Errorw("error", "err", err) return nil, err @@ -979,7 +981,7 @@ func (impl *ChartGroupServiceImpl) performDeployStage(installedAppVersionId int, } func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion *appStoreBean.InstallAppVersionDTO, ctx context.Context, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { - installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Name) + installedAppVersion.UpdateACDAppName() chartGitAttr := &commonBean.ChartGitAttribute{} if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || installedAppVersion.Status == appStoreBean.ENQUEUED || @@ -990,7 +992,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * appStoreGitOpsResponse, err := impl.fullModeDeploymentService.GenerateManifestAndPerformGitOperations(installedAppVersion) if err != nil { impl.logger.Errorw(" error", "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_ERROR) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_ERROR) if err != nil { impl.logger.Errorw(" error", "err", err) return nil, err @@ -1025,7 +1027,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * } _ = impl.pipelineStatusTimelineService.SaveTimeline(timeline, nil, true) impl.logger.Infow("GIT SUCCESSFUL", "chartGitAttrDB", appStoreGitOpsResponse) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_SUCCESS) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.GIT_SUCCESS) if err != nil { impl.logger.Errorw(" error", "err", err) return nil, err @@ -1054,7 +1056,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * } tx.Commit() // update build history for chart for argo_cd apps - err = impl.appStoreDeploymentService.UpdateInstalledAppVersionHistoryWithGitHash(installedAppVersion, nil) + err = impl.appStoreDeploymentDBService.UpdateInstalledAppVersionHistoryWithGitHash(installedAppVersion.InstalledAppVersionHistoryId, installedAppVersion.GitHash, installedAppVersion.UserId) if err != nil { impl.logger.Errorw("error on updating history for chart deployment", "error", err, "installedAppVersion", installedAppVersion) return nil, err @@ -1064,22 +1066,22 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * chartGitAttr.ChartLocation = appStoreGitOpsResponse.ChartGitAttribute.ChartLocation } else { impl.logger.Infow("DB and GIT operation already done for this app and env, proceed for further step", "installedAppId", installedAppVersion.InstalledAppId, "existing status", installedAppVersion.Status) - environment, err := impl.environmentRepository.FindById(installedAppVersion.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return nil, err + if installedAppVersion.Environment == nil { + environment, err := impl.environmentService.GetExtendedEnvBeanById(installedAppVersion.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching environment error", "envId", installedAppVersion.EnvironmentId, "err", err) + return nil, err + } + installedAppVersion.Environment = environment } - + adapter.UpdateAdditionalEnvDetails(installedAppVersion, installedAppVersion.Environment) repoUrl, err := impl.gitOperationService.GetRepoUrlByRepoName(installedAppVersion.GitOpsRepoName) if err != nil { //will allow to continue to persist status on next operation impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) } - chartGitAttr.RepoUrl = repoUrl - chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) - installedAppVersion.ACDAppName = fmt.Sprintf("%s-%s", installedAppVersion.AppName, environment.Name) - installedAppVersion.Environment = environment + chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Environment) } if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || @@ -1092,7 +1094,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * _, err := impl.fullModeDeploymentService.InstallApp(installedAppVersion, chartGitAttr, ctx, nil) if err != nil { impl.logger.Errorw("error", "chartGitAttr", chartGitAttr, "err", err) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_ERROR) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_ERROR) if err != nil { impl.logger.Errorw("error", "err", err) return nil, err @@ -1100,7 +1102,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * return nil, err } impl.logger.Infow("ACD SUCCESSFUL", "chartGitAttr", chartGitAttr) - _, err = impl.appStoreDeploymentService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_SUCCESS) + _, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationStatusUpdate(installedAppVersion.InstalledAppId, appStoreBean.ACD_SUCCESS) if err != nil { impl.logger.Errorw("error", "err", err) return nil, err diff --git a/pkg/appStore/installedApp/adapter/Adapter.go b/pkg/appStore/installedApp/adapter/Adapter.go index 75dd265781..b11f6b2964 100644 --- a/pkg/appStore/installedApp/adapter/Adapter.go +++ b/pkg/appStore/installedApp/adapter/Adapter.go @@ -11,7 +11,7 @@ import ( func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, repoURl string, tempRefChart string) *bean.PushChartToGitRequestDTO { return &bean.PushChartToGitRequestDTO{ AppName: installAppRequestDTO.AppName, - EnvName: installAppRequestDTO.Environment.Name, + EnvName: installAppRequestDTO.Environment.Environment, ChartAppStoreName: installAppRequestDTO.AppStoreName, RepoURL: repoURl, TempChartRefDir: tempRefChart, diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index 056282e1a1..290c8bcfb7 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -1,24 +1,104 @@ package service import ( + "encoding/json" "fmt" + "github.com/devtron-labs/devtron/internal/constants" + "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + discoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/bean" - util2 "github.com/devtron-labs/devtron/util" + clusterService "github.com/devtron-labs/devtron/pkg/cluster" + clutserBean "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" + globalUtil "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" + "go.uber.org/zap" + "net/http" + "time" ) -func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - err := impl.setEnvironmentForInstallAppRequest(installAppVersionRequest) +type AppStoreDeploymentDBService interface { + // AppStoreDeployOperationDB is used to perform Pre-Install DB operations in App Store deployments + AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) + // AppStoreDeployOperationStatusUpdate updates the bulk deployment status in repository.InstalledApps + AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) + // IsChartProviderActive validates if the chart provider for Helm App is active + IsChartProviderActive(appStoreVersionId int) (bool, error) + // GetInstalledApp returns - appStoreBean.InstallAppVersionDTO for the given InstalledAppId + GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) + // GetAllInstalledAppsByAppStoreId returns - []appStoreBean.InstalledAppsResponse for the given AppStoreId + GetAllInstalledAppsByAppStoreId(appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) + // UpdateInstalledAppVersionHistoryWithGitHash updates GitHash in the repository.InstalledAppVersionHistory + UpdateInstalledAppVersionHistoryWithGitHash(versionHistoryId int, gitHash string, userId int32) error + // UpdateProjectForHelmApp updates TeamId in the app.App + UpdateProjectForHelmApp(appName string, teamId int, userId int32) error + // InstallAppPostDbOperation is used to perform Post-Install DB operations in App Store deployments + InstallAppPostDbOperation(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error + // MarkInstalledAppVersionsInactiveByInstalledAppId will mark the repository.InstalledAppVersions inactive for the given InstalledAppId + MarkInstalledAppVersionsInactiveByInstalledAppId(installedAppId int, UserId int32, tx *pg.Tx) error + // MarkInstalledAppVersionModelInActive will mark the given repository.InstalledAppVersions inactive + MarkInstalledAppVersionModelInActive(installedAppVersionModel *repository.InstalledAppVersions, UserId int32, tx *pg.Tx) error + // MarkInstalledAppVersionHistorySucceeded will mark the repository.InstalledAppVersionHistory Status - Succeeded + MarkInstalledAppVersionHistorySucceeded(versionHistoryId int, deploymentAppType string) error + // UpdateInstalledAppVersionHistoryStatus will update the Status in the repository.InstalledAppVersionHistory + UpdateInstalledAppVersionHistoryStatus(versionHistoryId int, status string) error +} + +type AppStoreDeploymentDBServiceImpl struct { + logger *zap.SugaredLogger + installedAppRepository repository.InstalledAppRepository + appStoreApplicationVersionRepository discoverRepository.AppStoreApplicationVersionRepository + appRepository app.AppRepository + environmentService clusterService.EnvironmentService + clusterService clusterService.ClusterService + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository + deploymentTypeConfig *globalUtil.DeploymentServiceTypeConfig + gitOpsConfigReadService config.GitOpsConfigReadService + deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService +} + +func NewAppStoreDeploymentDBServiceImpl(logger *zap.SugaredLogger, + installedAppRepository repository.InstalledAppRepository, + appStoreApplicationVersionRepository discoverRepository.AppStoreApplicationVersionRepository, + appRepository app.AppRepository, + environmentService clusterService.EnvironmentService, + clusterService clusterService.ClusterService, + installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, + envVariables *globalUtil.EnvironmentVariables, + gitOpsConfigReadService config.GitOpsConfigReadService, + deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService) *AppStoreDeploymentDBServiceImpl { + return &AppStoreDeploymentDBServiceImpl{ + logger: logger, + installedAppRepository: installedAppRepository, + appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, + appRepository: appRepository, + environmentService: environmentService, + clusterService: clusterService, + installedAppRepositoryHistory: installedAppRepositoryHistory, + deploymentTypeConfig: envVariables.DeploymentServiceTypeConfig, + gitOpsConfigReadService: gitOpsConfigReadService, + deploymentTypeOverrideService: deploymentTypeOverrideService, + } +} + +func (impl *AppStoreDeploymentDBServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { + environment, err := impl.getEnvironmentForInstallAppRequest(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in getting environment for install helm chart", "envId", installAppVersionRequest.EnvironmentId, "err", err) return nil, err } + // setting additional env data required in appStoreBean.InstallAppVersionDTO + adapter.UpdateAdditionalEnvDetails(installAppVersionRequest, environment) + // Stage 1: Create App in tx (Only if AppId is not set already) - if installAppVersionRequest.AppId <= 0 { + if installAppVersionRequest.AppId == 0 { appCreateRequest := &bean.CreateAppDTO{ AppName: installAppVersionRequest.AppName, TeamId: installAppVersionRequest.TeamId, @@ -34,15 +114,16 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppV // Stage 1: ends // Stage 2: validate deployment app type and override if ExternallyManagedDeploymentType - err = impl.validateAndOverrideDeploymentAppType(installAppVersionRequest) + overrideDeploymentType, err := impl.validateAndGetOverrideDeploymentAppType(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in validating deployment app type", "error", err) return nil, err } + installAppVersionRequest.UpdateDeploymentAppType(overrideDeploymentType) // Stage 2: ends // Stage 3: save installed_apps model - if util2.IsFullStack() && util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { + if globalUtil.IsFullStack() && util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { installAppVersionRequest.GitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) } installedAppModel := adapter.NewInstallAppModel(installAppVersionRequest, appStoreBean.DEPLOY_INIT) @@ -86,7 +167,7 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationDB(installAppV return installAppVersionRequest, nil } -func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { +func (impl *AppStoreDeploymentDBServiceImpl) AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) { dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() if err != nil { @@ -113,57 +194,356 @@ func (impl *AppStoreDeploymentServiceImpl) AppStoreDeployOperationStatusUpdate(i return true, nil } -func (impl *AppStoreDeploymentServiceImpl) validateAndOverrideDeploymentAppType(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *AppStoreDeploymentDBServiceImpl) IsChartProviderActive(appStoreVersionId int) (bool, error) { + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(appStoreVersionId) + if err != nil { + impl.logger.Errorw("fetching error", "err", err) + return false, err + } + if appStoreAppVersion.AppStore.ChartRepo != nil { + return appStoreAppVersion.AppStore.ChartRepo.Active, nil + } else if appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig != nil { + return appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig[0].IsChartPullActive, err + } + return false, nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) { + app, err := impl.installedAppRepository.GetInstalledApp(id) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + chartTemplate := adapter.GenerateInstallAppVersionMinDTO(app) + return chartTemplate, nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) GetAllInstalledAppsByAppStoreId(appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) { + installedApps, err := impl.installedAppRepository.GetAllInstalledAppsByAppStoreId(appStoreId) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Error(err) + return nil, err + } + var installedAppsEnvResponse []appStoreBean.InstalledAppsResponse + for _, a := range installedApps { + installedAppRes := appStoreBean.InstalledAppsResponse{ + EnvironmentName: a.EnvironmentName, + AppName: a.AppName, + DeployedAt: a.UpdatedOn, + DeployedBy: a.EmailId, + Status: a.AppStatus, + AppStoreApplicationVersionId: a.AppStoreApplicationVersionId, + InstalledAppVersionId: a.InstalledAppVersionId, + InstalledAppsId: a.InstalledAppId, + EnvironmentId: a.EnvironmentId, + AppOfferingMode: a.AppOfferingMode, + DeploymentAppType: a.DeploymentAppType, + } + + // if hyperion mode app, then fill clusterId and namespace + if globalUtil.IsHelmApp(a.AppOfferingMode) { + environment, err := impl.environmentService.FindById(a.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching environment error", "err", err) + return nil, err + } + installedAppRes.ClusterId = environment.ClusterId + installedAppRes.Namespace = environment.Namespace + } + + installedAppsEnvResponse = append(installedAppsEnvResponse, installedAppRes) + } + return installedAppsEnvResponse, nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) UpdateInstalledAppVersionHistoryWithGitHash(versionHistoryId int, gitHash string, userId int32) error { + savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(versionHistoryId) + savedInstalledAppVersionHistory.GitHash = gitHash + savedInstalledAppVersionHistory.UpdateAuditLog(userId) + _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(savedInstalledAppVersionHistory, nil) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return err + } + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) UpdateProjectForHelmApp(appName string, teamId int, userId int32) error { + appModel, err := impl.appRepository.FindActiveByName(appName) + if err != nil && util.IsErrNoRows(err) { + impl.logger.Errorw("error in fetching appModel", "err", err) + return err + } + + var appInstallationMode string + dbConnection := impl.appRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return err + } + defer tx.Rollback() + + if appModel == nil || appModel.Id == 0 { + // for cli Helm appModel, if appModel is not yet created + if globalUtil.IsBaseStack() { + appInstallationMode = globalUtil.SERVER_MODE_HYPERION + } else { + appInstallationMode = globalUtil.SERVER_MODE_FULL + } + createAppRequest := bean.CreateAppDTO{ + AppName: appName, + UserId: userId, + TeamId: teamId, + } + _, err = impl.createAppForAppStore(&createAppRequest, tx, appInstallationMode) + if err != nil { + impl.logger.Errorw("error while creating appModel", "error", err) + return err + } + } else { + // update team id if appModel exist + appModel.TeamId = teamId + appModel.UpdateAuditLog(userId) + err = impl.appRepository.UpdateWithTxn(appModel, tx) + if err != nil { + impl.logger.Errorw("error in updating project", "err", err) + return err + } + } + tx.Commit() + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) InstallAppPostDbOperation(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { + //step 4 db operation status update to deploy success + _, err := impl.AppStoreDeployOperationStatusUpdate(installAppVersionRequest.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) + if err != nil { + impl.logger.Errorw(" error", "err", err) + return err + } + + //step 5 create build history first entry for install app version for argocd or helm type deployments + if !impl.deploymentTypeConfig.HelmInstallASyncMode { + err = impl.MarkInstalledAppVersionHistorySucceeded(installAppVersionRequest.InstalledAppVersionHistoryId, installAppVersionRequest.DeploymentAppType) + if err != nil { + impl.logger.Errorw("error in updating installedApp History with sync ", "err", err) + return err + } + } + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) MarkInstalledAppVersionsInactiveByInstalledAppId(installedAppId int, UserId int32, tx *pg.Tx) error { + installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installedAppId) + if err != nil { + impl.logger.Errorw("error while fetching installed version", "error", err) + return err + } + for _, installedAppVersionModel := range installedAppVersions { + installedAppVersionModel.Active = false + installedAppVersionModel.UpdatedOn = time.Now() + installedAppVersionModel.UpdatedBy = UserId + _, err = impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) + if err != nil { + impl.logger.Errorw("error while update installed chart", "error", err) + return err + } + } + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) MarkInstalledAppVersionModelInActive(installedAppVersionModel *repository.InstalledAppVersions, UserId int32, tx *pg.Tx) error { + installedAppVersionModel.Active = false + installedAppVersionModel.UpdatedOn = time.Now() + installedAppVersionModel.UpdatedBy = UserId + _, err := impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return err + } + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) UpdateInstalledAppVersionHistoryStatus(versionHistoryId int, status string) error { + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return err + } + // Rollback tx on error. + defer tx.Rollback() + savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(versionHistoryId) + savedInstalledAppVersionHistory.Status = status + + _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(savedInstalledAppVersionHistory, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return err + } + err = tx.Commit() + if err != nil { + impl.logger.Errorw("error while committing transaction to db", "error", err) + return err + } + return nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) MarkInstalledAppVersionHistorySucceeded(versionHistoryId int, deploymentAppType string) error { + if util.IsManifestDownload(deploymentAppType) { + err := impl.UpdateInstalledAppVersionHistoryStatus(versionHistoryId, pipelineConfig.WorkflowSucceeded) + if err != nil { + impl.logger.Errorw("error on creating history for chart deployment", "error", err) + return err + } + } + + if util.IsHelmApp(deploymentAppType) { + installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(versionHistoryId) + if err != nil { + impl.logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) + return err + } + installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded + helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{ + InstallAppVersionHistoryId: installedAppVersionHistory.Id, + Message: "Release Installed", + IsReleaseInstalled: true, + ErrorInInstallation: false, + } + data, err := json.Marshal(helmInstallStatus) + if err != nil { + impl.logger.Errorw("error in marshalling helmInstallStatus message") + return err + } + installedAppVersionHistory.HelmReleaseStatusConfig = string(data) + _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) + if err != nil { + impl.logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) + return err + } + } + return nil +} + +// createAppForAppStore is an internal function used in App Store deployments; It creates an App for the InstallAppRequest +func (impl *AppStoreDeploymentDBServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string) (*bean.CreateAppDTO, error) { + // TODO refactoring: Handling for concurrent requests with same AppName + activeApp, err := impl.appRepository.FindActiveByName(createRequest.AppName) + if err != nil && util.IsErrNoRows(err) { + return nil, err + } + if activeApp != nil && activeApp.Id > 0 { + impl.logger.Infow(" app already exists", "name", createRequest.AppName) + err = &util.ApiError{ + Code: constants.AppAlreadyExists.Code, + InternalMessage: "app already exists", + UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), + } + return nil, err + } + appModel := &app.App{ + Active: true, + AppName: createRequest.AppName, + TeamId: createRequest.TeamId, + AppType: helper.ChartStoreApp, + AppOfferingMode: appInstallationMode, + } + appModel.CreateAuditLog(createRequest.UserId) + err = impl.appRepository.SaveWithTxn(appModel, tx) + if err != nil { + impl.logger.Errorw("error in saving entity ", "entity", appModel) + return nil, err + } + createRequest.Id = appModel.Id + return createRequest, nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) validateAndGetOverrideDeploymentAppType(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (overrideDeploymentType string, err error) { + // initialise OverrideDeploymentType to the given DeploymentType + overrideDeploymentType = installAppVersionRequest.DeploymentAppType + isGitOpsConfigured, err := impl.gitOpsConfigReadService.IsGitOpsConfigured() if err != nil { impl.logger.Errorw("error while checking IsGitOpsConfigured", "err", err) - return err + return overrideDeploymentType, err } appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { impl.logger.Errorw("error in fetching app store application version", "err", err) - return err + return overrideDeploymentType, err } isOCIRepo := appStoreAppVersion.AppStore.DockerArtifactStore != nil - if isOCIRepo || getAppInstallationMode(installAppVersionRequest.AppOfferingMode) == util2.SERVER_MODE_HYPERION { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM + if isOCIRepo || getAppInstallationMode(installAppVersionRequest.AppOfferingMode) == globalUtil.SERVER_MODE_HYPERION { + overrideDeploymentType = util.PIPELINE_DEPLOYMENT_TYPE_HELM } - err = impl.deploymentTypeOverrideService.SetAndValidateDeploymentAppType(&installAppVersionRequest.DeploymentAppType, isGitOpsConfigured, installAppVersionRequest.EnvironmentId) + overrideDeploymentType, err = impl.deploymentTypeOverrideService.ValidateAndOverrideDeploymentAppType(overrideDeploymentType, isGitOpsConfigured, installAppVersionRequest.EnvironmentId) if err != nil { impl.logger.Errorw("validation error for the used deployment type", "appName", installAppVersionRequest.AppName, "err", err) - return err + return overrideDeploymentType, err } - return nil + return overrideDeploymentType, nil } -func (impl *AppStoreDeploymentServiceImpl) setEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { +func (impl *AppStoreDeploymentDBServiceImpl) getEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*clutserBean.EnvironmentBean, error) { // create env if env not exists for clusterId and namespace for hyperion mode - if util2.IsHelmApp(getAppInstallationMode(installAppVersionRequest.AppOfferingMode)) { - // TODO refactoring: should it be in transaction - envId, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) + if globalUtil.IsHelmApp(getAppInstallationMode(installAppVersionRequest.AppOfferingMode)) { + envBean, err := impl.createEnvironmentIfNotExists(installAppVersionRequest) if err != nil { - return err + return nil, err } - installAppVersionRequest.EnvironmentId = envId + installAppVersionRequest.EnvironmentId = envBean.Id + return envBean, nil } - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) + environment, err := impl.environmentService.GetExtendedEnvBeanById(installAppVersionRequest.EnvironmentId) if err != nil { impl.logger.Errorw("fetching environment error", "envId", installAppVersionRequest.EnvironmentId, "err", err) - return err + return nil, err } - // setting additional env data required in appStoreBean.InstallAppVersionDTO - installAppVersionRequest.Environment = environment - installAppVersionRequest.ACDAppName = fmt.Sprintf("%s-%s", installAppVersionRequest.AppName, installAppVersionRequest.Environment.Name) - installAppVersionRequest.ClusterId = environment.ClusterId - return nil + return environment, nil +} + +func (impl *AppStoreDeploymentDBServiceImpl) createEnvironmentIfNotExists(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*clutserBean.EnvironmentBean, error) { + clusterId := installAppVersionRequest.ClusterId + namespace := installAppVersionRequest.Namespace + env, err := impl.environmentService.FindOneByNamespaceAndClusterId(namespace, clusterId) + if err != nil && !util.IsErrNoRows(err) { + return nil, err + } + if env.Id != 0 { + return env, nil + } + // create env + cluster, err := impl.clusterService.FindById(clusterId) + if err != nil { + impl.logger.Errorw("error in getting cluster details", "clusterId", clusterId) + return nil, &util.ApiError{ + HttpStatusCode: http.StatusBadRequest, + InternalMessage: err.Error(), + UserMessage: "Invalid cluster details!", + } + } + + environmentBean := &clutserBean.EnvironmentBean{ + Environment: clusterService.BuildEnvironmentName(cluster.ClusterName, namespace), + ClusterId: clusterId, + Namespace: namespace, + Default: false, + Active: true, + } + envCreateRes, err := impl.environmentService.Create(environmentBean, installAppVersionRequest.UserId) + if err != nil { + return nil, err + } + + return envCreateRes, nil } func getAppInstallationMode(appOfferingMode string) string { - appInstallationMode := util2.SERVER_MODE_FULL - if util2.IsBaseStack() || util2.IsHelmApp(appOfferingMode) { - appInstallationMode = util2.SERVER_MODE_HYPERION + appInstallationMode := globalUtil.SERVER_MODE_FULL + if globalUtil.IsBaseStack() || globalUtil.IsHelmApp(appOfferingMode) { + appInstallationMode = globalUtil.SERVER_MODE_HYPERION } return appInstallationMode } diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index f4dbb4bb20..4bd34957dd 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -19,7 +19,6 @@ package service import ( "context" - "encoding/json" "errors" "fmt" bean3 "github.com/devtron-labs/devtron/api/helm-app/bean" @@ -28,9 +27,7 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/appStore/adapter" @@ -41,14 +38,8 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" bean2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" - "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" - cluster2 "github.com/devtron-labs/devtron/pkg/cluster" - clusterRepository "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" - "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" - "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" "go.opentelemetry.io/otel" @@ -59,93 +50,69 @@ import ( ) type AppStoreDeploymentService interface { - AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) - AppStoreDeployOperationStatusUpdate(installAppId int, status appStoreBean.AppstoreDeploymentStatus) (bool, error) - IsChartRepoActive(appStoreVersionId int) (bool, error) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) - GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) - GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) + UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) DeleteInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, appIdentifier *service.AppIdentifier, userId int32) (*openapi.UpdateReleaseResponse, bool, error) + UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error RollbackApplication(ctx context.Context, request *openapi2.RollbackReleaseRequest, installedApp *appStoreBean.InstallAppVersionDTO, userId int32) (bool, error) - UpdateInstallAppVersionHistory(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*repository.InstalledAppVersionHistory, error) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, installedAppVersionHistoryId int) (*openapi.HelmAppDeploymentManifestDetail, error) - UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) - UpdateInstalledAppVersionHistoryWithGitHash(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) error - GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) - UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error - UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error } type AppStoreDeploymentServiceImpl struct { logger *zap.SugaredLogger installedAppRepository repository.InstalledAppRepository + installedAppService EAMode.InstalledAppDBService + appStoreDeploymentDBService AppStoreDeploymentDBService chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository - environmentRepository clusterRepository.EnvironmentRepository - clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository appRepository app.AppRepository eaModeDeploymentService EAMode.EAModeDeploymentService fullModeDeploymentService deployment.FullModeDeploymentService environmentService cluster.EnvironmentService - clusterService cluster.ClusterService helmAppService service.HelmAppService - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository deploymentTypeConfig *util2.DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService } -func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepository repository.InstalledAppRepository, - chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, - environmentRepository clusterRepository.EnvironmentRepository, clusterInstalledAppsRepository repository.ClusterInstalledAppsRepository, appRepository app.AppRepository, - eaModeDeploymentService EAMode.EAModeDeploymentService, fullModeDeploymentService deployment.FullModeDeploymentService, - environmentService cluster.EnvironmentService, clusterService cluster.ClusterService, helmAppService service.HelmAppService, - appStoreDeploymentCommonService appStoreDeploymentCommon.AppStoreDeploymentCommonService, +func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, + installedAppRepository repository.InstalledAppRepository, + installedAppService EAMode.InstalledAppDBService, + appStoreDeploymentDBService AppStoreDeploymentDBService, + chartGroupDeploymentRepository repository3.ChartGroupDeploymentRepository, + appStoreApplicationVersionRepository appStoreDiscoverRepository.AppStoreApplicationVersionRepository, + appRepository app.AppRepository, + eaModeDeploymentService EAMode.EAModeDeploymentService, + fullModeDeploymentService deployment.FullModeDeploymentService, + environmentService cluster.EnvironmentService, + helmAppService service.HelmAppService, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, - envVariables *util2.EnvironmentVariables, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService, - deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService) *AppStoreDeploymentServiceImpl { + envVariables *util2.EnvironmentVariables, + aCDConfig *argocdServer.ACDConfig, + gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { return &AppStoreDeploymentServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, + installedAppService: installedAppService, + appStoreDeploymentDBService: appStoreDeploymentDBService, chartGroupDeploymentRepository: chartGroupDeploymentRepository, appStoreApplicationVersionRepository: appStoreApplicationVersionRepository, - environmentRepository: environmentRepository, - clusterInstalledAppsRepository: clusterInstalledAppsRepository, appRepository: appRepository, eaModeDeploymentService: eaModeDeploymentService, fullModeDeploymentService: fullModeDeploymentService, environmentService: environmentService, - clusterService: clusterService, helmAppService: helmAppService, - appStoreDeploymentCommonService: appStoreDeploymentCommonService, installedAppRepositoryHistory: installedAppRepositoryHistory, deploymentTypeConfig: envVariables.DeploymentServiceTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, - deploymentTypeOverrideService: deploymentTypeOverrideService, - } -} - -func (impl *AppStoreDeploymentServiceImpl) IsChartRepoActive(appStoreVersionId int) (bool, error) { - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(appStoreVersionId) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return false, err - } - if appStoreAppVersion.AppStore.ChartRepo != nil { - return appStoreAppVersion.AppStore.ChartRepo.Active, nil - } else if appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig != nil { - return appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig[0].IsChartPullActive, err } - return false, nil } func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { @@ -158,7 +125,7 @@ func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest * // Rollback tx on error. defer tx.Rollback() //step 1 db operation initiated - installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx) + installAppVersionRequest, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationDB(installAppVersionRequest, tx) if err != nil { impl.logger.Errorw(" error", "err", err) return nil, err @@ -217,7 +184,7 @@ func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest * } err = tx.Commit() - err = impl.installAppPostDbOperation(installAppVersionRequest) + err = impl.appStoreDeploymentDBService.InstallAppPostDbOperation(installAppVersionRequest) if err != nil { return nil, err } @@ -225,177 +192,6 @@ func (impl *AppStoreDeploymentServiceImpl) InstallApp(installAppVersionRequest * return installAppVersionRequest, nil } -func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, status string) error { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return err - } - // Rollback tx on error. - defer tx.Rollback() - savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) - savedInstalledAppVersionHistory.Status = status - - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(savedInstalledAppVersionHistory, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return err - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while committing transaction to db", "error", err) - return err - } - return nil -} - -func (impl *AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistory(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*repository.InstalledAppVersionHistory, error) { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return nil, err - } - // Rollback tx on error. - defer tx.Rollback() - installedAppVersionHistory := &repository.InstalledAppVersionHistory{ - InstalledAppVersionId: installAppVersionRequest.Id, - } - installedAppVersionHistory.ValuesYamlRaw = installAppVersionRequest.ValuesOverrideYaml - installedAppVersionHistory.CreatedBy = installAppVersionRequest.UserId - installedAppVersionHistory.CreatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.GitHash = installAppVersionRequest.GitHash - installedAppVersionHistory.Status = "Unknown" - installedAppVersionHistory, err = impl.installedAppRepositoryHistory.CreateInstalledAppVersionHistory(installedAppVersionHistory, tx) - if err != nil { - impl.logger.Errorw("error while creating installed app version history", "error", err) - return nil, err - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while committing transaction to db", "error", err) - return nil, err - } - return installedAppVersionHistory, nil -} - -func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledAppVersionHistoryWithGitHash(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) error { - savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) - savedInstalledAppVersionHistory.GitHash = installAppVersionRequest.GitHash - savedInstalledAppVersionHistory.UpdatedOn = time.Now() - savedInstalledAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(savedInstalledAppVersionHistory, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return err - } - return nil -} - -func (impl *AppStoreDeploymentServiceImpl) createAppForAppStore(createRequest *bean.CreateAppDTO, tx *pg.Tx, appInstallationMode string) (*bean.CreateAppDTO, error) { - app1, err := impl.appRepository.FindActiveByName(createRequest.AppName) - if err != nil && err != pg.ErrNoRows { - return nil, err - } - if app1 != nil && app1.Id > 0 { - impl.logger.Infow(" app already exists", "name", createRequest.AppName) - err = &util.ApiError{ - Code: constants.AppAlreadyExists.Code, - InternalMessage: "app already exists", - UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), - } - return nil, err - } - appModel := &app.App{ - Active: true, - AppName: createRequest.AppName, - TeamId: createRequest.TeamId, - AppType: helper.ChartStoreApp, - AppOfferingMode: appInstallationMode, - AuditLog: sql.AuditLog{UpdatedBy: createRequest.UserId, CreatedBy: createRequest.UserId, UpdatedOn: time.Now(), CreatedOn: time.Now()}, - } - err = impl.appRepository.SaveWithTxn(appModel, tx) - if err != nil { - impl.logger.Errorw("error in saving entity ", "entity", appModel) - return nil, err - } - - // if found more than 1 application, soft delete all except first item - apps, err := impl.appRepository.FindActiveListByName(createRequest.AppName) - if err != nil { - return nil, err - } - appLen := len(apps) - if appLen > 1 { - firstElement := apps[0] - if firstElement.Id != appModel.Id { - appModel.Active = false - err = impl.appRepository.UpdateWithTxn(appModel, tx) - if err != nil { - impl.logger.Errorw("error in saving entity ", "entity", appModel) - return nil, err - } - err = &util.ApiError{ - Code: constants.AppAlreadyExists.Code, - InternalMessage: "app already exists", - UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), - } - } - } - - createRequest.Id = appModel.Id - return createRequest, nil -} - -func (impl *AppStoreDeploymentServiceImpl) GetInstalledApp(id int) (*appStoreBean.InstallAppVersionDTO, error) { - app, err := impl.installedAppRepository.GetInstalledApp(id) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - chartTemplate := adapter.GenerateInstallAppVersionMinDTO(app) - return chartTemplate, nil -} - -func (impl *AppStoreDeploymentServiceImpl) GetAllInstalledAppsByAppStoreId(w http.ResponseWriter, r *http.Request, token string, appStoreId int) ([]appStoreBean.InstalledAppsResponse, error) { - installedApps, err := impl.installedAppRepository.GetAllInstalledAppsByAppStoreId(appStoreId) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Error(err) - return nil, err - } - var installedAppsEnvResponse []appStoreBean.InstalledAppsResponse - for _, a := range installedApps { - installedAppRes := appStoreBean.InstalledAppsResponse{ - EnvironmentName: a.EnvironmentName, - AppName: a.AppName, - DeployedAt: a.UpdatedOn, - DeployedBy: a.EmailId, - Status: a.AppStatus, - AppStoreApplicationVersionId: a.AppStoreApplicationVersionId, - InstalledAppVersionId: a.InstalledAppVersionId, - InstalledAppsId: a.InstalledAppId, - EnvironmentId: a.EnvironmentId, - AppOfferingMode: a.AppOfferingMode, - DeploymentAppType: a.DeploymentAppType, - } - - // if hyperion mode app, then fill clusterId and namespace - if util2.IsHelmApp(a.AppOfferingMode) { - environment, err := impl.environmentRepository.FindById(a.EnvironmentId) - if err != nil { - impl.logger.Errorw("fetching environment error", "err", err) - return nil, err - } - installedAppRes.ClusterId = environment.ClusterId - installedAppRes.Namespace = environment.Namespace - } - - installedAppsEnvResponse = append(installedAppsEnvResponse, installedAppRes) - } - return installedAppsEnvResponse, nil -} - func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest.InstalledAppDeleteResponse = &appStoreBean.InstalledAppDeleteResponseDTO{ DeleteInitiated: false, @@ -409,14 +205,14 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex // Rollback tx on error. defer tx.Rollback() - environment, err := impl.environmentRepository.FindById(installAppVersionRequest.EnvironmentId) + environment, err := impl.environmentService.GetExtendedEnvBeanById(installAppVersionRequest.EnvironmentId) if err != nil { impl.logger.Errorw("fetching error", "err", err) return nil, err } - if len(environment.Cluster.ErrorInConnecting) > 0 { + if len(environment.ErrorInConnecting) > 0 { installAppVersionRequest.InstalledAppDeleteResponse.ClusterReachable = false - installAppVersionRequest.InstalledAppDeleteResponse.ClusterName = environment.Cluster.ClusterName + installAppVersionRequest.InstalledAppDeleteResponse.ClusterName = environment.ClusterName } app, err := impl.appRepository.FindById(installAppVersionRequest.AppId) @@ -435,12 +231,12 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex if installAppVersionRequest.AcdPartialDelete == true { if !util2.IsBaseStack() && !util2.IsHelmApp(app.AppOfferingMode) && !util.IsHelmApp(model.DeploymentAppType) { if !installAppVersionRequest.InstalledAppDeleteResponse.ClusterReachable { - impl.logger.Errorw("cluster connection error", "err", environment.Cluster.ErrorInConnecting) + impl.logger.Errorw("cluster connection error", "err", environment.ErrorInConnecting) if !installAppVersionRequest.NonCascadeDelete { return installAppVersionRequest, nil } } - err = impl.fullModeDeploymentService.DeleteACDAppObject(ctx, app.AppName, environment.Name, installAppVersionRequest) + err = impl.fullModeDeploymentService.DeleteACDAppObject(ctx, app.AppName, environment.Environment, installAppVersionRequest) } if err != nil { impl.logger.Errorw("error on delete installed app", "err", err) @@ -511,9 +307,9 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex // there might be a case if helm release gets uninstalled from helm cli. //in this case on deleting the app from API, it should not give error as it should get deleted from db, otherwise due to delete error, db does not get clean // so in helm, we need to check first if the release exists or not, if exists then only delete - err = impl.eaModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) + err = impl.eaModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) } else { - err = impl.fullModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Name, installAppVersionRequest, model, tx) + err = impl.fullModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) } if err != nil { impl.logger.Errorw("error on delete installed app", "err", err) @@ -535,7 +331,7 @@ func (impl *AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx c impl.logger.Infow("Linking helm application to chart store", "appId", request.GetAppId()) // check if chart repo is active starts - isChartRepoActive, err := impl.IsChartRepoActive(int(request.GetAppStoreApplicationVersionId())) + isChartRepoActive, err := impl.appStoreDeploymentDBService.IsChartProviderActive(int(request.GetAppStoreApplicationVersionId())) if err != nil { impl.logger.Errorw("Error in checking if chart repo is active or not", "err", err) return nil, isChartRepoActive, err @@ -582,38 +378,24 @@ func (impl *AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx c return res, isChartRepoActive, nil } -func (impl *AppStoreDeploymentServiceImpl) createEnvironmentIfNotExists(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (int, error) { - clusterId := installAppVersionRequest.ClusterId - namespace := installAppVersionRequest.Namespace - env, err := impl.environmentRepository.FindOneByNamespaceAndClusterId(namespace, clusterId) - - if err == nil { - return env.Id, nil - } +func (impl *AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error { - if err != pg.ErrNoRows { - return 0, err - } + appIdSplitted := strings.Split(updateAppRequest.AppId, "|") - // create env - cluster, err := impl.clusterService.FindById(clusterId) - if err != nil { - return 0, err - } + appName := updateAppRequest.AppName - environmentBean := &cluster2.EnvironmentBean{ - Environment: cluster2.BuildEnvironmentName(cluster.ClusterName, namespace), - ClusterId: clusterId, - Namespace: namespace, - Default: false, - Active: true, + if len(appIdSplitted) > 1 { + // app id is zero for CLI apps + appIdentifier, _ := impl.helmAppService.DecodeAppId(updateAppRequest.AppId) + appName = appIdentifier.ReleaseName } - envCreateRes, err := impl.environmentService.Create(environmentBean, installAppVersionRequest.UserId) + impl.logger.Infow("update helm project request", updateAppRequest) + err := impl.appStoreDeploymentDBService.UpdateProjectForHelmApp(appName, updateAppRequest.TeamId, updateAppRequest.UserId) if err != nil { - return 0, err + impl.logger.Errorw("error in linking project to helm app", "appName", appName, "err", err) + return err } - - return envCreateRes.Id, nil + return nil } func (impl *AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Context, request *openapi2.RollbackReleaseRequest, @@ -679,142 +461,6 @@ func (impl *AppStoreDeploymentServiceImpl) RollbackApplication(ctx context.Conte return success, nil } -func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*openapi.UpdateReleaseResponse, error) { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return nil, err - } - // Rollback tx on error. - defer tx.Rollback() - - // skipAppCreation flag is set for CLI apps because for CLI Helm apps if project is created first before linking to chart store then app is created during project update time. - // skipAppCreation - This flag will skip app creation if app already exists. - - //step 1 db operation initiated - appModel, err := impl.appRepository.FindActiveByName(installAppVersionRequest.AppName) - if err != nil && !util.IsErrNoRows(err) { - impl.logger.Errorw("error in getting app", "appName", installAppVersionRequest.AppName) - return nil, err - } - if appModel != nil && appModel.Id > 0 { - impl.logger.Infow(" app already exists", "name", installAppVersionRequest.AppName) - installAppVersionRequest.AppId = appModel.Id - } - installAppVersionRequest, err = impl.AppStoreDeployOperationDB(installAppVersionRequest, tx) - if err != nil { - impl.logger.Errorw(" error", "err", err) - return nil, err - } - - // fetch app store application version from DB - appStoreApplicationVersionId := installAppVersionRequest.AppStoreVersion - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(appStoreApplicationVersionId) - if err != nil { - impl.logger.Errorw("Error in fetching app store application version", "err", err, "appStoreApplicationVersionId", appStoreApplicationVersionId) - return nil, err - } - - // STEP-2 update APP with chart info - chartRepoInfo := appStoreAppVersion.AppStore.ChartRepo - updateReleaseRequest := &bean3.UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &bean4.InstallReleaseRequest{ - ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, - ChartName: appStoreAppVersion.Name, - ChartVersion: appStoreAppVersion.Version, - ReleaseIdentifier: &bean4.ReleaseIdentifier{ - ReleaseNamespace: installAppVersionRequest.Namespace, - ReleaseName: installAppVersionRequest.AppName, - }, - }, - SourceAppType: bean3.SOURCE_HELM_APP, - } - if chartRepoInfo != nil { - updateReleaseRequest.ChartRepository = &bean4.ChartRepository{ - Name: chartRepoInfo.Name, - Url: chartRepoInfo.Url, - Username: chartRepoInfo.UserName, - Password: chartRepoInfo.Password, - } - } - res, err := impl.helmAppService.UpdateApplicationWithChartInfo(ctx, installAppVersionRequest.ClusterId, updateReleaseRequest) - if err != nil { - return nil, err - } - // STEP-2 ends - - // tx commit here because next operation will be process after this commit. - err = tx.Commit() - if err != nil { - return nil, err - } - // STEP-3 install app DB post operations - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM - err = impl.installAppPostDbOperation(installAppVersionRequest) - if err != nil { - return nil, err - } - // STEP-3 ends - - return res, nil -} - -func (impl *AppStoreDeploymentServiceImpl) installAppPostDbOperation(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { - //step 4 db operation status update to deploy success - _, err := impl.AppStoreDeployOperationStatusUpdate(installAppVersionRequest.InstalledAppId, appStoreBean.DEPLOY_SUCCESS) - if err != nil { - impl.logger.Errorw(" error", "err", err) - return err - } - - //step 5 create build history first entry for install app version for argocd or helm type deployments - if !impl.deploymentTypeConfig.HelmInstallASyncMode { - err = impl.updateInstalledAppVersionHistoryWithSync(installAppVersionRequest) - if err != nil { - impl.logger.Errorw("error in updating installedApp History with sync ", "err", err) - return err - } - } - return nil -} - -func (impl *AppStoreDeploymentServiceImpl) updateInstalledAppVersionHistoryWithSync(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) error { - if installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_MANIFEST_DOWNLOAD { - err := impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowSucceeded) - if err != nil { - impl.logger.Errorw("error on creating history for chart deployment", "error", err) - return err - } - } - - if installAppVersionRequest.DeploymentAppType == util.PIPELINE_DEPLOYMENT_TYPE_HELM { - installedAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installAppVersionRequest.InstalledAppVersionHistoryId) - if err != nil { - impl.logger.Errorw("error in fetching installed app by installed app id in subscribe helm status callback", "err", err) - return err - } - installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{ - InstallAppVersionHistoryId: installedAppVersionHistory.Id, - Message: "Release Installed", - IsReleaseInstalled: true, - ErrorInInstallation: false, - } - data, err := json.Marshal(helmInstallStatus) - if err != nil { - impl.logger.Errorw("error in marshalling helmInstallStatus message") - return err - } - installedAppVersionHistory.HelmReleaseStatusConfig = string(data) - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) - if err != nil { - impl.logger.Errorw("error in updating helm release status data in installedAppVersionHistoryRepository", "err", err) - return err - } - } - return nil -} - func (impl *AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*bean3.DeploymentHistoryAndInstalledAppInfo, error) { result := &bean3.DeploymentHistoryAndInstalledAppInfo{} var err error @@ -875,178 +521,7 @@ func (impl *AppStoreDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context. return result, err } -func (impl *AppStoreDeploymentServiceImpl) updateInstalledAppVersion(installedAppVersion *repository.InstalledAppVersions, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx, installedApp *repository.InstalledApps) (*repository.InstalledAppVersions, *appStoreBean.InstallAppVersionDTO, error) { - var err error - if installAppVersionRequest.Id == 0 { - installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installAppVersionRequest.InstalledAppId) - if err != nil { - impl.logger.Errorw("error while fetching installed version", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - for _, installedAppVersionModel := range installedAppVersions { - installedAppVersionModel.Active = false - installedAppVersionModel.UpdatedOn = time.Now() - installedAppVersionModel.UpdatedBy = installAppVersionRequest.UserId - _, err = impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) - if err != nil { - impl.logger.Errorw("error while update installed chart", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - } - - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installedAppVersion, installAppVersionRequest, err - } - installedAppVersion = &repository.InstalledAppVersions{ - InstalledAppId: installAppVersionRequest.InstalledAppId, - AppStoreApplicationVersionId: installAppVersionRequest.AppStoreVersion, - ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, - } - installedAppVersion.CreatedBy = installAppVersionRequest.UserId - installedAppVersion.UpdatedBy = installAppVersionRequest.UserId - installedAppVersion.CreatedOn = time.Now() - installedAppVersion.UpdatedOn = time.Now() - installedAppVersion.Active = true - installedAppVersion.ReferenceValueId = installAppVersionRequest.ReferenceValueId - installedAppVersion.ReferenceValueKind = installAppVersionRequest.ReferenceValueKind - _, err = impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersion, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - installedAppVersion.AppStoreApplicationVersion = *appStoreAppVersion - installedAppVersion.InstalledApp = *installedApp - installAppVersionRequest.InstalledAppVersionId = installedAppVersion.Id - } else { - installedAppVersionModel, err := impl.installedAppRepository.GetInstalledAppVersion(installAppVersionRequest.Id) - if err != nil { - impl.logger.Errorw("error while fetching chart installed version", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - if installedAppVersionModel.AppStoreApplicationVersionId != installAppVersionRequest.AppStoreVersion { - // upgrade to new version of same chart - installedAppVersionModel.Active = false - installedAppVersionModel.UpdatedOn = time.Now() - installedAppVersionModel.UpdatedBy = installAppVersionRequest.UserId - _, err = impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) - if err != nil { - impl.logger.Errorw("fetching error", "err", err) - return installedAppVersion, installAppVersionRequest, err - } - installedAppVersion = &repository.InstalledAppVersions{ - InstalledAppId: installAppVersionRequest.InstalledAppId, - AppStoreApplicationVersionId: installAppVersionRequest.AppStoreVersion, - ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, - } - installedAppVersion.CreatedBy = installAppVersionRequest.UserId - installedAppVersion.UpdatedBy = installAppVersionRequest.UserId - installedAppVersion.CreatedOn = time.Now() - installedAppVersion.UpdatedOn = time.Now() - installedAppVersion.Active = true - installedAppVersion.ReferenceValueId = installAppVersionRequest.ReferenceValueId - installedAppVersion.ReferenceValueKind = installAppVersionRequest.ReferenceValueKind - _, err = impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersion, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return installedAppVersion, installAppVersionRequest, err - } - installedAppVersion.AppStoreApplicationVersion = *appStoreAppVersion - } else { - installedAppVersion = installedAppVersionModel - } - - } - return installedAppVersion, installAppVersionRequest, err -} - -func (impl *AppStoreDeploymentServiceImpl) MarkInstalledAppVersionsInactiveByInstalledAppId(installedAppId int, UserId int32, tx *pg.Tx) error { - installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installedAppId) - if err != nil { - impl.logger.Errorw("error while fetching installed version", "error", err) - return err - } - for _, installedAppVersionModel := range installedAppVersions { - installedAppVersionModel.Active = false - installedAppVersionModel.UpdatedOn = time.Now() - installedAppVersionModel.UpdatedBy = UserId - _, err = impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) - if err != nil { - impl.logger.Errorw("error while update installed chart", "error", err) - return err - } - } - return nil -} - -func (impl *AppStoreDeploymentServiceImpl) MarkInstalledAppVersionModelInActive(installedAppVersionModel *repository.InstalledAppVersions, UserId int32, tx *pg.Tx) error { - installedAppVersionModel.Active = false - installedAppVersionModel.UpdatedOn = time.Now() - installedAppVersionModel.UpdatedBy = UserId - _, err := impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersionModel, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return err - } - return nil -} - -func (impl *AppStoreDeploymentServiceImpl) CreateInstalledAppVersion(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*repository.InstalledAppVersions, error) { - // TODO fix me next - // TODO refactoring: move this to adapter - installedAppVersion := &repository.InstalledAppVersions{ - InstalledAppId: installAppVersionRequest.InstalledAppId, - AppStoreApplicationVersionId: installAppVersionRequest.AppStoreVersion, - ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, - } - installedAppVersion.CreatedBy = installAppVersionRequest.UserId - installedAppVersion.UpdatedBy = installAppVersionRequest.UserId - installedAppVersion.CreatedOn = time.Now() - installedAppVersion.UpdatedOn = time.Now() - installedAppVersion.Active = true - installedAppVersion.ReferenceValueId = installAppVersionRequest.ReferenceValueId - installedAppVersion.ReferenceValueKind = installAppVersionRequest.ReferenceValueKind - _, err := impl.installedAppRepository.CreateInstalledAppVersion(installedAppVersion, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - return installedAppVersion, nil -} - -// CheckIfMonoRepoMigrationRequired checks if gitOps repo name is changed -func (impl *AppStoreDeploymentServiceImpl) CheckIfMonoRepoMigrationRequired(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApp *repository.InstalledApps) bool { - - monoRepoMigrationRequired := false - var err error - gitOpsRepoName := installedApp.GitOpsRepoName - if len(gitOpsRepoName) == 0 { - if util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { - gitOpsRepoName, err = impl.fullModeDeploymentService.GetAcdAppGitOpsRepoName(installAppVersionRequest.AppName, installAppVersionRequest.EnvironmentName) - if err != nil { - return false - } - } else { - gitOpsRepoName = impl.gitOpsConfigReadService.GetGitOpsRepoName(installAppVersionRequest.AppName) - } - } - //here will set new git repo name if required to migrate - newGitOpsRepoName := impl.gitOpsConfigReadService.GetGitOpsRepoName(installedApp.App.AppName) - //checking weather git repo migration needed or not, if existing git repo and new independent git repo is not same than go ahead with migration - if newGitOpsRepoName != gitOpsRepoName { - monoRepoMigrationRequired = true - } - return monoRepoMigrationRequired -} - func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Context, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*appStoreBean.InstallAppVersionDTO, error) { - // db operations dbConnection := impl.installedAppRepository.GetConnection() tx, err := dbConnection.Begin() @@ -1056,7 +531,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex // Rollback tx on error. defer tx.Rollback() - installedApp, err := impl.installedAppRepository.GetInstalledApp(installAppVersionRequest.InstalledAppId) + installedApp, err := impl.installedAppService.GetInstalledAppById(installAppVersionRequest.InstalledAppId) if err != nil { return nil, err } @@ -1067,14 +542,13 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex var installedAppVersion *repository.InstalledAppVersions // mark previous versions of chart as inactive if chart or version is updated - isChartChanged := false // flag for keeping track if chart is updated by user or not isVersionChanged := false // flag for keeping track if version of chart is upgraded //if chart is changed, then installedAppVersion id is sent as 0 from front-end if installAppVersionRequest.Id == 0 { isChartChanged = true - err = impl.MarkInstalledAppVersionsInactiveByInstalledAppId(installAppVersionRequest.InstalledAppId, installAppVersionRequest.UserId, tx) + err = impl.appStoreDeploymentDBService.MarkInstalledAppVersionsInactiveByInstalledAppId(installAppVersionRequest.InstalledAppId, installAppVersionRequest.UserId, tx) if err != nil { return nil, err } @@ -1087,7 +561,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex // version is upgraded if appStoreApplication version from request payload is not equal to installed app version saved in DB if installedAppVersion.AppStoreApplicationVersionId != installAppVersionRequest.AppStoreVersion { isVersionChanged = true - err = impl.MarkInstalledAppVersionModelInActive(installedAppVersion, installAppVersionRequest.UserId, tx) + err = impl.appStoreDeploymentDBService.MarkInstalledAppVersionModelInActive(installedAppVersion, installAppVersionRequest.UserId, tx) } } @@ -1098,51 +572,43 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } // create new entry for installed app version if chart or version is changed if isChartChanged || isVersionChanged { - installedAppVersion, err = impl.CreateInstalledAppVersion(installAppVersionRequest, tx) + installedAppVersion, err = impl.installedAppService.CreateInstalledAppVersion(installAppVersionRequest, tx) if err != nil { + impl.logger.Errorw("error in creating installed app version", "err", err) return nil, err } - installedAppVersion.Id = installedAppVersion.Id - } else { - // TODO fix me next - // TODO refactoring: move this to adapter - installedAppVersion.ValuesYaml = installAppVersionRequest.ValuesOverrideYaml - installedAppVersion.UpdatedOn = time.Now() - installedAppVersion.UpdatedBy = installAppVersionRequest.UserId - installedAppVersion.ReferenceValueId = installAppVersionRequest.ReferenceValueId - installedAppVersion.ReferenceValueKind = installAppVersionRequest.ReferenceValueKind - _, err = impl.installedAppRepository.UpdateInstalledAppVersion(installedAppVersion, tx) + } else if installedAppVersion != nil && installedAppVersion.Id != 0 { + adapter.UpdateInstalledAppVersionModel(installedAppVersion, installAppVersionRequest) + installedAppVersion, err = impl.installedAppService.UpdateInstalledAppVersion(installedAppVersion, installAppVersionRequest, tx) if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) + impl.logger.Errorw("error in creating installed app version", "err", err) return nil, err } } - + // populate the related model data into repository.InstalledAppVersions + // related tables: repository.InstalledApps AND appStoreDiscoverRepository.AppStoreApplicationVersion installedAppVersion.AppStoreApplicationVersion = *appStoreAppVersion installedAppVersion.InstalledApp = *installedApp - installAppVersionRequest.InstalledAppVersionId = installedAppVersion.Id + // populate appStoreBean.InstallAppVersionDTO from the DB models installAppVersionRequest.Id = installedAppVersion.Id - installAppVersionRequest.EnvironmentId = installedApp.EnvironmentId - installAppVersionRequest.AppName = installedApp.App.AppName - installAppVersionRequest.EnvironmentName = installedApp.Environment.Name - installAppVersionRequest.Environment = &installedApp.Environment - - installAppVersionHistoryStatus := pipelineConfig.WorkflowInProgress - // TODO fix me next - // TODO refactoring: move this to adapter - installedAppVersionHistory := &repository.InstalledAppVersionHistory{ - InstalledAppVersionId: installedAppVersion.Id, - ValuesYamlRaw: installAppVersionRequest.ValuesOverrideYaml, - StartedOn: time.Now(), - Status: installAppVersionHistoryStatus, - AuditLog: sql.AuditLog{ - CreatedOn: time.Now(), - CreatedBy: installAppVersionRequest.UserId, - UpdatedOn: time.Now(), - UpdatedBy: installAppVersionRequest.UserId, - }, + installAppVersionRequest.InstalledAppVersionId = installedAppVersion.Id + adapter.UpdateInstallAppDetails(installAppVersionRequest, installedApp) + adapter.UpdateAppDetails(installAppVersionRequest, &installedApp.App) + environment, err := impl.environmentService.GetExtendedEnvBeanById(installedApp.EnvironmentId) + if err != nil { + impl.logger.Errorw("fetching environment error", "envId", installedApp.EnvironmentId, "err", err) + return nil, err } + adapter.UpdateAdditionalEnvDetails(installAppVersionRequest, environment) + + helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ + InstallAppVersionHistoryId: 0, + Message: "Install initiated", + IsReleaseInstalled: false, + ErrorInInstallation: false, + } + installedAppVersionHistory, err := adapter.NewInstallAppVersionHistoryModel(installAppVersionRequest, pipelineConfig.WorkflowInProgress, helmInstallConfigDTO) _, err = impl.installedAppRepositoryHistory.CreateInstalledAppVersionHistory(installedAppVersionHistory, tx) if err != nil { impl.logger.Errorw("error while creating installed app version history for updating installed app", "error", err) @@ -1162,7 +628,7 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex manifest, err := impl.fullModeDeploymentService.GenerateManifest(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in generating manifest for helm apps", "err", err) - _ = impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowFailed) + _ = impl.appStoreDeploymentDBService.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest.InstalledAppVersionHistoryId, pipelineConfig.WorkflowFailed) return nil, err } // required if gitOps repo name is changed, gitOps repo name will change if env variable which we use as suffix changes @@ -1243,13 +709,13 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { - err = impl.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest, pipelineConfig.WorkflowSucceeded) + err = impl.appStoreDeploymentDBService.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest.InstalledAppVersionHistoryId, pipelineConfig.WorkflowSucceeded) if err != nil { impl.logger.Errorw("error on creating history for chart deployment", "error", err) return nil, err } } else if util.IsHelmApp(installAppVersionRequest.DeploymentAppType) && !impl.deploymentTypeConfig.HelmInstallASyncMode { - err = impl.updateInstalledAppVersionHistoryWithSync(installAppVersionRequest) + err = impl.appStoreDeploymentDBService.MarkInstalledAppVersionHistorySucceeded(installAppVersionRequest.InstalledAppVersionHistoryId, installAppVersionRequest.DeploymentAppType) if err != nil { impl.logger.Errorw("error in updating install app version history on sync", "err", err) return nil, err @@ -1259,43 +725,6 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex return installAppVersionRequest, nil } -func (impl *AppStoreDeploymentServiceImpl) GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { - app, err := impl.installedAppRepository.GetInstalledAppVersion(id) - if err != nil { - if err == pg.ErrNoRows { - return nil, &util.ApiError{HttpStatusCode: http.StatusBadRequest, Code: "400", UserMessage: "values are outdated. please fetch the latest version and try again", InternalMessage: err.Error()} - } - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - installAppVersion := &appStoreBean.InstallAppVersionDTO{ - InstalledAppId: app.InstalledAppId, - AppName: app.InstalledApp.App.AppName, - AppId: app.InstalledApp.App.Id, - Id: app.Id, - TeamId: app.InstalledApp.App.TeamId, - EnvironmentId: app.InstalledApp.EnvironmentId, - ValuesOverrideYaml: app.ValuesYaml, - Readme: app.AppStoreApplicationVersion.Readme, - ReferenceValueKind: app.ReferenceValueKind, - ReferenceValueId: app.ReferenceValueId, - AppStoreVersion: app.AppStoreApplicationVersionId, //check viki - Status: app.InstalledApp.Status, - AppStoreId: app.AppStoreApplicationVersion.AppStoreId, - AppStoreName: app.AppStoreApplicationVersion.AppStore.Name, - Deprecated: app.AppStoreApplicationVersion.Deprecated, - GitOpsRepoName: app.InstalledApp.GitOpsRepoName, - UserId: userId, - AppOfferingMode: app.InstalledApp.App.AppOfferingMode, - ClusterId: app.InstalledApp.Environment.ClusterId, - Namespace: app.InstalledApp.Environment.Namespace, - DeploymentAppType: app.InstalledApp.DeploymentAppType, - Environment: &app.InstalledApp.Environment, - ACDAppName: fmt.Sprintf("%s-%s", app.InstalledApp.App.AppName, app.InstalledApp.Environment.Name), - } - return installAppVersion, err -} - func (impl *AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) { installAppVersionRequest, err := impl.eaModeDeploymentService.InstallApp(installAppVersionRequest, nil, ctx, nil) if err != nil { @@ -1303,7 +732,7 @@ func (impl *AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionReq return installAppVersionRequest, err } if !impl.deploymentTypeConfig.HelmInstallASyncMode { - err = impl.updateInstalledAppVersionHistoryWithSync(installAppVersionRequest) + err = impl.appStoreDeploymentDBService.MarkInstalledAppVersionHistorySucceeded(installAppVersionRequest.InstalledAppVersionHistoryId, installAppVersionRequest.DeploymentAppType) if err != nil { impl.logger.Errorw("error in updating installed app version history with sync", "err", err) return installAppVersionRequest, err @@ -1312,70 +741,6 @@ func (impl *AppStoreDeploymentServiceImpl) InstallAppByHelm(installAppVersionReq return installAppVersionRequest, nil } -func (impl *AppStoreDeploymentServiceImpl) UpdateProjectHelmApp(updateAppRequest *appStoreBean.UpdateProjectHelmAppDTO) error { - - appIdSplitted := strings.Split(updateAppRequest.AppId, "|") - - appName := updateAppRequest.AppName - - if len(appIdSplitted) > 1 { - // app id is zero for CLI apps - appIdentifier, _ := impl.helmAppService.DecodeAppId(updateAppRequest.AppId) - appName = appIdentifier.ReleaseName - } - - app, err := impl.appRepository.FindActiveByName(appName) - - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error in fetching app", "err", err) - return err - } - - var appInstallationMode string - - dbConnection := impl.appRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return err - } - - defer tx.Rollback() - - impl.logger.Infow("update helm project request", updateAppRequest) - if app.Id == 0 { - // for cli Helm app, if app is not yet created - if util2.IsBaseStack() { - appInstallationMode = util2.SERVER_MODE_HYPERION - } else { - appInstallationMode = util2.SERVER_MODE_FULL - } - createAppRequest := bean.CreateAppDTO{ - AppName: appName, - UserId: updateAppRequest.UserId, - TeamId: updateAppRequest.TeamId, - } - _, err := impl.createAppForAppStore(&createAppRequest, tx, appInstallationMode) - if err != nil { - impl.logger.Errorw("error while creating app", "error", err) - return err - } - } else { - // update team id if app exist - app.TeamId = updateAppRequest.TeamId - app.UpdatedOn = time.Now() - app.UpdatedBy = updateAppRequest.UserId - err = impl.appRepository.UpdateWithTxn(app, tx) - - if err != nil { - impl.logger.Errorw("error in updating project", "err", err) - return err - } - } - tx.Commit() - return nil - -} - func (impl *AppStoreDeploymentServiceImpl) UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error { //creating pipeline status timeline for deployment failed if !util.IsAcdApp(installAppVersionRequest.DeploymentAppType) { @@ -1389,29 +754,6 @@ func (impl *AppStoreDeploymentServiceImpl) UpdatePreviousDeploymentStatusForAppS return nil } -func (impl *AppStoreDeploymentServiceImpl) UpdateInstallAppVersionHistoryStatus(installedAppVersionHistoryId int, status string) error { - dbConnection := impl.installedAppRepository.GetConnection() - tx, err := dbConnection.Begin() - if err != nil { - return err - } - // Rollback tx on error. - defer tx.Rollback() - savedInstalledAppVersionHistory, err := impl.installedAppRepositoryHistory.GetInstalledAppVersionHistory(installedAppVersionHistoryId) - savedInstalledAppVersionHistory.Status = status - _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(savedInstalledAppVersionHistory, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return err - } - err = tx.Commit() - if err != nil { - impl.logger.Errorw("error while committing transaction to db", "error", err) - return err - } - return nil -} - func (impl *AppStoreDeploymentServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error { apiError := &util.ApiError{} installedApp, err := impl.installedAppRepository.GetGitOpsInstalledAppsWhereArgoAppDeletedIsTrue(installedAppId, envId) @@ -1464,3 +806,83 @@ func (impl *AppStoreDeploymentServiceImpl) MarkGitOpsInstalledAppsDeletedIfArgoA apiError.HttpStatusCode = http.StatusNotFound return apiError } + +func (impl *AppStoreDeploymentServiceImpl) linkHelmApplicationToChartStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*openapi.UpdateReleaseResponse, error) { + dbConnection := impl.installedAppRepository.GetConnection() + tx, err := dbConnection.Begin() + if err != nil { + return nil, err + } + // Rollback tx on error. + defer tx.Rollback() + + // skipAppCreation flag is set for CLI apps because for CLI Helm apps if project is created first before linking to chart store then app is created during project update time. + // skipAppCreation - This flag will skip app creation if app already exists. + + //step 1 db operation initiated + appModel, err := impl.appRepository.FindActiveByName(installAppVersionRequest.AppName) + if err != nil && !util.IsErrNoRows(err) { + impl.logger.Errorw("error in getting app", "appName", installAppVersionRequest.AppName) + return nil, err + } + if appModel != nil && appModel.Id > 0 { + impl.logger.Infow(" app already exists", "name", installAppVersionRequest.AppName) + installAppVersionRequest.AppId = appModel.Id + } + installAppVersionRequest, err = impl.appStoreDeploymentDBService.AppStoreDeployOperationDB(installAppVersionRequest, tx) + if err != nil { + impl.logger.Errorw(" error", "err", err) + return nil, err + } + + // fetch app store application version from DB + appStoreApplicationVersionId := installAppVersionRequest.AppStoreVersion + appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(appStoreApplicationVersionId) + if err != nil { + impl.logger.Errorw("Error in fetching app store application version", "err", err, "appStoreApplicationVersionId", appStoreApplicationVersionId) + return nil, err + } + + // STEP-2 update APP with chart info + chartRepoInfo := appStoreAppVersion.AppStore.ChartRepo + updateReleaseRequest := &bean3.UpdateApplicationWithChartInfoRequestDto{ + InstallReleaseRequest: &bean4.InstallReleaseRequest{ + ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, + ChartName: appStoreAppVersion.Name, + ChartVersion: appStoreAppVersion.Version, + ReleaseIdentifier: &bean4.ReleaseIdentifier{ + ReleaseNamespace: installAppVersionRequest.Namespace, + ReleaseName: installAppVersionRequest.AppName, + }, + }, + SourceAppType: bean3.SOURCE_HELM_APP, + } + if chartRepoInfo != nil { + updateReleaseRequest.ChartRepository = &bean4.ChartRepository{ + Name: chartRepoInfo.Name, + Url: chartRepoInfo.Url, + Username: chartRepoInfo.UserName, + Password: chartRepoInfo.Password, + } + } + res, err := impl.helmAppService.UpdateApplicationWithChartInfo(ctx, installAppVersionRequest.ClusterId, updateReleaseRequest) + if err != nil { + return nil, err + } + // STEP-2 ends + + // tx commit here because next operation will be process after this commit. + err = tx.Commit() + if err != nil { + return nil, err + } + // STEP-3 install app DB post operations + installAppVersionRequest.UpdateDeploymentAppType(util.PIPELINE_DEPLOYMENT_TYPE_HELM) + err = impl.appStoreDeploymentDBService.InstallAppPostDbOperation(installAppVersionRequest) + if err != nil { + return nil, err + } + // STEP-3 ends + + return res, nil +} diff --git a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 36b4ced1b9..ea16ef492f 100644 --- a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -66,7 +66,7 @@ func (impl *EAModeDeploymentServiceImpl) UpgradeDeployment(installAppVersionRequ } func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - installAppVersionRequest.DeploymentAppType = util.PIPELINE_DEPLOYMENT_TYPE_HELM + installAppVersionRequest.UpdateDeploymentAppType(util.PIPELINE_DEPLOYMENT_TYPE_HELM) appStoreAppVersion, err := impl.appStoreApplicationVersionRepository.FindById(installAppVersionRequest.AppStoreVersion) if err != nil { impl.Logger.Errorw("fetching error", "err", err) diff --git a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go index 8f61cdcc7f..b67e85b57a 100644 --- a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go +++ b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go @@ -19,6 +19,8 @@ package EAMode import ( "github.com/devtron-labs/devtron/pkg/appStore/adapter" + "github.com/devtron-labs/devtron/pkg/cluster" + "net/http" "strconv" "strings" "time" @@ -30,7 +32,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" + appStoreRepo "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/bean" util3 "github.com/devtron-labs/devtron/util" @@ -42,29 +44,35 @@ type InstalledAppDBService interface { GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) - CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) + GetInstalledAppById(installedAppId int) (*appStoreRepo.InstalledApps, error) GetInstalledAppByClusterNamespaceAndName(clusterId int, namespace string, appName string) (*appStoreBean.InstallAppVersionDTO, error) GetInstalledAppByInstalledAppId(installedAppId int) (*appStoreBean.InstallAppVersionDTO, error) + GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) + CreateInstalledAppVersion(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreRepo.InstalledAppVersions, error) + UpdateInstalledAppVersion(installedAppVersion *appStoreRepo.InstalledAppVersions, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreRepo.InstalledAppVersions, error) } type InstalledAppDBServiceImpl struct { Logger *zap.SugaredLogger - InstalledAppRepository repository2.InstalledAppRepository + InstalledAppRepository appStoreRepo.InstalledAppRepository AppRepository app.AppRepository UserService user.UserService - InstalledAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository + EnvironmentService cluster.EnvironmentService + InstalledAppRepositoryHistory appStoreRepo.InstalledAppVersionHistoryRepository } func NewInstalledAppDBServiceImpl(logger *zap.SugaredLogger, - installedAppRepository repository2.InstalledAppRepository, + installedAppRepository appStoreRepo.InstalledAppRepository, appRepository app.AppRepository, userService user.UserService, - installedAppRepositoryHistory repository2.InstalledAppVersionHistoryRepository) *InstalledAppDBServiceImpl { + environmentService cluster.EnvironmentService, + installedAppRepositoryHistory appStoreRepo.InstalledAppVersionHistoryRepository) *InstalledAppDBServiceImpl { return &InstalledAppDBServiceImpl{ Logger: logger, InstalledAppRepository: installedAppRepository, AppRepository: appRepository, UserService: userService, + EnvironmentService: environmentService, InstalledAppRepositoryHistory: installedAppRepositoryHistory, } } @@ -196,7 +204,7 @@ func (impl *InstalledAppDBServiceImpl) FindAppDetailsForAppstoreApplication(inst return appDetail, nil } -func (impl *InstalledAppDBServiceImpl) CheckAppExistsByInstalledAppId(installedAppId int) (*repository2.InstalledApps, error) { +func (impl *InstalledAppDBServiceImpl) GetInstalledAppById(installedAppId int) (*appStoreRepo.InstalledApps, error) { installedApp, err := impl.InstalledAppRepository.GetInstalledApp(installedAppId) if err != nil { return nil, err @@ -235,3 +243,62 @@ func (impl *InstalledAppDBServiceImpl) GetInstalledAppByInstalledAppId(installed installedApp := &installedAppVersion.InstalledApp return adapter.GenerateInstallAppVersionDTO(installedApp, installedAppVersion), nil } + +func (impl *InstalledAppDBServiceImpl) GetInstalledAppVersion(id int, userId int32) (*appStoreBean.InstallAppVersionDTO, error) { + model, err := impl.InstalledAppRepository.GetInstalledAppVersion(id) + if err != nil { + if util.IsErrNoRows(err) { + return nil, &util.ApiError{HttpStatusCode: http.StatusBadRequest, Code: "400", UserMessage: "values are outdated. please fetch the latest version and try again", InternalMessage: err.Error()} + } + impl.Logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + // update InstallAppVersion configurations + installAppVersion := &appStoreBean.InstallAppVersionDTO{ + Id: model.Id, + InstalledAppVersionId: model.Id, + ValuesOverrideYaml: model.ValuesYaml, + ReferenceValueKind: model.ReferenceValueKind, + ReferenceValueId: model.ReferenceValueId, + InstalledAppId: model.InstalledAppId, + AppStoreVersion: model.AppStoreApplicationVersionId, //check viki + UserId: userId, + } + + // update App configurations + adapter.UpdateAppDetails(installAppVersion, &model.InstalledApp.App) + + // update InstallApp configurations + adapter.UpdateInstallAppDetails(installAppVersion, &model.InstalledApp) + + // update AppStoreApplication configurations + adapter.UpdateAppStoreApplicationDetails(installAppVersion, &model.AppStoreApplicationVersion) + + environment, err := impl.EnvironmentService.GetExtendedEnvBeanById(installAppVersion.EnvironmentId) + if err != nil { + impl.Logger.Errorw("fetching environment error", "envId", installAppVersion.EnvironmentId, "err", err) + return nil, err + } + // update environment details configurations + adapter.UpdateAdditionalEnvDetails(installAppVersion, environment) + return installAppVersion, err +} + +func (impl *InstalledAppDBServiceImpl) CreateInstalledAppVersion(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreRepo.InstalledAppVersions, error) { + installedAppVersion := adapter.NewInstalledAppVersionModel(installAppVersionRequest) + _, err := impl.InstalledAppRepository.CreateInstalledAppVersion(installedAppVersion, tx) + if err != nil { + impl.Logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + return installedAppVersion, nil +} + +func (impl *InstalledAppDBServiceImpl) UpdateInstalledAppVersion(installedAppVersion *appStoreRepo.InstalledAppVersions, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreRepo.InstalledAppVersions, error) { + _, err := impl.InstalledAppRepository.UpdateInstalledAppVersion(installedAppVersion, tx) + if err != nil { + impl.Logger.Errorw("error while fetching from db", "error", err) + return nil, err + } + return installedAppVersion, nil +} diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go index 1b48cd3cad..1975a62037 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go @@ -77,10 +77,9 @@ func (impl *FullModeDeploymentServiceImpl) UpdateInstalledAppAndPipelineStatusFo impl.Logger.Errorw("error in getting installedAppVersionHistory by installedAppVersionHistoryId", "installedAppVersionHistoryId", installAppVersionRequest.InstalledAppVersionHistoryId, "err", err) return err } - installedAppVersionHistory.Status = pipelineConfig.WorkflowFailed + installedAppVersionHistory.SetStatus(pipelineConfig.WorkflowFailed) installedAppVersionHistory.FinishedOn = triggeredAt - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = installAppVersionRequest.UserId + installedAppVersionHistory.UpdateAuditLog(installAppVersionRequest.UserId) _, err = impl.installedAppRepositoryHistory.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) if err != nil { impl.Logger.Errorw("error updating installed app version history status", "err", err, "installedAppVersionHistory", installedAppVersionHistory) diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go index 02b098b425..a33ad1624d 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go @@ -10,7 +10,8 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" - repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" + cluster2 "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/go-pg/pg" "strings" @@ -157,23 +158,23 @@ func (impl *FullModeDeploymentServiceImpl) deleteACD(acdAppName string, ctx cont return nil } -func (impl *FullModeDeploymentServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, envModel repository5.Environment, argocdAppName string) error { +func (impl *FullModeDeploymentServiceImpl) createInArgo(chartGitAttribute *commonBean.ChartGitAttribute, envModel bean.EnvironmentBean, argocdAppName string) error { appNamespace := envModel.Namespace if appNamespace == "" { - appNamespace = "default" + appNamespace = cluster2.DEFAULT_NAMESPACE } - appreq := &argocdServer.AppTemplate{ + appReq := &argocdServer.AppTemplate{ ApplicationName: argocdAppName, Namespace: impl.aCDAuthConfig.ACDConfigMapNamespace, TargetNamespace: appNamespace, - TargetServer: envModel.Cluster.ServerUrl, + TargetServer: envModel.ClusterServerUrl, Project: "default", ValuesFile: fmt.Sprintf("values.yaml"), RepoPath: chartGitAttribute.ChartLocation, RepoUrl: chartGitAttribute.RepoUrl, AutoSyncEnabled: impl.acdConfig.ArgoCDAutoSyncEnabled, } - _, err := impl.argoK8sClient.CreateAcdApp(appreq, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) + _, err := impl.argoK8sClient.CreateAcdApp(appReq, argocdServer.ARGOCD_APPLICATION_TEMPLATE) //create if err != nil { impl.Logger.Errorw("error in creating argo cd app ", "err", err) diff --git a/pkg/cluster/ClusterService.go b/pkg/cluster/ClusterService.go index f803780dc3..f2bf4bd947 100644 --- a/pkg/cluster/ClusterService.go +++ b/pkg/cluster/ClusterService.go @@ -88,7 +88,6 @@ type ClusterBean struct { ErrorInConnecting string `json:"errorInConnecting"` IsCdArgoSetup bool `json:"isCdArgoSetup"` IsVirtualCluster bool `json:"isVirtualCluster"` - isClusterNameEmpty bool `json:"-"` ClusterUpdated bool `json:"clusterUpdated"` } diff --git a/pkg/cluster/EnvironmentService.go b/pkg/cluster/EnvironmentService.go index 8422ea4d04..d6ac799b66 100644 --- a/pkg/cluster/EnvironmentService.go +++ b/pkg/cluster/EnvironmentService.go @@ -20,6 +20,8 @@ package cluster import ( "encoding/json" "fmt" + "github.com/devtron-labs/devtron/pkg/cluster/adapter" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "strconv" "strings" "time" @@ -38,62 +40,29 @@ import ( "go.uber.org/zap" ) -type EnvironmentBean struct { - Id int `json:"id,omitempty" validate:"number"` - Environment string `json:"environment_name,omitempty" validate:"required,max=50"` - ClusterId int `json:"cluster_id,omitempty" validate:"number,required"` - ClusterName string `json:"cluster_name,omitempty"` - Active bool `json:"active"` - Default bool `json:"default"` - PrometheusEndpoint string `json:"prometheus_endpoint,omitempty"` - Namespace string `json:"namespace,omitempty" validate:"name-space-component,max=50"` - CdArgoSetup bool `json:"isClusterCdActive"` - EnvironmentIdentifier string `json:"environmentIdentifier"` - Description string `json:"description" validate:"max=40"` - AppCount int `json:"appCount"` - IsVirtualEnvironment bool `json:"isVirtualEnvironment"` - AllowedDeploymentTypes []string `json:"allowedDeploymentTypes"` - IsDigestEnforcedForEnv bool `json:"isDigestEnforcedForEnv"` -} - -type EnvDto struct { - EnvironmentId int `json:"environmentId" validate:"number"` - EnvironmentName string `json:"environmentName,omitempty" validate:"max=50"` - Namespace string `json:"namespace,omitempty" validate:"name-space-component,max=50"` - EnvironmentIdentifier string `json:"environmentIdentifier,omitempty"` - Description string `json:"description" validate:"max=40"` - IsVirtualEnvironment bool `json:"isVirtualEnvironment"` -} - -type ClusterEnvDto struct { - ClusterId int `json:"clusterId"` - ClusterName string `json:"clusterName,omitempty"` - Environments []*EnvDto `json:"environments,omitempty"` - IsVirtualCluster bool `json:"isVirtualCluster"` -} - -type ResourceGroupingResponse struct { - EnvList []EnvironmentBean `json:"envList"` - EnvCount int `json:"envCount"` -} - type EnvironmentService interface { - FindOne(environment string) (*EnvironmentBean, error) - Create(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error) - GetAll() ([]EnvironmentBean, error) - GetAllActive() ([]EnvironmentBean, error) - Delete(deleteReq *EnvironmentBean, userId int32) error - - FindById(id int) (*EnvironmentBean, error) - Update(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error) + FindOne(environment string) (*bean2.EnvironmentBean, error) + Create(mappings *bean2.EnvironmentBean, userId int32) (*bean2.EnvironmentBean, error) + Update(mappings *bean2.EnvironmentBean, userId int32) (*bean2.EnvironmentBean, error) + GetAll() ([]bean2.EnvironmentBean, error) + GetAllActive() ([]bean2.EnvironmentBean, error) + Delete(deleteReq *bean2.EnvironmentBean, userId int32) error FindClusterByEnvId(id int) (*ClusterBean, error) - GetEnvironmentListForAutocomplete(isDeploymentTypeParam bool) ([]EnvironmentBean, error) - GetEnvironmentOnlyListForAutocomplete() ([]EnvironmentBean, error) - FindByIds(ids []*int) ([]*EnvironmentBean, error) + // FindById provides an exposed struct of bean.EnvironmentBean; + // Usage - can be used for API responses; + FindById(id int) (*bean2.EnvironmentBean, error) + // GetExtendedEnvBeanById is used internally to get combined env and cluster data in bean.EnvironmentBean; + // Usage - used for intra-service communications only; + // For exposed view use FindById instead + GetExtendedEnvBeanById(id int) (*bean2.EnvironmentBean, error) + GetEnvironmentListForAutocomplete(isDeploymentTypeParam bool) ([]bean2.EnvironmentBean, error) + GetEnvironmentOnlyListForAutocomplete() ([]bean2.EnvironmentBean, error) + FindByIds(ids []*int) ([]*bean2.EnvironmentBean, error) FindByNamespaceAndClusterName(namespaces string, clusterName string) (*repository.Environment, error) - GetByClusterId(id int) ([]*EnvironmentBean, error) - GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(email string, object []string) map[string]bool) ([]*ClusterEnvDto, error) - GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*ClusterEnvDto, error) + FindOneByNamespaceAndClusterId(namespaces string, clusterId int) (*bean2.EnvironmentBean, error) + GetByClusterId(id int) ([]*bean2.EnvironmentBean, error) + GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(email string, object []string) map[string]bool) ([]*bean2.ClusterEnvDto, error) + GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*bean2.ClusterEnvDto, error) HandleErrorInClusterConnections(clusters []*ClusterBean, respMap map[int]error, clusterExistInDb bool) } @@ -125,7 +94,7 @@ func NewEnvironmentServiceImpl(environmentRepository repository.EnvironmentRepos } } -func (impl EnvironmentServiceImpl) Create(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) Create(mappings *bean2.EnvironmentBean, userId int32) (*bean2.EnvironmentBean, error) { existingEnvs, err := impl.environmentRepository.FindByClusterId(mappings.ClusterId) if err != nil && !util.IsErrNoRows(err) { impl.logger.Errorw("error while fetch", "err", err) @@ -190,16 +159,17 @@ func (impl EnvironmentServiceImpl) Create(mappings *EnvironmentBean, userId int3 } } mappings.Id = model.Id + mappings.ClusterServerUrl = clusterBean.ServerUrl return mappings, nil } -func (impl EnvironmentServiceImpl) FindOne(environment string) (*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) FindOne(environment string) (*bean2.EnvironmentBean, error) { model, err := impl.environmentRepository.FindOne(environment) if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) return nil, err } - bean := &EnvironmentBean{ + bean := &bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, ClusterId: model.Cluster.Id, @@ -213,14 +183,14 @@ func (impl EnvironmentServiceImpl) FindOne(environment string) (*EnvironmentBean return bean, nil } -func (impl EnvironmentServiceImpl) GetAll() ([]EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) GetAll() ([]bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindAll() if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []EnvironmentBean + var beans []bean2.EnvironmentBean for _, model := range models { - beans = append(beans, EnvironmentBean{ + beans = append(beans, bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, ClusterId: model.Cluster.Id, @@ -238,14 +208,14 @@ func (impl EnvironmentServiceImpl) GetAll() ([]EnvironmentBean, error) { return beans, nil } -func (impl EnvironmentServiceImpl) GetAllActive() ([]EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) GetAllActive() ([]bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindAllActive() if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []EnvironmentBean + var beans []bean2.EnvironmentBean for _, model := range models { - beans = append(beans, EnvironmentBean{ + beans = append(beans, bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, ClusterId: model.Cluster.Id, @@ -262,13 +232,13 @@ func (impl EnvironmentServiceImpl) GetAllActive() ([]EnvironmentBean, error) { return beans, nil } -func (impl EnvironmentServiceImpl) FindById(id int) (*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) FindById(id int) (*bean2.EnvironmentBean, error) { model, err := impl.environmentRepository.FindById(id) if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) return nil, err } - bean := &EnvironmentBean{ + bean := &bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, ClusterId: model.Cluster.Id, @@ -280,16 +250,10 @@ func (impl EnvironmentServiceImpl) FindById(id int) (*EnvironmentBean, error) { Description: model.Description, IsVirtualEnvironment: model.IsVirtualEnvironment, } - - /*clusterBean := &ClusterBean{ - id:model.Cluster.id, - ClusterName: model.Cluster.ClusterName, - Active:model.Cluster.Active, - }*/ return bean, nil } -func (impl EnvironmentServiceImpl) Update(mappings *EnvironmentBean, userId int32) (*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) Update(mappings *bean2.EnvironmentBean, userId int32) (*bean2.EnvironmentBean, error) { model, err := impl.environmentRepository.FindById(mappings.Id) if err != nil { impl.logger.Errorw("error in finding environment for update", "err", err) @@ -360,6 +324,15 @@ func (impl EnvironmentServiceImpl) Update(mappings *EnvironmentBean, userId int3 return mappings, nil } +func (impl EnvironmentServiceImpl) GetExtendedEnvBeanById(id int) (*bean2.EnvironmentBean, error) { + model, err := impl.environmentRepository.FindById(id) + if err != nil { + impl.logger.Errorw("error in fetch environment by id", "err", err) + return nil, err + } + return adapter.NewEnvironmentBean(model), nil +} + func (impl EnvironmentServiceImpl) FindClusterByEnvId(id int) (*ClusterBean, error) { model, err := impl.environmentRepository.FindById(id) if err != nil { @@ -375,19 +348,14 @@ func (impl EnvironmentServiceImpl) FindClusterByEnvId(id int) (*ClusterBean, err return clusterBean, nil } -const ( - PIPELINE_DEPLOYMENT_TYPE_HELM = "helm" - PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd" -) - -var permittedDeploymentConfigString = []string{PIPELINE_DEPLOYMENT_TYPE_HELM, PIPELINE_DEPLOYMENT_TYPE_ACD} +var permittedDeploymentConfigString = []string{bean2.PIPELINE_DEPLOYMENT_TYPE_HELM, bean2.PIPELINE_DEPLOYMENT_TYPE_ACD} -func (impl EnvironmentServiceImpl) GetEnvironmentListForAutocomplete(isDeploymentTypeParam bool) ([]EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) GetEnvironmentListForAutocomplete(isDeploymentTypeParam bool) ([]bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindAllActive() if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []EnvironmentBean + var beans []bean2.EnvironmentBean //Fetching deployment app type config values along with autocomplete api while creating CD pipeline if isDeploymentTypeParam { for _, model := range models { @@ -411,7 +379,7 @@ func (impl EnvironmentServiceImpl) GetEnvironmentListForAutocomplete(isDeploymen } else { allowedDeploymentConfigString = permittedDeploymentConfigString } - beans = append(beans, EnvironmentBean{ + beans = append(beans, bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, Namespace: model.Namespace, @@ -426,7 +394,7 @@ func (impl EnvironmentServiceImpl) GetEnvironmentListForAutocomplete(isDeploymen } } else { for _, model := range models { - beans = append(beans, EnvironmentBean{ + beans = append(beans, bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, Namespace: model.Namespace, @@ -466,14 +434,14 @@ func (impl EnvironmentServiceImpl) IsReceivedDeploymentTypeValid(deploymentConfi return true, filteredDeploymentConfig } -func (impl EnvironmentServiceImpl) GetEnvironmentOnlyListForAutocomplete() ([]EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) GetEnvironmentOnlyListForAutocomplete() ([]bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindAllActiveEnvOnlyDetails() if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []EnvironmentBean + var beans []bean2.EnvironmentBean for _, model := range models { - beans = append(beans, EnvironmentBean{ + beans = append(beans, bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, Namespace: model.Namespace, @@ -501,14 +469,14 @@ func (impl EnvironmentServiceImpl) validateNamespaces(namespace string, envs []* return nil } -func (impl EnvironmentServiceImpl) FindByIds(ids []*int) ([]*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) FindByIds(ids []*int) ([]*bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindByIds(ids) if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []*EnvironmentBean + var beans []*bean2.EnvironmentBean for _, model := range models { - beans = append(beans, &EnvironmentBean{ + beans = append(beans, &bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, Active: model.Active, @@ -528,14 +496,23 @@ func (impl EnvironmentServiceImpl) FindByNamespaceAndClusterName(namespaces stri return env, err } -func (impl EnvironmentServiceImpl) GetByClusterId(id int) ([]*EnvironmentBean, error) { +func (impl EnvironmentServiceImpl) FindOneByNamespaceAndClusterId(namespaces string, clusterId int) (*bean2.EnvironmentBean, error) { + env, err := impl.environmentRepository.FindOneByNamespaceAndClusterId(namespaces, clusterId) + if err != nil { + impl.logger.Errorw("error in getting environment by namespace and cluster id", "namespaces", namespaces, "clusterId", clusterId) + return nil, err + } + return adapter.NewEnvironmentBean(env), err +} + +func (impl EnvironmentServiceImpl) GetByClusterId(id int) ([]*bean2.EnvironmentBean, error) { models, err := impl.environmentRepository.FindByClusterId(id) if err != nil { impl.logger.Errorw("error in fetching environment", "err", err) } - var beans []*EnvironmentBean + var beans []*bean2.EnvironmentBean for _, model := range models { - beans = append(beans, &EnvironmentBean{ + beans = append(beans, &bean2.EnvironmentBean{ Id: model.Id, Environment: model.Name, Namespace: model.Namespace, @@ -546,8 +523,8 @@ func (impl EnvironmentServiceImpl) GetByClusterId(id int) ([]*EnvironmentBean, e return beans, nil } -func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(email string, object []string) map[string]bool) ([]*ClusterEnvDto, error) { - var namespaceGroupByClusterResponse []*ClusterEnvDto +func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token string, isActionUserSuperAdmin bool, auth func(email string, object []string) map[string]bool) ([]*bean2.ClusterEnvDto, error) { + var namespaceGroupByClusterResponse []*bean2.ClusterEnvDto clusterModels, err := impl.clusterService.FindAllActive() if err != nil { impl.logger.Errorw("error in fetching clusters", "err", err) @@ -570,7 +547,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token s rbacObjectResult := auth(token, rbacObject) uniqueComboMap := make(map[string]bool) - grantedEnvironmentMap := make(map[string][]*EnvDto) + grantedEnvironmentMap := make(map[string][]*bean2.EnvDto) for _, model := range models { // isActionUserSuperAdmin tell that user is super admin or not. auth check skip for admin if !isActionUserSuperAdmin { @@ -583,7 +560,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token s key := fmt.Sprintf("%s__%s", model.Cluster.ClusterName, model.Namespace) groupKey := fmt.Sprintf("%s__%d", model.Cluster.ClusterName, model.ClusterId) uniqueComboMap[key] = true - grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &EnvDto{ + grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &bean2.EnvDto{ EnvironmentId: model.Id, EnvironmentName: model.Name, Namespace: model.Namespace, @@ -619,7 +596,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token s continue } } - grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &EnvDto{ + grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &bean2.EnvDto{ EnvironmentName: environmentIdentifier, Namespace: namespace, EnvironmentIdentifier: environmentIdentifier, @@ -635,7 +612,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token s if err != nil { clusterId = 0 } - namespaceGroupByClusterResponse = append(namespaceGroupByClusterResponse, &ClusterEnvDto{ + namespaceGroupByClusterResponse = append(namespaceGroupByClusterResponse, &bean2.ClusterEnvDto{ ClusterName: clusterInfo[0], ClusterId: clusterId, Environments: v, @@ -644,8 +621,8 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDown(token s return namespaceGroupByClusterResponse, nil } -func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*ClusterEnvDto, error) { - var namespaceGroupByClusterResponse []*ClusterEnvDto +func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByClusterIds(token string, clusterIds []int, auth func(token string, object string) bool) ([]*bean2.ClusterEnvDto, error) { + var namespaceGroupByClusterResponse []*bean2.ClusterEnvDto clusterModels, err := impl.clusterService.FindByIds(clusterIds) if err != nil { impl.logger.Errorw("error in fetching clusters", "err", err) @@ -661,7 +638,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByCluste return namespaceGroupByClusterResponse, err } uniqueComboMap := make(map[string]bool) - grantedEnvironmentMap := make(map[string][]*EnvDto) + grantedEnvironmentMap := make(map[string][]*bean2.EnvDto) for _, model := range models { // auth enforcer applied here isValidAuth := auth(token, model.EnvironmentIdentifier) @@ -672,7 +649,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByCluste key := fmt.Sprintf("%s__%s", model.Cluster.ClusterName, model.Namespace) groupKey := fmt.Sprintf("%s__%d", model.Cluster.ClusterName, model.ClusterId) uniqueComboMap[key] = true - grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &EnvDto{ + grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &bean2.EnvDto{ EnvironmentId: model.Id, EnvironmentName: model.Name, Namespace: model.Namespace, @@ -699,7 +676,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByCluste impl.logger.Debugw("authentication for env failed", "object", environmentIdentifier) continue } - grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &EnvDto{ + grantedEnvironmentMap[groupKey] = append(grantedEnvironmentMap[groupKey], &bean2.EnvDto{ EnvironmentName: environmentIdentifier, Namespace: namespace, EnvironmentIdentifier: environmentIdentifier, @@ -715,7 +692,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByCluste if err != nil { clusterId = 0 } - namespaceGroupByClusterResponse = append(namespaceGroupByClusterResponse, &ClusterEnvDto{ + namespaceGroupByClusterResponse = append(namespaceGroupByClusterResponse, &bean2.ClusterEnvDto{ ClusterName: clusterInfo[0], ClusterId: clusterId, Environments: v, @@ -724,7 +701,7 @@ func (impl EnvironmentServiceImpl) GetCombinedEnvironmentListForDropDownByCluste return namespaceGroupByClusterResponse, nil } -func (impl EnvironmentServiceImpl) Delete(deleteReq *EnvironmentBean, userId int32) error { +func (impl EnvironmentServiceImpl) Delete(deleteReq *bean2.EnvironmentBean, userId int32) error { existingEnv, err := impl.environmentRepository.FindById(deleteReq.Id) if err != nil { impl.logger.Errorw("No matching entry found for delete.", "id", deleteReq.Id) diff --git a/pkg/cluster/adapter/Adapter.go b/pkg/cluster/adapter/Adapter.go new file mode 100644 index 0000000000..2d78d07a87 --- /dev/null +++ b/pkg/cluster/adapter/Adapter.go @@ -0,0 +1,31 @@ +package adapter + +import ( + "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" +) + +// NewEnvironmentBean provides a new cluster.EnvironmentBean for the given repository.Environment +// Note: NewEnvironmentBean doesn't include AppCount and AllowedDeploymentTypes +func NewEnvironmentBean(envModel *repository.Environment) *bean.EnvironmentBean { + envBean := &bean.EnvironmentBean{ + Id: envModel.Id, + Environment: envModel.Name, + ClusterId: envModel.ClusterId, + Active: envModel.Active, + Default: envModel.Default, + Namespace: envModel.Namespace, + EnvironmentIdentifier: envModel.EnvironmentIdentifier, + Description: envModel.Description, + IsVirtualEnvironment: envModel.IsVirtualEnvironment, + } + if envModel.Cluster != nil { + envBean.ClusterName = envModel.Cluster.ClusterName + envBean.PrometheusEndpoint = envModel.Cluster.PrometheusEndpoint + envBean.CdArgoSetup = envModel.Cluster.CdArgoSetup + // populate internal use only fields + envBean.ClusterServerUrl = envModel.Cluster.ServerUrl + envBean.ErrorInConnecting = envModel.Cluster.ErrorInConnecting + } + return envBean +} diff --git a/pkg/cluster/repository/bean/bean.go b/pkg/cluster/repository/bean/bean.go new file mode 100644 index 0000000000..39e298216f --- /dev/null +++ b/pkg/cluster/repository/bean/bean.go @@ -0,0 +1,46 @@ +package bean + +type EnvironmentBean struct { + Id int `json:"id,omitempty" validate:"number"` + Environment string `json:"environment_name,omitempty" validate:"required,max=50"` + ClusterId int `json:"cluster_id,omitempty" validate:"number,required"` + ClusterName string `json:"cluster_name,omitempty"` + Active bool `json:"active"` + Default bool `json:"default"` + PrometheusEndpoint string `json:"prometheus_endpoint,omitempty"` + Namespace string `json:"namespace,omitempty" validate:"name-space-component,max=50"` + CdArgoSetup bool `json:"isClusterCdActive"` + EnvironmentIdentifier string `json:"environmentIdentifier"` + Description string `json:"description" validate:"max=40"` + AppCount int `json:"appCount"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` + AllowedDeploymentTypes []string `json:"allowedDeploymentTypes"` + ClusterServerUrl string `json:"-"` + ErrorInConnecting string `json:"-"` +} + +type EnvDto struct { + EnvironmentId int `json:"environmentId" validate:"number"` + EnvironmentName string `json:"environmentName,omitempty" validate:"max=50"` + Namespace string `json:"namespace,omitempty" validate:"name-space-component,max=50"` + EnvironmentIdentifier string `json:"environmentIdentifier,omitempty"` + Description string `json:"description" validate:"max=40"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` +} + +type ClusterEnvDto struct { + ClusterId int `json:"clusterId"` + ClusterName string `json:"clusterName,omitempty"` + Environments []*EnvDto `json:"environments,omitempty"` + IsVirtualCluster bool `json:"isVirtualCluster"` +} + +type ResourceGroupingResponse struct { + EnvList []EnvironmentBean `json:"envList"` + EnvCount int `json:"envCount"` +} + +const ( + PIPELINE_DEPLOYMENT_TYPE_HELM = "helm" + PIPELINE_DEPLOYMENT_TYPE_ACD = "argo_cd" +) diff --git a/pkg/delete/DeleteService.go b/pkg/delete/DeleteService.go index 9c353f73e7..4e8ab5e1f3 100644 --- a/pkg/delete/DeleteService.go +++ b/pkg/delete/DeleteService.go @@ -6,6 +6,7 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/team" @@ -15,7 +16,7 @@ import ( type DeleteService interface { DeleteCluster(deleteRequest *cluster.ClusterBean, userId int32) error - DeleteEnvironment(deleteRequest *cluster.EnvironmentBean, userId int32) error + DeleteEnvironment(deleteRequest *bean.EnvironmentBean, userId int32) error DeleteTeam(deleteRequest *team.TeamRequest) error DeleteChartRepo(deleteRequest *chartRepo.ChartRepoDto) error DeleteDockerRegistryConfig(deleteRequest *types.DockerArtifactStoreBean) error @@ -63,7 +64,7 @@ func (impl DeleteServiceImpl) DeleteCluster(deleteRequest *cluster.ClusterBean, return nil } -func (impl DeleteServiceImpl) DeleteEnvironment(deleteRequest *cluster.EnvironmentBean, userId int32) error { +func (impl DeleteServiceImpl) DeleteEnvironment(deleteRequest *bean.EnvironmentBean, userId int32) error { err := impl.environmentService.Delete(deleteRequest, userId) if err != nil { impl.logger.Errorw("error in deleting environment", "err", err, "deleteRequest", deleteRequest) diff --git a/pkg/delete/DeleteServiceExtended.go b/pkg/delete/DeleteServiceExtended.go index 8f6c302c56..fa78edc654 100644 --- a/pkg/delete/DeleteServiceExtended.go +++ b/pkg/delete/DeleteServiceExtended.go @@ -10,6 +10,7 @@ import ( "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/cluster/repository" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/team" "github.com/go-pg/pg" @@ -71,7 +72,7 @@ func (impl DeleteServiceExtendedImpl) DeleteCluster(deleteRequest *cluster.Clust return nil } -func (impl DeleteServiceExtendedImpl) DeleteEnvironment(deleteRequest *cluster.EnvironmentBean, userId int32) error { +func (impl DeleteServiceExtendedImpl) DeleteEnvironment(deleteRequest *bean.EnvironmentBean, userId int32) error { //finding if this env is used in any cd pipelines, if yes then will not delete pipelines, err := impl.pipelineRepository.FindActiveByEnvId(deleteRequest.Id) if err != nil && err != pg.ErrNoRows { diff --git a/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go index 720dae4eb5..bcd5522a35 100644 --- a/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go +++ b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go @@ -9,8 +9,8 @@ import ( ) type DeploymentTypeOverrideService interface { - // SetAndValidateDeploymentAppType : Set deployment application (helm/argo) types based on the enforcement configurations - SetAndValidateDeploymentAppType(deploymentType *string, isGitOpsConfigured bool, environmentId int) error + // ValidateAndOverrideDeploymentAppType : Set deployment application (helm/argo) types based on the enforcement configurations + ValidateAndOverrideDeploymentAppType(deploymentType string, isGitOpsConfigured bool, environmentId int) (overrideDeploymentType string, err error) } type DeploymentTypeOverrideServiceImpl struct { @@ -29,12 +29,14 @@ func NewDeploymentTypeOverrideServiceImpl(logger *zap.SugaredLogger, } } -func (impl *DeploymentTypeOverrideServiceImpl) SetAndValidateDeploymentAppType(deploymentType *string, isGitOpsConfigured bool, environmentId int) error { +func (impl *DeploymentTypeOverrideServiceImpl) ValidateAndOverrideDeploymentAppType(deploymentType string, isGitOpsConfigured bool, environmentId int) (overrideDeploymentType string, err error) { + // initialise OverrideDeploymentType to the given DeploymentType + overrideDeploymentType = deploymentType // if no deployment app type sent from user then we'll not validate deploymentTypeValidationConfig, err := impl.attributesService.GetDeploymentEnforcementConfig(environmentId) if err != nil { impl.logger.Errorw("error in getting enforcement config for deployment", "err", err) - return err + return overrideDeploymentType, err } // by default both deployment app type are allowed AllowedDeploymentAppTypes := map[string]bool{ @@ -47,32 +49,32 @@ func (impl *DeploymentTypeOverrideServiceImpl) SetAndValidateDeploymentAppType(d } if !impl.deploymentConfig.ExternallyManagedDeploymentType { if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_ACD] { - *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD + overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD } else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] { - *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM + overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM } } - if *deploymentType == "" { + if deploymentType == "" { if isGitOpsConfigured && AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_ACD] { - *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD + overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_ACD } else if AllowedDeploymentAppTypes[util2.PIPELINE_DEPLOYMENT_TYPE_HELM] { - *deploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM + overrideDeploymentType = util2.PIPELINE_DEPLOYMENT_TYPE_HELM } } - if err := impl.validateDeploymentAppType(*deploymentType, deploymentTypeValidationConfig); err != nil { - impl.logger.Errorw("validation error for the given deployment type", "deploymentType", *deploymentType, "err", err) - return err + if err = impl.validateDeploymentAppType(overrideDeploymentType, deploymentTypeValidationConfig); err != nil { + impl.logger.Errorw("validation error for the given deployment type", "deploymentType", deploymentType, "err", err) + return overrideDeploymentType, err } - if !isGitOpsConfigured && util2.IsAcdApp(*deploymentType) { + if !isGitOpsConfigured && util2.IsAcdApp(overrideDeploymentType) { impl.logger.Errorw("GitOps not configured but selected as a deployment app type") err = &util2.ApiError{ HttpStatusCode: http.StatusBadRequest, InternalMessage: "GitOps integration is not installed/configured. Please install/configure GitOps or use helm option.", UserMessage: "GitOps integration is not installed/configured. Please install/configure GitOps or use helm option.", } - return err + return overrideDeploymentType, err } - return nil + return overrideDeploymentType, nil } func (impl *DeploymentTypeOverrideServiceImpl) validateDeploymentAppType(deploymentType string, deploymentConfig map[string]bool) error { diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 5c133b9007..c3c95f1779 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -536,10 +536,9 @@ func (impl *CdHandlerImpl) UpdatePipelineTimelineAndStatusByLiveApplicationFetch if isSucceeded { // handling deployment success event // updating cdWfr status - installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - installedAppVersionHistory.FinishedOn = time.Now() - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = 1 + installedAppVersionHistory.SetStatus(pipelineConfig.WorkflowSucceeded) + installedAppVersionHistory.SetFinishedOn() + installedAppVersionHistory.UpdateAuditLog(1) installedAppVersionHistory, err = impl.installedAppVersionHistoryRepository.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) if err != nil { impl.Logger.Errorw("error on update installedAppVersionHistory", "installedAppVersionHistory", installedAppVersionHistory, "err", err) diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 83ca9c4b7a..54bed48156 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -39,8 +39,8 @@ import ( "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" - "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" + bean4 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" @@ -111,7 +111,7 @@ type CdPipelineConfigService interface { IsGitOpsRequiredForCD(pipelineCreateRequest *bean.CdPipelines) bool MarkGitOpsDevtronAppsDeletedWhereArgoAppIsDeleted(appId int, envId int, acdToken string, pipeline *pipelineConfig.Pipeline) (bool, error) //GetEnvironmentListForAutocompleteFilter : lists environment for given configuration - GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*cluster.ResourceGroupingResponse, error) + GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*bean4.ResourceGroupingResponse, error) RegisterInACD(gitOpsRepoName string, chartGitAttr *commonBean.ChartGitAttribute, userId int32, ctx context.Context) error } @@ -366,11 +366,12 @@ func (impl *CdPipelineConfigServiceImpl) CreateCdPipelines(pipelineCreateRequest if pipeline.EnvironmentId <= 0 { continue } - err = impl.deploymentTypeOverrideService.SetAndValidateDeploymentAppType(&pipeline.DeploymentAppType, isGitOpsConfigured, pipeline.EnvironmentId) + overrideDeploymentType, err := impl.deploymentTypeOverrideService.ValidateAndOverrideDeploymentAppType(pipeline.DeploymentAppType, isGitOpsConfigured, pipeline.EnvironmentId) if err != nil { impl.logger.Errorw("validation error in creating pipeline", "name", pipeline.Name, "err", err) return nil, err } + pipeline.DeploymentAppType = overrideDeploymentType } isGitOpsRequiredForCD := impl.IsGitOpsRequiredForCD(pipelineCreateRequest) @@ -1399,10 +1400,10 @@ func (impl *CdPipelineConfigServiceImpl) MarkGitOpsDevtronAppsDeletedWhereArgoAp return acdAppFound, nil } -func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*cluster.ResourceGroupingResponse, error) { - result := &cluster.ResourceGroupingResponse{} +func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset int, size int, token string, checkAuthBatch func(token string, appObject []string, envObject []string) (map[string]bool, map[string]bool), ctx context.Context) (*bean4.ResourceGroupingResponse, error) { + result := &bean4.ResourceGroupingResponse{} var models []*repository2.Environment - var beans []cluster.EnvironmentBean + var beans []bean4.EnvironmentBean var err error if len(envName) > 0 && len(clusterIds) > 0 { models, err = impl.environmentRepository.FindByEnvNameAndClusterIds(envName, clusterIds) @@ -1466,7 +1467,7 @@ func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter pipelinesMap[pipeline.EnvironmentId] = append(pipelinesMap[pipeline.EnvironmentId], pipeline) } for _, model := range models { - environment := cluster.EnvironmentBean{ + environment := bean4.EnvironmentBean{ Id: model.Id, Environment: model.Name, Namespace: model.Namespace, diff --git a/pkg/pipeline/WorkflowDagExecutor.go b/pkg/pipeline/WorkflowDagExecutor.go index 501834298b..bc19fede8f 100644 --- a/pkg/pipeline/WorkflowDagExecutor.go +++ b/pkg/pipeline/WorkflowDagExecutor.go @@ -3646,7 +3646,7 @@ func (impl *WorkflowDagExecutorImpl) createArgoApplicationIfRequired(appId int, RepoUrl: chart.GitRepoUrl, AutoSyncEnabled: impl.ACDConfig.ArgoCDAutoSyncEnabled, } - argoAppName, err := impl.argoK8sClient.CreateAcdApp(appRequest, envModel.Cluster, argocdServer.ARGOCD_APPLICATION_TEMPLATE) + argoAppName, err := impl.argoK8sClient.CreateAcdApp(appRequest, argocdServer.ARGOCD_APPLICATION_TEMPLATE) if err != nil { return "", err } diff --git a/pkg/pipeline/mock_pipeline/PipelineBuilder.go b/pkg/pipeline/mock_pipeline/PipelineBuilder.go index bf1b03d03f..dd2acc9732 100644 --- a/pkg/pipeline/mock_pipeline/PipelineBuilder.go +++ b/pkg/pipeline/mock_pipeline/PipelineBuilder.go @@ -6,13 +6,13 @@ package mock_pipeline import ( context "context" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" reflect "reflect" bean "github.com/devtron-labs/devtron/api/bean" helper "github.com/devtron-labs/devtron/internal/sql/repository/helper" pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" bean0 "github.com/devtron-labs/devtron/pkg/bean" - cluster "github.com/devtron-labs/devtron/pkg/cluster" pipeline "github.com/devtron-labs/devtron/pkg/pipeline" appGroup "github.com/devtron-labs/devtron/pkg/resourceGroup" gomock "github.com/golang/mock/gomock" @@ -623,10 +623,10 @@ func (mr *MockPipelineBuilderMockRecorder) GetEnvironmentByCdPipelineId(pipeline } // GetEnvironmentListForAutocompleteFilter mocks base method. -func (m *MockPipelineBuilder) GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset, size int, emailId string, checkAuthBatch func(string, []string, []string) (map[string]bool, map[string]bool), ctx context.Context) (*cluster.ResourceGroupingResponse, error) { +func (m *MockPipelineBuilder) GetEnvironmentListForAutocompleteFilter(envName string, clusterIds []int, offset, size int, emailId string, checkAuthBatch func(string, []string, []string) (map[string]bool, map[string]bool), ctx context.Context) (*bean2.ResourceGroupingResponse, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetEnvironmentListForAutocompleteFilter", envName, clusterIds, offset, size, emailId, checkAuthBatch, ctx) - ret0, _ := ret[0].(*cluster.ResourceGroupingResponse) + ret0, _ := ret[0].(*bean2.ResourceGroupingResponse) ret1, _ := ret[1].(error) return ret0, ret1 } diff --git a/pkg/security/ImageScanService.go b/pkg/security/ImageScanService.go index e8d027e5f1..6cf31f40a3 100644 --- a/pkg/security/ImageScanService.go +++ b/pkg/security/ImageScanService.go @@ -18,6 +18,7 @@ package security import ( + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "time" repository1 "github.com/devtron-labs/devtron/internal/sql/repository/app" @@ -569,7 +570,7 @@ func (impl ImageScanServiceImpl) VulnerabilityExposure(request *security.Vulnera return nil, err } - envMap := make(map[int]cluster.EnvironmentBean) + envMap := make(map[int]bean.EnvironmentBean) environments, err := impl.envService.GetAllActive() if err != nil { impl.Logger.Errorw("error while fetching vulnerability exposure", "err", err) diff --git a/wire_gen.go b/wire_gen.go index 10503f0d59..e9deb37e2a 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -601,12 +601,13 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } + installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, environmentServiceImpl, installedAppVersionHistoryRepositoryImpl) + appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImplExtended, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) chartGroupDeploymentRepositoryImpl := repository15.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) - clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, clusterInstalledAppsRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, clusterServiceImplExtended, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl) applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl, userRepositoryQueryBuilder) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) @@ -628,12 +629,12 @@ func InitializeApp() (*App, error) { chartGroupEntriesRepositoryImpl := repository15.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository15.NewChartGroupReposotoryImpl(db, sugaredLogger) appStoreVersionValuesRepositoryImpl := appStoreValuesRepository.NewAppStoreVersionValuesRepositoryImpl(sugaredLogger, db) + clusterInstalledAppsRepositoryImpl := repository3.NewClusterInstalledAppsRepositoryImpl(db, sugaredLogger) appStoreValuesServiceImpl := service3.NewAppStoreValuesServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userServiceImpl) - chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentRepositoryImpl, teamRepositoryImpl, clusterInstalledAppsRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, environmentServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl) + chartGroupServiceImpl, err := chartGroup.NewChartGroupServiceImpl(sugaredLogger, chartGroupEntriesRepositoryImpl, chartGroupReposotoryImpl, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, appStoreVersionValuesRepositoryImpl, userAuthServiceImpl, appStoreApplicationVersionRepositoryImpl, environmentServiceImpl, teamRepositoryImpl, clusterInstalledAppsRepositoryImpl, appStoreValuesServiceImpl, pubSubClientServiceImpl, appStoreDeploymentServiceImpl, argoUserServiceImpl, pipelineStatusTimelineServiceImpl, acdConfig, fullModeDeploymentServiceImpl, gitOperationServiceImpl, installedAppDBExtendedServiceImpl) if err != nil { return nil, err } - installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, installedAppVersionHistoryRepositoryImpl) cdApplicationStatusUpdateHandlerImpl := cron2.NewCdApplicationStatusUpdateHandlerImpl(sugaredLogger, appServiceImpl, workflowDagExecutorImpl, installedAppDBServiceImpl, cdHandlerImpl, appServiceConfig, pubSubClientServiceImpl, pipelineStatusTimelineRepositoryImpl, eventRESTClientImpl, appListingRepositoryImpl, cdWorkflowRepositoryImpl, pipelineRepositoryImpl, installedAppVersionHistoryRepositoryImpl, installedAppRepositoryImpl, cronLoggerImpl) installedAppRestHandlerImpl := appStore.NewInstalledAppRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, chartGroupServiceImpl, validate, clusterServiceImplExtended, applicationServiceClientImpl, appStoreDeploymentServiceImpl, helmAppClientImpl, argoUserServiceImpl, cdApplicationStatusUpdateHandlerImpl, installedAppRepositoryImpl, appCrudOperationServiceImpl) appStoreValuesRestHandlerImpl := appStoreValues.NewAppStoreValuesRestHandlerImpl(sugaredLogger, userServiceImpl, appStoreValuesServiceImpl) @@ -643,7 +644,7 @@ func InitializeApp() (*App, error) { appStoreDiscoverRouterImpl := appStoreDiscover.NewAppStoreDiscoverRouterImpl(appStoreRestHandlerImpl) chartProviderRestHandlerImpl := chartProvider2.NewChartProviderRestHandlerImpl(sugaredLogger, userServiceImpl, validate, chartProviderServiceImpl, enforcerImpl) chartProviderRouterImpl := chartProvider2.NewChartProviderRouterImpl(chartProviderRestHandlerImpl) - appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, appStoreDeploymentCommonServiceImpl, argoUserServiceImpl, attributesServiceImpl) + appStoreDeploymentRestHandlerImpl := appStoreDeployment.NewAppStoreDeploymentRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, enforcerUtilImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, validate, helmAppServiceImpl, argoUserServiceImpl, attributesServiceImpl, installedAppDBServiceImpl) appStoreDeploymentRouterImpl := appStoreDeployment.NewAppStoreDeploymentRouterImpl(appStoreDeploymentRestHandlerImpl) appStoreStatusTimelineRestHandlerImpl := appStore.NewAppStoreStatusTimelineRestHandlerImpl(sugaredLogger, pipelineStatusTimelineServiceImpl, enforcerUtilImpl, enforcerImpl) appStoreRouterImpl := appStore.NewAppStoreRouterImpl(installedAppRestHandlerImpl, appStoreValuesRouterImpl, appStoreDiscoverRouterImpl, chartProviderRouterImpl, appStoreDeploymentRouterImpl, appStoreStatusTimelineRestHandlerImpl) From 111e389aee5c4b3610278c533b795f11b0930270 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 12 Feb 2024 10:48:56 +0530 Subject: [PATCH 58/83] fix: install apps audit logs --- .../installedApp/service/AppStoreDeploymentService.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 4bd34957dd..6b5bbefe54 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -693,9 +693,8 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex } } } - installedApp.Status = appStoreBean.DEPLOY_SUCCESS - installedApp.UpdatedOn = time.Now() - installedAppVersion.UpdatedBy = installAppVersionRequest.UserId + installedApp.UpdateStatus(appStoreBean.DEPLOY_SUCCESS) + installedApp.UpdateAuditLog(installAppVersionRequest.UserId) installedApp, err = impl.installedAppRepository.UpdateInstalledApp(installedApp, tx) if err != nil { impl.logger.Errorw("error in updating installed app", "err", err) From b23b6da5baf5eb7eaf420029297d6530a0e87ca8 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Tue, 13 Feb 2024 12:47:52 +0530 Subject: [PATCH 59/83] chore: update env name usgae --- pkg/appStore/adapter/Adapter.go | 1 + pkg/appStore/bean/bean.go | 4 ++-- pkg/appStore/chartGroup/ChartGroupService.go | 2 +- pkg/appStore/installedApp/adapter/Adapter.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go index bd62a16bda..e3a49dc680 100644 --- a/pkg/appStore/adapter/Adapter.go +++ b/pkg/appStore/adapter/Adapter.go @@ -196,6 +196,7 @@ func UpdateAdditionalEnvDetails(request *appStoreBean.InstallAppVersionDTO, envB return } request.Environment = envBean + request.EnvironmentName = envBean.Environment request.ClusterId = envBean.ClusterId request.Namespace = envBean.Namespace request.UpdateACDAppName() diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index c85c0bfb55..860726a1b1 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -112,10 +112,10 @@ func (chart *InstallAppVersionDTO) UpdateDeploymentAppType(deploymentAppType str // UpdateACDAppName updates ArgoCd app object name to InstallAppVersionDTO func (chart *InstallAppVersionDTO) UpdateACDAppName() { - if chart == nil || chart.Environment == nil { + if chart == nil { return } - chart.ACDAppName = fmt.Sprintf("%s-%s", chart.AppName, chart.Environment.Environment) + chart.ACDAppName = fmt.Sprintf("%s-%s", chart.AppName, chart.EnvironmentName) } // InstalledAppDeploymentAction is an internal struct for Helm App deployment; used to decide the deployment steps to be performed diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index 1099f1917e..b20de96cd4 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -1081,7 +1081,7 @@ func (impl *ChartGroupServiceImpl) performDeployStageOnAcd(installedAppVersion * impl.logger.Errorw("error, GetRepoUrlByRepoName", "err", err) } chartGitAttr.RepoUrl = repoUrl - chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.Environment.Environment) + chartGitAttr.ChartLocation = fmt.Sprintf("%s-%s", installedAppVersion.AppName, installedAppVersion.EnvironmentName) } if installedAppVersion.Status == appStoreBean.DEPLOY_INIT || diff --git a/pkg/appStore/installedApp/adapter/Adapter.go b/pkg/appStore/installedApp/adapter/Adapter.go index b11f6b2964..c14505699b 100644 --- a/pkg/appStore/installedApp/adapter/Adapter.go +++ b/pkg/appStore/installedApp/adapter/Adapter.go @@ -11,7 +11,7 @@ import ( func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersionDTO, repoURl string, tempRefChart string) *bean.PushChartToGitRequestDTO { return &bean.PushChartToGitRequestDTO{ AppName: installAppRequestDTO.AppName, - EnvName: installAppRequestDTO.Environment.Environment, + EnvName: installAppRequestDTO.EnvironmentName, ChartAppStoreName: installAppRequestDTO.AppStoreName, RepoURL: repoURl, TempChartRefDir: tempRefChart, From ffc740cd4e42272ca2a35f1e9b1e4a645e27323d Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Mon, 26 Feb 2024 18:02:50 +0530 Subject: [PATCH 60/83] CommonWireSet made --- Wire.go | 930 +------------------------------- authWire.go | 5 +- commonWireset/commonWireset.go | 936 +++++++++++++++++++++++++++++++++ 3 files changed, 939 insertions(+), 932 deletions(-) create mode 100644 commonWireset/commonWireset.go diff --git a/Wire.go b/Wire.go index b79240efc2..7391db1584 100644 --- a/Wire.go +++ b/Wire.go @@ -21,143 +21,11 @@ package main import ( - "github.com/devtron-labs/authenticator/middleware" cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" - util4 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/api/apiToken" - appStoreRestHandler "github.com/devtron-labs/devtron/api/appStore" - chartGroup2 "github.com/devtron-labs/devtron/api/appStore/chartGroup" - chartProvider "github.com/devtron-labs/devtron/api/appStore/chartProvider" - appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" - appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover" - appStoreValues "github.com/devtron-labs/devtron/api/appStore/values" - "github.com/devtron-labs/devtron/api/argoApplication" - "github.com/devtron-labs/devtron/api/auth/sso" - "github.com/devtron-labs/devtron/api/auth/user" - chartRepo "github.com/devtron-labs/devtron/api/chartRepo" - "github.com/devtron-labs/devtron/api/cluster" - "github.com/devtron-labs/devtron/api/connector" - "github.com/devtron-labs/devtron/api/dashboardEvent" - "github.com/devtron-labs/devtron/api/deployment" - "github.com/devtron-labs/devtron/api/externalLink" - client "github.com/devtron-labs/devtron/api/helm-app" - "github.com/devtron-labs/devtron/api/infraConfig" - "github.com/devtron-labs/devtron/api/k8s" - "github.com/devtron-labs/devtron/api/module" - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" - appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" - pipeline3 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline" - pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" - "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history" - status2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status" - "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger" - "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook" - "github.com/devtron-labs/devtron/api/restHandler/app/workflow" - "github.com/devtron-labs/devtron/api/restHandler/scopedVariable" - "github.com/devtron-labs/devtron/api/router" - app3 "github.com/devtron-labs/devtron/api/router/app" - appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" - "github.com/devtron-labs/devtron/api/router/app/appList" - pipeline5 "github.com/devtron-labs/devtron/api/router/app/pipeline" - pipeline4 "github.com/devtron-labs/devtron/api/router/app/pipeline/configure" - history2 "github.com/devtron-labs/devtron/api/router/app/pipeline/history" - status3 "github.com/devtron-labs/devtron/api/router/app/pipeline/status" - trigger2 "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger" - workflow2 "github.com/devtron-labs/devtron/api/router/app/workflow" - "github.com/devtron-labs/devtron/api/router/pubsub" - "github.com/devtron-labs/devtron/api/server" - "github.com/devtron-labs/devtron/api/sse" - "github.com/devtron-labs/devtron/api/team" - "github.com/devtron-labs/devtron/api/terminal" - util5 "github.com/devtron-labs/devtron/api/util" - webhookHelm "github.com/devtron-labs/devtron/api/webhook/helm" - "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/client/argocdServer/application" - cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster" - "github.com/devtron-labs/devtron/client/argocdServer/connection" - repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository" - session2 "github.com/devtron-labs/devtron/client/argocdServer/session" - "github.com/devtron-labs/devtron/client/cron" - "github.com/devtron-labs/devtron/client/dashboard" - eClient "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/client/grafana" - "github.com/devtron-labs/devtron/client/lens" - "github.com/devtron-labs/devtron/client/proxy" - "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internal/sql/repository" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" - security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/commonWireset" "github.com/devtron-labs/devtron/internal/util" - "github.com/devtron-labs/devtron/pkg/app" - "github.com/devtron-labs/devtron/pkg/app/status" - "github.com/devtron-labs/devtron/pkg/appClone" - "github.com/devtron-labs/devtron/pkg/appClone/batch" - "github.com/devtron-labs/devtron/pkg/appStatus" - "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" - deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" - "github.com/devtron-labs/devtron/pkg/appWorkflow" - "github.com/devtron-labs/devtron/pkg/attributes" - "github.com/devtron-labs/devtron/pkg/build" - "github.com/devtron-labs/devtron/pkg/bulkAction" - "github.com/devtron-labs/devtron/pkg/chart" - chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" - "github.com/devtron-labs/devtron/pkg/commonService" - delete2 "github.com/devtron-labs/devtron/pkg/delete" - deployment2 "github.com/devtron-labs/devtron/pkg/deployment" - git2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" - "github.com/devtron-labs/devtron/pkg/deploymentGroup" - "github.com/devtron-labs/devtron/pkg/devtronResource" - repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" - "github.com/devtron-labs/devtron/pkg/dockerRegistry" - "github.com/devtron-labs/devtron/pkg/eventProcessor" - "github.com/devtron-labs/devtron/pkg/generateManifest" - "github.com/devtron-labs/devtron/pkg/git" - "github.com/devtron-labs/devtron/pkg/gitops" - "github.com/devtron-labs/devtron/pkg/imageDigestPolicy" - infraConfigService "github.com/devtron-labs/devtron/pkg/infraConfig" - "github.com/devtron-labs/devtron/pkg/infraConfig/units" - "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" - "github.com/devtron-labs/devtron/pkg/notifier" - "github.com/devtron-labs/devtron/pkg/pipeline" - "github.com/devtron-labs/devtron/pkg/pipeline/executors" - history3 "github.com/devtron-labs/devtron/pkg/pipeline/history" - repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" - "github.com/devtron-labs/devtron/pkg/pipeline/infraProviders" - 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" - resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" - "github.com/devtron-labs/devtron/pkg/resourceQualifiers" - "github.com/devtron-labs/devtron/pkg/security" "github.com/devtron-labs/devtron/pkg/sql" - util3 "github.com/devtron-labs/devtron/pkg/util" - "github.com/devtron-labs/devtron/pkg/variables" - "github.com/devtron-labs/devtron/pkg/variables/parsers" - repository10 "github.com/devtron-labs/devtron/pkg/variables/repository" - workflow3 "github.com/devtron-labs/devtron/pkg/workflow" - "github.com/devtron-labs/devtron/pkg/workflow/dag" - util2 "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/util/argo" - cron2 "github.com/devtron-labs/devtron/util/cron" - "github.com/devtron-labs/devtron/util/rbac" "github.com/google/wire" ) @@ -166,809 +34,15 @@ func InitializeApp() (*App, error) { wire.Build( // ----- wireset start sql.PgSqlWireSet, - user.SelfRegistrationWireSet, - externalLink.ExternalLinkWireSet, - team.TeamsWireSet, AuthWireSet, - util4.NewK8sUtil, - user.UserWireSet, - sso.SsoConfigWireSet, - cluster.ClusterWireSet, - dashboard.DashboardWireSet, - proxy.ProxyWireSet, - client.HelmAppWireSet, - k8s.K8sApplicationWireSet, - chartRepo.ChartRepositoryWireSet, - appStoreDiscover.AppStoreDiscoverWireSet, - chartProvider.AppStoreChartProviderWireSet, - appStoreValues.AppStoreValuesWireSet, - util2.GetEnvironmentVariables, - appStoreDeployment.AppStoreDeploymentWireSet, - server.ServerWireSet, - module.ModuleWireSet, - apiToken.ApiTokenWireSet, - webhookHelm.WebhookHelmWireSet, - terminal.TerminalWireSet, - build.BuildWireSet, - deployment2.DeploymentWireSet, - argoApplication.ArgoApplicationWireSet, - - eventProcessor.EventProcessorWireSet, - workflow3.WorkflowWireSet, - // -------wireset end ---------- - // ------- - gitSensor.GetConfig, - gitSensor.NewGitSensorClient, - wire.Bind(new(gitSensor.Client), new(*gitSensor.ClientImpl)), - // ------- - helper.NewAppListingRepositoryQueryBuilder, - // sql.GetConfig, - eClient.GetEventClientConfig, - // sql.NewDbConnection, - // app.GetACDAuthConfig, - util3.GetACDAuthConfig, - connection.SettingsManager, - // auth.GetConfig, - - connection.GetConfig, - wire.Bind(new(session2.ServiceClient), new(*middleware.LoginService)), - - sse.NewSSE, - trigger2.NewPipelineTriggerRouter, - wire.Bind(new(trigger2.PipelineTriggerRouter), new(*trigger2.PipelineTriggerRouterImpl)), - - // ---- pprof start ---- - restHandler.NewPProfRestHandler, - wire.Bind(new(restHandler.PProfRestHandler), new(*restHandler.PProfRestHandlerImpl)), - - router.NewPProfRouter, - wire.Bind(new(router.PProfRouter), new(*router.PProfRouterImpl)), - // ---- pprof end ---- - - trigger.NewPipelineRestHandler, - wire.Bind(new(trigger.PipelineTriggerRestHandler), new(*trigger.PipelineTriggerRestHandlerImpl)), - app.GetAppServiceConfig, - app.NewAppService, - wire.Bind(new(app.AppService), new(*app.AppServiceImpl)), - - bulkUpdate.NewBulkUpdateRepository, - wire.Bind(new(bulkUpdate.BulkUpdateRepository), new(*bulkUpdate.BulkUpdateRepositoryImpl)), - - chartConfig.NewEnvConfigOverrideRepository, - wire.Bind(new(chartConfig.EnvConfigOverrideRepository), new(*chartConfig.EnvConfigOverrideRepositoryImpl)), - chartConfig.NewPipelineOverrideRepository, - wire.Bind(new(chartConfig.PipelineOverrideRepository), new(*chartConfig.PipelineOverrideRepositoryImpl)), - wire.Struct(new(util.MergeUtil), "*"), util.NewSugardLogger, - - deployment.NewDeploymentConfigRestHandlerImpl, - wire.Bind(new(deployment.DeploymentConfigRestHandler), new(*deployment.DeploymentConfigRestHandlerImpl)), - deployment.NewDeploymentRouterImpl, - wire.Bind(new(deployment.DeploymentConfigRouter), new(*deployment.DeploymentConfigRouterImpl)), - - dashboardEvent.NewDashboardTelemetryRestHandlerImpl, - wire.Bind(new(dashboardEvent.DashboardTelemetryRestHandler), new(*dashboardEvent.DashboardTelemetryRestHandlerImpl)), - dashboardEvent.NewDashboardTelemetryRouterImpl, - wire.Bind(new(dashboardEvent.DashboardTelemetryRouter), - new(*dashboardEvent.DashboardTelemetryRouterImpl)), - - infraConfigService.NewInfraProfileRepositoryImpl, - wire.Bind(new(infraConfigService.InfraConfigRepository), new(*infraConfigService.InfraConfigRepositoryImpl)), - - units.NewUnits, - infraConfigService.NewInfraConfigServiceImpl, - wire.Bind(new(infraConfigService.InfraConfigService), new(*infraConfigService.InfraConfigServiceImpl)), - infraProviders.NewInfraProviderImpl, - wire.Bind(new(infraProviders.InfraProvider), new(*infraProviders.InfraProviderImpl)), - infraConfig.NewInfraConfigRestHandlerImpl, - wire.Bind(new(infraConfig.InfraConfigRestHandler), new(*infraConfig.InfraConfigRestHandlerImpl)), - - infraConfig.NewInfraProfileRouterImpl, - wire.Bind(new(infraConfig.InfraConfigRouter), new(*infraConfig.InfraConfigRouterImpl)), - - router.NewMuxRouter, - - app2.NewAppRepositoryImpl, - wire.Bind(new(app2.AppRepository), new(*app2.AppRepositoryImpl)), - - //util2.GetEnvironmentVariables, - - pipeline.NewPipelineBuilderImpl, - wire.Bind(new(pipeline.PipelineBuilder), new(*pipeline.PipelineBuilderImpl)), - pipeline.NewBuildPipelineSwitchServiceImpl, - wire.Bind(new(pipeline.BuildPipelineSwitchService), new(*pipeline.BuildPipelineSwitchServiceImpl)), - pipeline.NewCiPipelineConfigServiceImpl, - wire.Bind(new(pipeline.CiPipelineConfigService), new(*pipeline.CiPipelineConfigServiceImpl)), - pipeline.NewCiMaterialConfigServiceImpl, - wire.Bind(new(pipeline.CiMaterialConfigService), new(*pipeline.CiMaterialConfigServiceImpl)), - - pipeline.NewAppArtifactManagerImpl, - wire.Bind(new(pipeline.AppArtifactManager), new(*pipeline.AppArtifactManagerImpl)), - pipeline.NewDevtronAppCMCSServiceImpl, - wire.Bind(new(pipeline.DevtronAppCMCSService), new(*pipeline.DevtronAppCMCSServiceImpl)), - pipeline.NewDevtronAppStrategyServiceImpl, - wire.Bind(new(pipeline.DevtronAppStrategyService), new(*pipeline.DevtronAppStrategyServiceImpl)), - pipeline.NewAppDeploymentTypeChangeManagerImpl, - wire.Bind(new(pipeline.AppDeploymentTypeChangeManager), new(*pipeline.AppDeploymentTypeChangeManagerImpl)), - pipeline.NewCdPipelineConfigServiceImpl, - wire.Bind(new(pipeline.CdPipelineConfigService), new(*pipeline.CdPipelineConfigServiceImpl)), - pipeline.NewDevtronAppConfigServiceImpl, - wire.Bind(new(pipeline.DevtronAppConfigService), new(*pipeline.DevtronAppConfigServiceImpl)), - pipeline3.NewDevtronAppAutoCompleteRestHandlerImpl, - wire.Bind(new(pipeline3.DevtronAppAutoCompleteRestHandler), new(*pipeline3.DevtronAppAutoCompleteRestHandlerImpl)), - - util5.NewLoggingMiddlewareImpl, - wire.Bind(new(util5.LoggingMiddleware), new(*util5.LoggingMiddlewareImpl)), - pipeline2.NewPipelineRestHandlerImpl, - wire.Bind(new(pipeline2.PipelineConfigRestHandler), new(*pipeline2.PipelineConfigRestHandlerImpl)), - - pipeline4.NewPipelineRouterImpl, - wire.Bind(new(pipeline4.PipelineConfigRouter), new(*pipeline4.PipelineConfigRouterImpl)), - history2.NewPipelineHistoryRouterImpl, - wire.Bind(new(history2.PipelineHistoryRouter), new(*history2.PipelineHistoryRouterImpl)), - status3.NewPipelineStatusRouterImpl, - wire.Bind(new(status3.PipelineStatusRouter), new(*status3.PipelineStatusRouterImpl)), - pipeline5.NewDevtronAppAutoCompleteRouterImpl, - wire.Bind(new(pipeline5.DevtronAppAutoCompleteRouter), new(*pipeline5.DevtronAppAutoCompleteRouterImpl)), - workflow2.NewAppWorkflowRouterImpl, - wire.Bind(new(workflow2.AppWorkflowRouter), new(*workflow2.AppWorkflowRouterImpl)), - - pipeline.NewCiCdPipelineOrchestrator, - wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)), - pipelineConfig.NewMaterialRepositoryImpl, - wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), - - util.NewChartTemplateServiceImpl, - wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), - - // scoped variables start - variables.NewScopedVariableServiceImpl, - wire.Bind(new(variables.ScopedVariableService), new(*variables.ScopedVariableServiceImpl)), - - parsers.NewVariableTemplateParserImpl, - wire.Bind(new(parsers.VariableTemplateParser), new(*parsers.VariableTemplateParserImpl)), - repository10.NewVariableEntityMappingRepository, - wire.Bind(new(repository10.VariableEntityMappingRepository), new(*repository10.VariableEntityMappingRepositoryImpl)), - - repository10.NewVariableSnapshotHistoryRepository, - wire.Bind(new(repository10.VariableSnapshotHistoryRepository), new(*repository10.VariableSnapshotHistoryRepositoryImpl)), - variables.NewVariableEntityMappingServiceImpl, - wire.Bind(new(variables.VariableEntityMappingService), new(*variables.VariableEntityMappingServiceImpl)), - variables.NewVariableSnapshotHistoryServiceImpl, - wire.Bind(new(variables.VariableSnapshotHistoryService), new(*variables.VariableSnapshotHistoryServiceImpl)), - - variables.NewScopedVariableManagerImpl, - wire.Bind(new(variables.ScopedVariableManager), new(*variables.ScopedVariableManagerImpl)), - - variables.NewScopedVariableCMCSManagerImpl, - wire.Bind(new(variables.ScopedVariableCMCSManager), new(*variables.ScopedVariableCMCSManagerImpl)), - - // end - - chart.NewChartServiceImpl, - wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)), - bulkAction.NewBulkUpdateServiceImpl, - wire.Bind(new(bulkAction.BulkUpdateService), new(*bulkAction.BulkUpdateServiceImpl)), - - repository.NewImageTagRepository, - wire.Bind(new(repository.ImageTagRepository), new(*repository.ImageTagRepositoryImpl)), - - pipeline.NewCustomTagService, - wire.Bind(new(pipeline.CustomTagService), new(*pipeline.CustomTagServiceImpl)), - - repository.NewGitProviderRepositoryImpl, - wire.Bind(new(repository.GitProviderRepository), new(*repository.GitProviderRepositoryImpl)), - pipeline.NewGitRegistryConfigImpl, - wire.Bind(new(pipeline.GitRegistryConfig), new(*pipeline.GitRegistryConfigImpl)), - - appList.NewAppFilteringRouterImpl, - wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), - appList2.NewAppFilteringRestHandlerImpl, - wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), - - appList.NewAppListingRouterImpl, - wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)), - appList2.NewAppListingRestHandlerImpl, - wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)), - app.NewAppListingServiceImpl, - wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)), - repository.NewAppListingRepositoryImpl, - wire.Bind(new(repository.AppListingRepository), new(*repository.AppListingRepositoryImpl)), - - repository.NewDeploymentTemplateRepositoryImpl, - wire.Bind(new(repository.DeploymentTemplateRepository), new(*repository.DeploymentTemplateRepositoryImpl)), - generateManifest.NewDeploymentTemplateServiceImpl, - wire.Bind(new(generateManifest.DeploymentTemplateService), new(*generateManifest.DeploymentTemplateServiceImpl)), - - router.NewJobRouterImpl, - wire.Bind(new(router.JobRouter), new(*router.JobRouterImpl)), - - pipelineConfig.NewPipelineRepositoryImpl, - wire.Bind(new(pipelineConfig.PipelineRepository), new(*pipelineConfig.PipelineRepositoryImpl)), - pipeline.NewPropertiesConfigServiceImpl, - wire.Bind(new(pipeline.PropertiesConfigService), new(*pipeline.PropertiesConfigServiceImpl)), - util.NewHttpClient, - - eClient.NewEventRESTClientImpl, - wire.Bind(new(eClient.EventClient), new(*eClient.EventRESTClientImpl)), - - eClient.NewEventSimpleFactoryImpl, - wire.Bind(new(eClient.EventFactory), new(*eClient.EventSimpleFactoryImpl)), - - repository.NewCiArtifactRepositoryImpl, - wire.Bind(new(repository.CiArtifactRepository), new(*repository.CiArtifactRepositoryImpl)), - pipeline.NewWebhookServiceImpl, - wire.Bind(new(pipeline.WebhookService), new(*pipeline.WebhookServiceImpl)), - - router.NewWebhookRouterImpl, - wire.Bind(new(router.WebhookRouter), new(*router.WebhookRouterImpl)), - pipelineConfig.NewCiTemplateRepositoryImpl, - wire.Bind(new(pipelineConfig.CiTemplateRepository), new(*pipelineConfig.CiTemplateRepositoryImpl)), - pipelineConfig.NewCiPipelineRepositoryImpl, - wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), - pipelineConfig.NewCiPipelineMaterialRepositoryImpl, - wire.Bind(new(pipelineConfig.CiPipelineMaterialRepository), new(*pipelineConfig.CiPipelineMaterialRepositoryImpl)), - git2.NewGitFactory, - - application.NewApplicationClientImpl, - wire.Bind(new(application.ServiceClient), new(*application.ServiceClientImpl)), - cluster2.NewServiceClientImpl, - wire.Bind(new(cluster2.ServiceClient), new(*cluster2.ServiceClientImpl)), - connector.NewPumpImpl, - repository2.NewServiceClientImpl, - wire.Bind(new(repository2.ServiceClient), new(*repository2.ServiceClientImpl)), - wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), - - //app.GetConfig, - - pipeline.GetEcrConfig, - // otel.NewOtelTracingServiceImpl, - // wire.Bind(new(otel.OtelTracingService), new(*otel.OtelTracingServiceImpl)), NewApp, - // session.NewK8sClient, - repository8.NewImageTaggingRepositoryImpl, - wire.Bind(new(repository8.ImageTaggingRepository), new(*repository8.ImageTaggingRepositoryImpl)), - pipeline.NewImageTaggingServiceImpl, - wire.Bind(new(pipeline.ImageTaggingService), new(*pipeline.ImageTaggingServiceImpl)), - argocdServer.NewVersionServiceImpl, - wire.Bind(new(argocdServer.VersionService), new(*argocdServer.VersionServiceImpl)), - - router.NewGitProviderRouterImpl, - wire.Bind(new(router.GitProviderRouter), new(*router.GitProviderRouterImpl)), - restHandler.NewGitProviderRestHandlerImpl, - wire.Bind(new(restHandler.GitProviderRestHandler), new(*restHandler.GitProviderRestHandlerImpl)), - - router.NewNotificationRouterImpl, - wire.Bind(new(router.NotificationRouter), new(*router.NotificationRouterImpl)), - restHandler.NewNotificationRestHandlerImpl, - wire.Bind(new(restHandler.NotificationRestHandler), new(*restHandler.NotificationRestHandlerImpl)), - - notifier.NewSlackNotificationServiceImpl, - wire.Bind(new(notifier.SlackNotificationService), new(*notifier.SlackNotificationServiceImpl)), - repository.NewSlackNotificationRepositoryImpl, - wire.Bind(new(repository.SlackNotificationRepository), new(*repository.SlackNotificationRepositoryImpl)), - notifier.NewWebhookNotificationServiceImpl, - wire.Bind(new(notifier.WebhookNotificationService), new(*notifier.WebhookNotificationServiceImpl)), - repository.NewWebhookNotificationRepositoryImpl, - wire.Bind(new(repository.WebhookNotificationRepository), new(*repository.WebhookNotificationRepositoryImpl)), - - notifier.NewNotificationConfigServiceImpl, - wire.Bind(new(notifier.NotificationConfigService), new(*notifier.NotificationConfigServiceImpl)), - app.NewAppListingViewBuilderImpl, - wire.Bind(new(app.AppListingViewBuilder), new(*app.AppListingViewBuilderImpl)), - repository.NewNotificationSettingsRepositoryImpl, - wire.Bind(new(repository.NotificationSettingsRepository), new(*repository.NotificationSettingsRepositoryImpl)), util.IntValidator, - types.GetCiCdConfig, - - pipeline.NewWorkflowServiceImpl, - wire.Bind(new(pipeline.WorkflowService), new(*pipeline.WorkflowServiceImpl)), - - pipeline.NewCiServiceImpl, - wire.Bind(new(pipeline.CiService), new(*pipeline.CiServiceImpl)), - - pipelineConfig.NewCiWorkflowRepositoryImpl, - wire.Bind(new(pipelineConfig.CiWorkflowRepository), new(*pipelineConfig.CiWorkflowRepositoryImpl)), - - restHandler.NewGitWebhookRestHandlerImpl, - wire.Bind(new(restHandler.GitWebhookRestHandler), new(*restHandler.GitWebhookRestHandlerImpl)), - - git.NewGitWebhookServiceImpl, - wire.Bind(new(git.GitWebhookService), new(*git.GitWebhookServiceImpl)), - - repository.NewGitWebhookRepositoryImpl, - wire.Bind(new(repository.GitWebhookRepository), new(*repository.GitWebhookRepositoryImpl)), - - pipeline.NewCiHandlerImpl, - wire.Bind(new(pipeline.CiHandler), new(*pipeline.CiHandlerImpl)), - - pipeline.NewCiLogServiceImpl, - wire.Bind(new(pipeline.CiLogService), new(*pipeline.CiLogServiceImpl)), - pubsub1.NewPubSubClientServiceImpl, - - pubsub.NewGitWebhookHandler, - wire.Bind(new(pubsub.GitWebhookHandler), new(*pubsub.GitWebhookHandlerImpl)), - - pubsub.NewApplicationStatusHandlerImpl, - wire.Bind(new(pubsub.ApplicationStatusHandler), new(*pubsub.ApplicationStatusHandlerImpl)), - - rbac.NewEnforcerUtilImpl, - wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), - - chartConfig.NewPipelineConfigRepository, - wire.Bind(new(chartConfig.PipelineConfigRepository), new(*chartConfig.PipelineConfigRepositoryImpl)), - - repository10.NewScopedVariableRepository, - wire.Bind(new(repository10.ScopedVariableRepository), new(*repository10.ScopedVariableRepositoryImpl)), - - repository.NewLinkoutsRepositoryImpl, - wire.Bind(new(repository.LinkoutsRepository), new(*repository.LinkoutsRepositoryImpl)), - - router.NewChartRefRouterImpl, - wire.Bind(new(router.ChartRefRouter), new(*router.ChartRefRouterImpl)), - restHandler.NewChartRefRestHandlerImpl, - wire.Bind(new(restHandler.ChartRefRestHandler), new(*restHandler.ChartRefRestHandlerImpl)), - - router.NewConfigMapRouterImpl, - wire.Bind(new(router.ConfigMapRouter), new(*router.ConfigMapRouterImpl)), - restHandler.NewConfigMapRestHandlerImpl, - wire.Bind(new(restHandler.ConfigMapRestHandler), new(*restHandler.ConfigMapRestHandlerImpl)), - pipeline.NewConfigMapServiceImpl, - wire.Bind(new(pipeline.ConfigMapService), new(*pipeline.ConfigMapServiceImpl)), - chartConfig.NewConfigMapRepositoryImpl, - wire.Bind(new(chartConfig.ConfigMapRepository), new(*chartConfig.ConfigMapRepositoryImpl)), - - notifier.NewSESNotificationServiceImpl, - wire.Bind(new(notifier.SESNotificationService), new(*notifier.SESNotificationServiceImpl)), - - repository.NewSESNotificationRepositoryImpl, - wire.Bind(new(repository.SESNotificationRepository), new(*repository.SESNotificationRepositoryImpl)), - - notifier.NewSMTPNotificationServiceImpl, - wire.Bind(new(notifier.SMTPNotificationService), new(*notifier.SMTPNotificationServiceImpl)), - - repository.NewSMTPNotificationRepositoryImpl, - wire.Bind(new(repository.SMTPNotificationRepository), new(*repository.SMTPNotificationRepositoryImpl)), - - notifier.NewNotificationConfigBuilderImpl, - wire.Bind(new(notifier.NotificationConfigBuilder), new(*notifier.NotificationConfigBuilderImpl)), - appStoreRestHandler.NewAppStoreStatusTimelineRestHandlerImpl, - wire.Bind(new(appStoreRestHandler.AppStoreStatusTimelineRestHandler), new(*appStoreRestHandler.AppStoreStatusTimelineRestHandlerImpl)), - appStoreRestHandler.NewInstalledAppRestHandlerImpl, - wire.Bind(new(appStoreRestHandler.InstalledAppRestHandler), new(*appStoreRestHandler.InstalledAppRestHandlerImpl)), - FullMode.NewInstalledAppDBExtendedServiceImpl, - wire.Bind(new(FullMode.InstalledAppDBExtendedService), new(*FullMode.InstalledAppDBExtendedServiceImpl)), - resource.NewInstalledAppResourceServiceImpl, - wire.Bind(new(resource.InstalledAppResourceService), new(*resource.InstalledAppResourceServiceImpl)), - deploymentTypeChange.NewInstalledAppDeploymentTypeChangeServiceImpl, - wire.Bind(new(deploymentTypeChange.InstalledAppDeploymentTypeChangeService), new(*deploymentTypeChange.InstalledAppDeploymentTypeChangeServiceImpl)), - - appStoreRestHandler.NewAppStoreRouterImpl, - wire.Bind(new(appStoreRestHandler.AppStoreRouter), new(*appStoreRestHandler.AppStoreRouterImpl)), - - workflow.NewAppWorkflowRestHandlerImpl, - wire.Bind(new(workflow.AppWorkflowRestHandler), new(*workflow.AppWorkflowRestHandlerImpl)), - - appWorkflow.NewAppWorkflowServiceImpl, - wire.Bind(new(appWorkflow.AppWorkflowService), new(*appWorkflow.AppWorkflowServiceImpl)), - - appWorkflow2.NewAppWorkflowRepositoryImpl, - wire.Bind(new(appWorkflow2.AppWorkflowRepository), new(*appWorkflow2.AppWorkflowRepositoryImpl)), - - restHandler.NewExternalCiRestHandlerImpl, - wire.Bind(new(restHandler.ExternalCiRestHandler), new(*restHandler.ExternalCiRestHandlerImpl)), - - grafana.GetGrafanaClientConfig, - grafana.NewGrafanaClientImpl, - wire.Bind(new(grafana.GrafanaClient), new(*grafana.GrafanaClientImpl)), - - app.NewReleaseDataServiceImpl, - wire.Bind(new(app.ReleaseDataService), new(*app.ReleaseDataServiceImpl)), - restHandler.NewReleaseMetricsRestHandlerImpl, - wire.Bind(new(restHandler.ReleaseMetricsRestHandler), new(*restHandler.ReleaseMetricsRestHandlerImpl)), - router.NewReleaseMetricsRouterImpl, - wire.Bind(new(router.ReleaseMetricsRouter), new(*router.ReleaseMetricsRouterImpl)), - lens.GetLensConfig, - lens.NewLensClientImpl, - wire.Bind(new(lens.LensClient), new(*lens.LensClientImpl)), - - pipelineConfig.NewCdWorkflowRepositoryImpl, - wire.Bind(new(pipelineConfig.CdWorkflowRepository), new(*pipelineConfig.CdWorkflowRepositoryImpl)), - - pipeline.NewCdHandlerImpl, - wire.Bind(new(pipeline.CdHandler), new(*pipeline.CdHandlerImpl)), - - pipeline.NewBlobStorageConfigServiceImpl, - wire.Bind(new(pipeline.BlobStorageConfigService), new(*pipeline.BlobStorageConfigServiceImpl)), - - dag.NewWorkflowDagExecutorImpl, - wire.Bind(new(dag.WorkflowDagExecutor), new(*dag.WorkflowDagExecutorImpl)), - appClone.NewAppCloneServiceImpl, - wire.Bind(new(appClone.AppCloneService), new(*appClone.AppCloneServiceImpl)), - - router.NewDeploymentGroupRouterImpl, - wire.Bind(new(router.DeploymentGroupRouter), new(*router.DeploymentGroupRouterImpl)), - restHandler.NewDeploymentGroupRestHandlerImpl, - wire.Bind(new(restHandler.DeploymentGroupRestHandler), new(*restHandler.DeploymentGroupRestHandlerImpl)), - deploymentGroup.NewDeploymentGroupServiceImpl, - wire.Bind(new(deploymentGroup.DeploymentGroupService), new(*deploymentGroup.DeploymentGroupServiceImpl)), - repository.NewDeploymentGroupRepositoryImpl, - wire.Bind(new(repository.DeploymentGroupRepository), new(*repository.DeploymentGroupRepositoryImpl)), - - repository.NewDeploymentGroupAppRepositoryImpl, - wire.Bind(new(repository.DeploymentGroupAppRepository), new(*repository.DeploymentGroupAppRepositoryImpl)), - restHandler.NewPubSubClientRestHandlerImpl, - wire.Bind(new(restHandler.PubSubClientRestHandler), new(*restHandler.PubSubClientRestHandlerImpl)), - - // Batch actions - batch.NewWorkflowActionImpl, - wire.Bind(new(batch.WorkflowAction), new(*batch.WorkflowActionImpl)), - batch.NewDeploymentActionImpl, - wire.Bind(new(batch.DeploymentAction), new(*batch.DeploymentActionImpl)), - batch.NewBuildActionImpl, - wire.Bind(new(batch.BuildAction), new(*batch.BuildActionImpl)), - batch.NewDataHolderActionImpl, - wire.Bind(new(batch.DataHolderAction), new(*batch.DataHolderActionImpl)), - batch.NewDeploymentTemplateActionImpl, - wire.Bind(new(batch.DeploymentTemplateAction), new(*batch.DeploymentTemplateActionImpl)), - restHandler.NewBatchOperationRestHandlerImpl, - wire.Bind(new(restHandler.BatchOperationRestHandler), new(*restHandler.BatchOperationRestHandlerImpl)), - router.NewBatchOperationRouterImpl, - wire.Bind(new(router.BatchOperationRouter), new(*router.BatchOperationRouterImpl)), - - repository4.NewChartGroupReposotoryImpl, - wire.Bind(new(repository4.ChartGroupReposotory), new(*repository4.ChartGroupReposotoryImpl)), - repository4.NewChartGroupEntriesRepositoryImpl, - wire.Bind(new(repository4.ChartGroupEntriesRepository), new(*repository4.ChartGroupEntriesRepositoryImpl)), - chartGroup.NewChartGroupServiceImpl, - wire.Bind(new(chartGroup.ChartGroupService), new(*chartGroup.ChartGroupServiceImpl)), - chartGroup2.NewChartGroupRestHandlerImpl, - wire.Bind(new(chartGroup2.ChartGroupRestHandler), new(*chartGroup2.ChartGroupRestHandlerImpl)), - chartGroup2.NewChartGroupRouterImpl, - wire.Bind(new(chartGroup2.ChartGroupRouter), new(*chartGroup2.ChartGroupRouterImpl)), - repository4.NewChartGroupDeploymentRepositoryImpl, - wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)), - - commonService.NewCommonServiceImpl, - wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)), - - router.NewImageScanRouterImpl, - wire.Bind(new(router.ImageScanRouter), new(*router.ImageScanRouterImpl)), - restHandler.NewImageScanRestHandlerImpl, - wire.Bind(new(restHandler.ImageScanRestHandler), new(*restHandler.ImageScanRestHandlerImpl)), - security.NewImageScanServiceImpl, - wire.Bind(new(security.ImageScanService), new(*security.ImageScanServiceImpl)), - security2.NewImageScanHistoryRepositoryImpl, - wire.Bind(new(security2.ImageScanHistoryRepository), new(*security2.ImageScanHistoryRepositoryImpl)), - security2.NewImageScanResultRepositoryImpl, - wire.Bind(new(security2.ImageScanResultRepository), new(*security2.ImageScanResultRepositoryImpl)), - security2.NewImageScanObjectMetaRepositoryImpl, - wire.Bind(new(security2.ImageScanObjectMetaRepository), new(*security2.ImageScanObjectMetaRepositoryImpl)), - security2.NewCveStoreRepositoryImpl, - wire.Bind(new(security2.CveStoreRepository), new(*security2.CveStoreRepositoryImpl)), - security2.NewImageScanDeployInfoRepositoryImpl, - wire.Bind(new(security2.ImageScanDeployInfoRepository), new(*security2.ImageScanDeployInfoRepositoryImpl)), - security2.NewScanToolMetadataRepositoryImpl, - wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), - router.NewPolicyRouterImpl, - wire.Bind(new(router.PolicyRouter), new(*router.PolicyRouterImpl)), - restHandler.NewPolicyRestHandlerImpl, - wire.Bind(new(restHandler.PolicyRestHandler), new(*restHandler.PolicyRestHandlerImpl)), - security.NewPolicyServiceImpl, - wire.Bind(new(security.PolicyService), new(*security.PolicyServiceImpl)), - security2.NewPolicyRepositoryImpl, - wire.Bind(new(security2.CvePolicyRepository), new(*security2.CvePolicyRepositoryImpl)), - security2.NewScanToolExecutionHistoryMappingRepositoryImpl, - wire.Bind(new(security2.ScanToolExecutionHistoryMappingRepository), new(*security2.ScanToolExecutionHistoryMappingRepositoryImpl)), - - argocdServer.NewArgoK8sClientImpl, - wire.Bind(new(argocdServer.ArgoK8sClient), new(*argocdServer.ArgoK8sClientImpl)), - - grafana.GetConfig, - router.NewGrafanaRouterImpl, - wire.Bind(new(router.GrafanaRouter), new(*router.GrafanaRouterImpl)), - - router.NewGitOpsConfigRouterImpl, - wire.Bind(new(router.GitOpsConfigRouter), new(*router.GitOpsConfigRouterImpl)), - restHandler.NewGitOpsConfigRestHandlerImpl, - wire.Bind(new(restHandler.GitOpsConfigRestHandler), new(*restHandler.GitOpsConfigRestHandlerImpl)), - gitops.NewGitOpsConfigServiceImpl, - wire.Bind(new(gitops.GitOpsConfigService), new(*gitops.GitOpsConfigServiceImpl)), - - router.NewAttributesRouterImpl, - wire.Bind(new(router.AttributesRouter), new(*router.AttributesRouterImpl)), - restHandler.NewAttributesRestHandlerImpl, - wire.Bind(new(restHandler.AttributesRestHandler), new(*restHandler.AttributesRestHandlerImpl)), - attributes.NewAttributesServiceImpl, - wire.Bind(new(attributes.AttributesService), new(*attributes.AttributesServiceImpl)), - repository.NewAttributesRepositoryImpl, - wire.Bind(new(repository.AttributesRepository), new(*repository.AttributesRepositoryImpl)), - - router.NewCommonRouterImpl, - wire.Bind(new(router.CommonRouter), new(*router.CommonRouterImpl)), - restHandler.NewCommonRestHanlderImpl, - wire.Bind(new(restHandler.CommonRestHanlder), new(*restHandler.CommonRestHanlderImpl)), - - router.NewScopedVariableRouterImpl, - wire.Bind(new(router.ScopedVariableRouter), new(*router.ScopedVariableRouterImpl)), - scopedVariable.NewScopedVariableRestHandlerImpl, - wire.Bind(new(scopedVariable.ScopedVariableRestHandler), new(*scopedVariable.ScopedVariableRestHandlerImpl)), - - router.NewTelemetryRouterImpl, - wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), - restHandler.NewTelemetryRestHandlerImpl, - wire.Bind(new(restHandler.TelemetryRestHandler), new(*restHandler.TelemetryRestHandlerImpl)), - telemetry.NewPosthogClient, - cloudProviderIdentifier.NewProviderIdentifierServiceImpl, wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)), - - telemetry.NewTelemetryEventClientImplExtended, - wire.Bind(new(telemetry.TelemetryEventClient), new(*telemetry.TelemetryEventClientImplExtended)), - - router.NewBulkUpdateRouterImpl, - wire.Bind(new(router.BulkUpdateRouter), new(*router.BulkUpdateRouterImpl)), - restHandler.NewBulkUpdateRestHandlerImpl, - wire.Bind(new(restHandler.BulkUpdateRestHandler), new(*restHandler.BulkUpdateRestHandlerImpl)), - - router.NewCoreAppRouterImpl, - wire.Bind(new(router.CoreAppRouter), new(*router.CoreAppRouterImpl)), - restHandler.NewCoreAppRestHandlerImpl, - wire.Bind(new(restHandler.CoreAppRestHandler), new(*restHandler.CoreAppRestHandlerImpl)), - - // Webhook - repository.NewGitHostRepositoryImpl, - wire.Bind(new(repository.GitHostRepository), new(*repository.GitHostRepositoryImpl)), - restHandler.NewGitHostRestHandlerImpl, - wire.Bind(new(restHandler.GitHostRestHandler), new(*restHandler.GitHostRestHandlerImpl)), - restHandler.NewWebhookEventHandlerImpl, - wire.Bind(new(restHandler.WebhookEventHandler), new(*restHandler.WebhookEventHandlerImpl)), - router.NewGitHostRouterImpl, - wire.Bind(new(router.GitHostRouter), new(*router.GitHostRouterImpl)), - router.NewWebhookListenerRouterImpl, - wire.Bind(new(router.WebhookListenerRouter), new(*router.WebhookListenerRouterImpl)), - git.NewWebhookSecretValidatorImpl, - wire.Bind(new(git.WebhookSecretValidator), new(*git.WebhookSecretValidatorImpl)), - pipeline.NewGitHostConfigImpl, - wire.Bind(new(pipeline.GitHostConfig), new(*pipeline.GitHostConfigImpl)), - repository.NewWebhookEventDataRepositoryImpl, - wire.Bind(new(repository.WebhookEventDataRepository), new(*repository.WebhookEventDataRepositoryImpl)), - pipeline.NewWebhookEventDataConfigImpl, - wire.Bind(new(pipeline.WebhookEventDataConfig), new(*pipeline.WebhookEventDataConfigImpl)), - webhook.NewWebhookDataRestHandlerImpl, - wire.Bind(new(webhook.WebhookDataRestHandler), new(*webhook.WebhookDataRestHandlerImpl)), - - app3.NewAppRouterImpl, - wire.Bind(new(app3.AppRouter), new(*app3.AppRouterImpl)), - appInfo2.NewAppInfoRouterImpl, - wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), - appInfo.NewAppInfoRestHandlerImpl, - wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), - - app.NewAppCrudOperationServiceImpl, - wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), - pipelineConfig.NewAppLabelRepositoryImpl, - wire.Bind(new(pipelineConfig.AppLabelRepository), new(*pipelineConfig.AppLabelRepositoryImpl)), - - delete2.NewDeleteServiceExtendedImpl, - wire.Bind(new(delete2.DeleteService), new(*delete2.DeleteServiceExtendedImpl)), - delete2.NewDeleteServiceFullModeImpl, - wire.Bind(new(delete2.DeleteServiceFullMode), new(*delete2.DeleteServiceFullModeImpl)), - - deployment3.NewFullModeDeploymentServiceImpl, - wire.Bind(new(deployment3.FullModeDeploymentService), new(*deployment3.FullModeDeploymentServiceImpl)), - // util2.NewGoJsonSchemaCustomFormatChecker, - - //history starts - history.NewPipelineHistoryRestHandlerImpl, - wire.Bind(new(history.PipelineHistoryRestHandler), new(*history.PipelineHistoryRestHandlerImpl)), - - repository3.NewConfigMapHistoryRepositoryImpl, - wire.Bind(new(repository3.ConfigMapHistoryRepository), new(*repository3.ConfigMapHistoryRepositoryImpl)), - repository3.NewDeploymentTemplateHistoryRepositoryImpl, - wire.Bind(new(repository3.DeploymentTemplateHistoryRepository), new(*repository3.DeploymentTemplateHistoryRepositoryImpl)), - repository3.NewPrePostCiScriptHistoryRepositoryImpl, - wire.Bind(new(repository3.PrePostCiScriptHistoryRepository), new(*repository3.PrePostCiScriptHistoryRepositoryImpl)), - repository3.NewPrePostCdScriptHistoryRepositoryImpl, - wire.Bind(new(repository3.PrePostCdScriptHistoryRepository), new(*repository3.PrePostCdScriptHistoryRepositoryImpl)), - repository3.NewPipelineStrategyHistoryRepositoryImpl, - wire.Bind(new(repository3.PipelineStrategyHistoryRepository), new(*repository3.PipelineStrategyHistoryRepositoryImpl)), - repository3.NewGitMaterialHistoryRepositoyImpl, - wire.Bind(new(repository3.GitMaterialHistoryRepository), new(*repository3.GitMaterialHistoryRepositoryImpl)), - - history3.NewCiTemplateHistoryServiceImpl, - wire.Bind(new(history3.CiTemplateHistoryService), new(*history3.CiTemplateHistoryServiceImpl)), - - repository3.NewCiTemplateHistoryRepositoryImpl, - wire.Bind(new(repository3.CiTemplateHistoryRepository), new(*repository3.CiTemplateHistoryRepositoryImpl)), - - history3.NewCiPipelineHistoryServiceImpl, - wire.Bind(new(history3.CiPipelineHistoryService), new(*history3.CiPipelineHistoryServiceImpl)), - - repository3.NewCiPipelineHistoryRepositoryImpl, - wire.Bind(new(repository3.CiPipelineHistoryRepository), new(*repository3.CiPipelineHistoryRepositoryImpl)), - - history3.NewPrePostCdScriptHistoryServiceImpl, - wire.Bind(new(history3.PrePostCdScriptHistoryService), new(*history3.PrePostCdScriptHistoryServiceImpl)), - history3.NewPrePostCiScriptHistoryServiceImpl, - wire.Bind(new(history3.PrePostCiScriptHistoryService), new(*history3.PrePostCiScriptHistoryServiceImpl)), - history3.NewDeploymentTemplateHistoryServiceImpl, - wire.Bind(new(history3.DeploymentTemplateHistoryService), new(*history3.DeploymentTemplateHistoryServiceImpl)), - history3.NewConfigMapHistoryServiceImpl, - wire.Bind(new(history3.ConfigMapHistoryService), new(*history3.ConfigMapHistoryServiceImpl)), - history3.NewPipelineStrategyHistoryServiceImpl, - wire.Bind(new(history3.PipelineStrategyHistoryService), new(*history3.PipelineStrategyHistoryServiceImpl)), - history3.NewGitMaterialHistoryServiceImpl, - wire.Bind(new(history3.GitMaterialHistoryService), new(*history3.GitMaterialHistoryServiceImpl)), - - history3.NewDeployedConfigurationHistoryServiceImpl, - wire.Bind(new(history3.DeployedConfigurationHistoryService), new(*history3.DeployedConfigurationHistoryServiceImpl)), - // history ends - - // plugin starts - repository6.NewGlobalPluginRepository, - wire.Bind(new(repository6.GlobalPluginRepository), new(*repository6.GlobalPluginRepositoryImpl)), - - plugin.NewGlobalPluginService, - wire.Bind(new(plugin.GlobalPluginService), new(*plugin.GlobalPluginServiceImpl)), - - restHandler.NewGlobalPluginRestHandler, - wire.Bind(new(restHandler.GlobalPluginRestHandler), new(*restHandler.GlobalPluginRestHandlerImpl)), - - router.NewGlobalPluginRouter, - wire.Bind(new(router.GlobalPluginRouter), new(*router.GlobalPluginRouterImpl)), - - repository5.NewPipelineStageRepository, - wire.Bind(new(repository5.PipelineStageRepository), new(*repository5.PipelineStageRepositoryImpl)), - - pipeline.NewPipelineStageService, - wire.Bind(new(pipeline.PipelineStageService), new(*pipeline.PipelineStageServiceImpl)), - // plugin ends - - connection.NewArgoCDConnectionManagerImpl, - wire.Bind(new(connection.ArgoCDConnectionManager), new(*connection.ArgoCDConnectionManagerImpl)), - argo.NewArgoUserServiceImpl, - wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)), - //util2.GetEnvironmentVariables, - // AuthWireSet, - - cron.NewCdApplicationStatusUpdateHandlerImpl, - wire.Bind(new(cron.CdApplicationStatusUpdateHandler), new(*cron.CdApplicationStatusUpdateHandlerImpl)), - - // app_status - appStatusRepo.NewAppStatusRepositoryImpl, - wire.Bind(new(appStatusRepo.AppStatusRepository), new(*appStatusRepo.AppStatusRepositoryImpl)), - appStatus.NewAppStatusServiceImpl, - wire.Bind(new(appStatus.AppStatusService), new(*appStatus.AppStatusServiceImpl)), - // app_status ends - - cron.GetCiWorkflowStatusUpdateConfig, - cron.NewCiStatusUpdateCronImpl, - wire.Bind(new(cron.CiStatusUpdateCron), new(*cron.CiStatusUpdateCronImpl)), - - cron.GetCiTriggerCronConfig, - cron.NewCiTriggerCronImpl, - wire.Bind(new(cron.CiTriggerCron), new(*cron.CiTriggerCronImpl)), - - status2.NewPipelineStatusTimelineRestHandlerImpl, - wire.Bind(new(status2.PipelineStatusTimelineRestHandler), new(*status2.PipelineStatusTimelineRestHandlerImpl)), - - status.NewPipelineStatusTimelineServiceImpl, - wire.Bind(new(status.PipelineStatusTimelineService), new(*status.PipelineStatusTimelineServiceImpl)), - - router.NewUserAttributesRouterImpl, - wire.Bind(new(router.UserAttributesRouter), new(*router.UserAttributesRouterImpl)), - restHandler.NewUserAttributesRestHandlerImpl, - wire.Bind(new(restHandler.UserAttributesRestHandler), new(*restHandler.UserAttributesRestHandlerImpl)), - attributes.NewUserAttributesServiceImpl, - wire.Bind(new(attributes.UserAttributesService), new(*attributes.UserAttributesServiceImpl)), - repository.NewUserAttributesRepositoryImpl, - wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)), - pipelineConfig.NewPipelineStatusTimelineRepositoryImpl, - wire.Bind(new(pipelineConfig.PipelineStatusTimelineRepository), new(*pipelineConfig.PipelineStatusTimelineRepositoryImpl)), - wire.Bind(new(pipeline.DeploymentConfigService), new(*pipeline.DeploymentConfigServiceImpl)), - pipeline.NewDeploymentConfigServiceImpl, - pipelineConfig.NewCiTemplateOverrideRepositoryImpl, - wire.Bind(new(pipelineConfig.CiTemplateOverrideRepository), new(*pipelineConfig.CiTemplateOverrideRepositoryImpl)), - pipelineConfig.NewCiBuildConfigRepositoryImpl, - wire.Bind(new(pipelineConfig.CiBuildConfigRepository), new(*pipelineConfig.CiBuildConfigRepositoryImpl)), - pipeline.NewCiBuildConfigServiceImpl, - wire.Bind(new(pipeline.CiBuildConfigService), new(*pipeline.CiBuildConfigServiceImpl)), - pipeline.NewCiTemplateServiceImpl, - wire.Bind(new(pipeline.CiTemplateService), new(*pipeline.CiTemplateServiceImpl)), - router.NewGlobalCMCSRouterImpl, - wire.Bind(new(router.GlobalCMCSRouter), new(*router.GlobalCMCSRouterImpl)), - restHandler.NewGlobalCMCSRestHandlerImpl, - wire.Bind(new(restHandler.GlobalCMCSRestHandler), new(*restHandler.GlobalCMCSRestHandlerImpl)), - pipeline.NewGlobalCMCSServiceImpl, - wire.Bind(new(pipeline.GlobalCMCSService), new(*pipeline.GlobalCMCSServiceImpl)), - repository.NewGlobalCMCSRepositoryImpl, - wire.Bind(new(repository.GlobalCMCSRepository), new(*repository.GlobalCMCSRepositoryImpl)), - - // chartRepoRepository.NewGlobalStrategyMetadataRepositoryImpl, - // wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataRepository), new(*chartRepoRepository.GlobalStrategyMetadataRepositoryImpl)), - chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl, - wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepository), new(*chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepositoryImpl)), - - status.NewPipelineStatusTimelineResourcesServiceImpl, - wire.Bind(new(status.PipelineStatusTimelineResourcesService), new(*status.PipelineStatusTimelineResourcesServiceImpl)), - pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl, - wire.Bind(new(pipelineConfig.PipelineStatusTimelineResourcesRepository), new(*pipelineConfig.PipelineStatusTimelineResourcesRepositoryImpl)), - - status.NewPipelineStatusSyncDetailServiceImpl, - wire.Bind(new(status.PipelineStatusSyncDetailService), new(*status.PipelineStatusSyncDetailServiceImpl)), - pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl, - wire.Bind(new(pipelineConfig.PipelineStatusSyncDetailRepository), new(*pipelineConfig.PipelineStatusSyncDetailRepositoryImpl)), - - repository7.NewK8sResourceHistoryRepositoryImpl, - wire.Bind(new(repository7.K8sResourceHistoryRepository), new(*repository7.K8sResourceHistoryRepositoryImpl)), - - kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl, - wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)), - - router.NewResourceGroupingRouterImpl, - wire.Bind(new(router.ResourceGroupingRouter), new(*router.ResourceGroupingRouterImpl)), - restHandler.NewResourceGroupRestHandlerImpl, - wire.Bind(new(restHandler.ResourceGroupRestHandler), new(*restHandler.ResourceGroupRestHandlerImpl)), - resourceGroup2.NewResourceGroupServiceImpl, - wire.Bind(new(resourceGroup2.ResourceGroupService), new(*resourceGroup2.ResourceGroupServiceImpl)), - resourceGroup.NewResourceGroupRepositoryImpl, - wire.Bind(new(resourceGroup.ResourceGroupRepository), new(*resourceGroup.ResourceGroupRepositoryImpl)), - resourceGroup.NewResourceGroupMappingRepositoryImpl, - wire.Bind(new(resourceGroup.ResourceGroupMappingRepository), new(*resourceGroup.ResourceGroupMappingRepositoryImpl)), - executors.NewArgoWorkflowExecutorImpl, - wire.Bind(new(executors.ArgoWorkflowExecutor), new(*executors.ArgoWorkflowExecutorImpl)), - executors.NewSystemWorkflowExecutorImpl, - wire.Bind(new(executors.SystemWorkflowExecutor), new(*executors.SystemWorkflowExecutorImpl)), - repository5.NewManifestPushConfigRepository, - wire.Bind(new(repository5.ManifestPushConfigRepository), new(*repository5.ManifestPushConfigRepositoryImpl)), - app.NewGitOpsManifestPushServiceImpl, - wire.Bind(new(app.GitOpsPushService), new(*app.GitOpsManifestPushServiceImpl)), - - // start: docker registry wire set injection - router.NewDockerRegRouterImpl, - wire.Bind(new(router.DockerRegRouter), new(*router.DockerRegRouterImpl)), - restHandler.NewDockerRegRestHandlerExtendedImpl, - wire.Bind(new(restHandler.DockerRegRestHandler), new(*restHandler.DockerRegRestHandlerExtendedImpl)), - pipeline.NewDockerRegistryConfigImpl, - wire.Bind(new(pipeline.DockerRegistryConfig), new(*pipeline.DockerRegistryConfigImpl)), - dockerRegistry.NewDockerRegistryIpsConfigServiceImpl, - wire.Bind(new(dockerRegistry.DockerRegistryIpsConfigService), new(*dockerRegistry.DockerRegistryIpsConfigServiceImpl)), - dockerRegistryRepository.NewDockerArtifactStoreRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.DockerArtifactStoreRepository), new(*dockerRegistryRepository.DockerArtifactStoreRepositoryImpl)), - dockerRegistryRepository.NewDockerRegistryIpsConfigRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.DockerRegistryIpsConfigRepository), new(*dockerRegistryRepository.DockerRegistryIpsConfigRepositoryImpl)), - dockerRegistryRepository.NewOCIRegistryConfigRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.OCIRegistryConfigRepository), new(*dockerRegistryRepository.OCIRegistryConfigRepositoryImpl)), - - // end: docker registry wire set injection - - resourceQualifiers.NewQualifiersMappingRepositoryImpl, - wire.Bind(new(resourceQualifiers.QualifiersMappingRepository), new(*resourceQualifiers.QualifiersMappingRepositoryImpl)), - - resourceQualifiers.NewQualifierMappingServiceImpl, - wire.Bind(new(resourceQualifiers.QualifierMappingService), new(*resourceQualifiers.QualifierMappingServiceImpl)), - - repository9.NewDevtronResourceSearchableKeyRepositoryImpl, - wire.Bind(new(repository9.DevtronResourceSearchableKeyRepository), new(*repository9.DevtronResourceSearchableKeyRepositoryImpl)), - - devtronResource.NewDevtronResourceSearchableKeyServiceImpl, - wire.Bind(new(devtronResource.DevtronResourceSearchableKeyService), new(*devtronResource.DevtronResourceSearchableKeyServiceImpl)), - - argocdServer.NewArgoClientWrapperServiceImpl, - wire.Bind(new(argocdServer.ArgoClientWrapperService), new(*argocdServer.ArgoClientWrapperServiceImpl)), - - pipeline.NewPluginInputVariableParserImpl, - wire.Bind(new(pipeline.PluginInputVariableParser), new(*pipeline.PluginInputVariableParserImpl)), - - pipeline.NewPipelineConfigListenerServiceImpl, - wire.Bind(new(pipeline.PipelineConfigListenerService), new(*pipeline.PipelineConfigListenerServiceImpl)), - cron2.NewCronLoggerImpl, - - imageDigestPolicy.NewImageDigestPolicyServiceImpl, - wire.Bind(new(imageDigestPolicy.ImageDigestPolicyService), new(*imageDigestPolicy.ImageDigestPolicyServiceImpl)), + commonWireset.CommonWireSet, ) return &App{}, nil } diff --git a/authWire.go b/authWire.go index 27bdad693d..57ac34a45e 100644 --- a/authWire.go +++ b/authWire.go @@ -2,7 +2,6 @@ package main import ( "github.com/devtron-labs/authenticator/client" - "github.com/devtron-labs/authenticator/middleware" "github.com/devtron-labs/devtron/api/apiToken" "github.com/google/wire" ) @@ -14,6 +13,4 @@ var AuthWireSet = wire.NewSet( client.BuildDexConfig, client.GetSettings, apiToken.ApiTokenSecretWireSet, - middleware.NewSessionManager, - middleware.NewUserLogin, -) \ No newline at end of file +) diff --git a/commonWireset/commonWireset.go b/commonWireset/commonWireset.go new file mode 100644 index 0000000000..8192ca7060 --- /dev/null +++ b/commonWireset/commonWireset.go @@ -0,0 +1,936 @@ +package commonWireset + +import ( + "github.com/devtron-labs/authenticator/middleware" + util4 "github.com/devtron-labs/common-lib/utils/k8s" + "github.com/devtron-labs/devtron/api/apiToken" + appStoreRestHandler "github.com/devtron-labs/devtron/api/appStore" + chartGroup2 "github.com/devtron-labs/devtron/api/appStore/chartGroup" + "github.com/devtron-labs/devtron/api/appStore/chartProvider" + appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" + appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover" + appStoreValues "github.com/devtron-labs/devtron/api/appStore/values" + "github.com/devtron-labs/devtron/api/argoApplication" + "github.com/devtron-labs/devtron/api/auth/sso" + "github.com/devtron-labs/devtron/api/auth/user" + "github.com/devtron-labs/devtron/api/chartRepo" + "github.com/devtron-labs/devtron/api/cluster" + "github.com/devtron-labs/devtron/api/connector" + "github.com/devtron-labs/devtron/api/dashboardEvent" + "github.com/devtron-labs/devtron/api/deployment" + "github.com/devtron-labs/devtron/api/externalLink" + client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/infraConfig" + "github.com/devtron-labs/devtron/api/k8s" + "github.com/devtron-labs/devtron/api/module" + "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" + pipeline3 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline" + pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history" + status2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger" + "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook" + "github.com/devtron-labs/devtron/api/restHandler/app/workflow" + "github.com/devtron-labs/devtron/api/restHandler/scopedVariable" + "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + "github.com/devtron-labs/devtron/api/router/app/appList" + pipeline5 "github.com/devtron-labs/devtron/api/router/app/pipeline" + pipeline4 "github.com/devtron-labs/devtron/api/router/app/pipeline/configure" + history2 "github.com/devtron-labs/devtron/api/router/app/pipeline/history" + status3 "github.com/devtron-labs/devtron/api/router/app/pipeline/status" + trigger2 "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger" + workflow2 "github.com/devtron-labs/devtron/api/router/app/workflow" + "github.com/devtron-labs/devtron/api/router/pubsub" + "github.com/devtron-labs/devtron/api/server" + "github.com/devtron-labs/devtron/api/sse" + "github.com/devtron-labs/devtron/api/team" + "github.com/devtron-labs/devtron/api/terminal" + util5 "github.com/devtron-labs/devtron/api/util" + webhookHelm "github.com/devtron-labs/devtron/api/webhook/helm" + "github.com/devtron-labs/devtron/client/argocdServer" + "github.com/devtron-labs/devtron/client/argocdServer/application" + cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster" + "github.com/devtron-labs/devtron/client/argocdServer/connection" + repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository" + session2 "github.com/devtron-labs/devtron/client/argocdServer/session" + "github.com/devtron-labs/devtron/client/cron" + "github.com/devtron-labs/devtron/client/dashboard" + eClient "github.com/devtron-labs/devtron/client/events" + "github.com/devtron-labs/devtron/client/gitSensor" + "github.com/devtron-labs/devtron/client/grafana" + "github.com/devtron-labs/devtron/client/lens" + "github.com/devtron-labs/devtron/client/proxy" + "github.com/devtron-labs/devtron/client/telemetry" + "github.com/devtron-labs/devtron/internal/sql/repository" + app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" + appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" + appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" + "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" + security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/app" + "github.com/devtron-labs/devtron/pkg/app/status" + "github.com/devtron-labs/devtron/pkg/appClone" + "github.com/devtron-labs/devtron/pkg/appClone/batch" + "github.com/devtron-labs/devtron/pkg/appStatus" + "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" + deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" + "github.com/devtron-labs/devtron/pkg/appWorkflow" + "github.com/devtron-labs/devtron/pkg/attributes" + "github.com/devtron-labs/devtron/pkg/build" + "github.com/devtron-labs/devtron/pkg/bulkAction" + "github.com/devtron-labs/devtron/pkg/chart" + chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" + "github.com/devtron-labs/devtron/pkg/commonService" + delete2 "github.com/devtron-labs/devtron/pkg/delete" + deployment2 "github.com/devtron-labs/devtron/pkg/deployment" + git2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" + "github.com/devtron-labs/devtron/pkg/deploymentGroup" + "github.com/devtron-labs/devtron/pkg/devtronResource" + repository9 "github.com/devtron-labs/devtron/pkg/devtronResource/repository" + "github.com/devtron-labs/devtron/pkg/dockerRegistry" + "github.com/devtron-labs/devtron/pkg/eventProcessor" + "github.com/devtron-labs/devtron/pkg/generateManifest" + "github.com/devtron-labs/devtron/pkg/git" + "github.com/devtron-labs/devtron/pkg/gitops" + "github.com/devtron-labs/devtron/pkg/imageDigestPolicy" + infraConfigService "github.com/devtron-labs/devtron/pkg/infraConfig" + "github.com/devtron-labs/devtron/pkg/infraConfig/units" + "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" + repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + "github.com/devtron-labs/devtron/pkg/notifier" + "github.com/devtron-labs/devtron/pkg/pipeline" + "github.com/devtron-labs/devtron/pkg/pipeline/executors" + history3 "github.com/devtron-labs/devtron/pkg/pipeline/history" + repository3 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + "github.com/devtron-labs/devtron/pkg/pipeline/infraProviders" + 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" + resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup" + "github.com/devtron-labs/devtron/pkg/resourceQualifiers" + "github.com/devtron-labs/devtron/pkg/security" + util3 "github.com/devtron-labs/devtron/pkg/util" + "github.com/devtron-labs/devtron/pkg/variables" + "github.com/devtron-labs/devtron/pkg/variables/parsers" + repository10 "github.com/devtron-labs/devtron/pkg/variables/repository" + workflow3 "github.com/devtron-labs/devtron/pkg/workflow" + "github.com/devtron-labs/devtron/pkg/workflow/dag" + util2 "github.com/devtron-labs/devtron/util" + "github.com/devtron-labs/devtron/util/argo" + cron2 "github.com/devtron-labs/devtron/util/cron" + "github.com/devtron-labs/devtron/util/rbac" + "github.com/google/wire" +) + +var CommonWireSet = wire.NewSet( + // ----- wireset start + user.SelfRegistrationWireSet, + externalLink.ExternalLinkWireSet, + team.TeamsWireSet, + util4.NewK8sUtil, + user.UserWireSet, + sso.SsoConfigWireSet, + cluster.ClusterWireSet, + dashboard.DashboardWireSet, + proxy.ProxyWireSet, + client.HelmAppWireSet, + k8s.K8sApplicationWireSet, + chartRepo.ChartRepositoryWireSet, + appStoreDiscover.AppStoreDiscoverWireSet, + chartProvider.AppStoreChartProviderWireSet, + appStoreValues.AppStoreValuesWireSet, + util2.GetEnvironmentVariables, + appStoreDeployment.AppStoreDeploymentWireSet, + server.ServerWireSet, + module.ModuleWireSet, + apiToken.ApiTokenWireSet, + webhookHelm.WebhookHelmWireSet, + terminal.TerminalWireSet, + build.BuildWireSet, + deployment2.DeploymentWireSet, + argoApplication.ArgoApplicationWireSet, + + eventProcessor.EventProcessorWireSet, + workflow3.WorkflowWireSet, + // -------wireset end ---------- + // ------- + gitSensor.GetConfig, + gitSensor.NewGitSensorClient, + wire.Bind(new(gitSensor.Client), new(*gitSensor.ClientImpl)), + // ------- + helper.NewAppListingRepositoryQueryBuilder, + // sql.GetConfig, + eClient.GetEventClientConfig, + // sql.NewDbConnection, + // app.GetACDAuthConfig, + util3.GetACDAuthConfig, + connection.SettingsManager, + // auth.GetConfig, + middleware.NewSessionManager, + middleware.NewUserLogin, + connection.GetConfig, + wire.Bind(new(session2.ServiceClient), new(*middleware.LoginService)), + + sse.NewSSE, + trigger2.NewPipelineTriggerRouter, + wire.Bind(new(trigger2.PipelineTriggerRouter), new(*trigger2.PipelineTriggerRouterImpl)), + + // ---- pprof start ---- + restHandler.NewPProfRestHandler, + wire.Bind(new(restHandler.PProfRestHandler), new(*restHandler.PProfRestHandlerImpl)), + + router.NewPProfRouter, + wire.Bind(new(router.PProfRouter), new(*router.PProfRouterImpl)), + // ---- pprof end ---- + + trigger.NewPipelineRestHandler, + wire.Bind(new(trigger.PipelineTriggerRestHandler), new(*trigger.PipelineTriggerRestHandlerImpl)), + app.GetAppServiceConfig, + app.NewAppService, + wire.Bind(new(app.AppService), new(*app.AppServiceImpl)), + + bulkUpdate.NewBulkUpdateRepository, + wire.Bind(new(bulkUpdate.BulkUpdateRepository), new(*bulkUpdate.BulkUpdateRepositoryImpl)), + + chartConfig.NewEnvConfigOverrideRepository, + wire.Bind(new(chartConfig.EnvConfigOverrideRepository), new(*chartConfig.EnvConfigOverrideRepositoryImpl)), + chartConfig.NewPipelineOverrideRepository, + wire.Bind(new(chartConfig.PipelineOverrideRepository), new(*chartConfig.PipelineOverrideRepositoryImpl)), + wire.Struct(new(util.MergeUtil), "*"), + + deployment.NewDeploymentConfigRestHandlerImpl, + wire.Bind(new(deployment.DeploymentConfigRestHandler), new(*deployment.DeploymentConfigRestHandlerImpl)), + deployment.NewDeploymentRouterImpl, + wire.Bind(new(deployment.DeploymentConfigRouter), new(*deployment.DeploymentConfigRouterImpl)), + + dashboardEvent.NewDashboardTelemetryRestHandlerImpl, + wire.Bind(new(dashboardEvent.DashboardTelemetryRestHandler), new(*dashboardEvent.DashboardTelemetryRestHandlerImpl)), + dashboardEvent.NewDashboardTelemetryRouterImpl, + wire.Bind(new(dashboardEvent.DashboardTelemetryRouter), + new(*dashboardEvent.DashboardTelemetryRouterImpl)), + + infraConfigService.NewInfraProfileRepositoryImpl, + wire.Bind(new(infraConfigService.InfraConfigRepository), new(*infraConfigService.InfraConfigRepositoryImpl)), + + units.NewUnits, + infraConfigService.NewInfraConfigServiceImpl, + wire.Bind(new(infraConfigService.InfraConfigService), new(*infraConfigService.InfraConfigServiceImpl)), + infraProviders.NewInfraProviderImpl, + wire.Bind(new(infraProviders.InfraProvider), new(*infraProviders.InfraProviderImpl)), + infraConfig.NewInfraConfigRestHandlerImpl, + wire.Bind(new(infraConfig.InfraConfigRestHandler), new(*infraConfig.InfraConfigRestHandlerImpl)), + + infraConfig.NewInfraProfileRouterImpl, + wire.Bind(new(infraConfig.InfraConfigRouter), new(*infraConfig.InfraConfigRouterImpl)), + + router.NewMuxRouter, + + app2.NewAppRepositoryImpl, + wire.Bind(new(app2.AppRepository), new(*app2.AppRepositoryImpl)), + + //util2.GetEnvironmentVariables, + + pipeline.NewPipelineBuilderImpl, + wire.Bind(new(pipeline.PipelineBuilder), new(*pipeline.PipelineBuilderImpl)), + pipeline.NewBuildPipelineSwitchServiceImpl, + wire.Bind(new(pipeline.BuildPipelineSwitchService), new(*pipeline.BuildPipelineSwitchServiceImpl)), + pipeline.NewCiPipelineConfigServiceImpl, + wire.Bind(new(pipeline.CiPipelineConfigService), new(*pipeline.CiPipelineConfigServiceImpl)), + pipeline.NewCiMaterialConfigServiceImpl, + wire.Bind(new(pipeline.CiMaterialConfigService), new(*pipeline.CiMaterialConfigServiceImpl)), + + pipeline.NewAppArtifactManagerImpl, + wire.Bind(new(pipeline.AppArtifactManager), new(*pipeline.AppArtifactManagerImpl)), + pipeline.NewDevtronAppCMCSServiceImpl, + wire.Bind(new(pipeline.DevtronAppCMCSService), new(*pipeline.DevtronAppCMCSServiceImpl)), + pipeline.NewDevtronAppStrategyServiceImpl, + wire.Bind(new(pipeline.DevtronAppStrategyService), new(*pipeline.DevtronAppStrategyServiceImpl)), + pipeline.NewAppDeploymentTypeChangeManagerImpl, + wire.Bind(new(pipeline.AppDeploymentTypeChangeManager), new(*pipeline.AppDeploymentTypeChangeManagerImpl)), + pipeline.NewCdPipelineConfigServiceImpl, + wire.Bind(new(pipeline.CdPipelineConfigService), new(*pipeline.CdPipelineConfigServiceImpl)), + pipeline.NewDevtronAppConfigServiceImpl, + wire.Bind(new(pipeline.DevtronAppConfigService), new(*pipeline.DevtronAppConfigServiceImpl)), + pipeline3.NewDevtronAppAutoCompleteRestHandlerImpl, + wire.Bind(new(pipeline3.DevtronAppAutoCompleteRestHandler), new(*pipeline3.DevtronAppAutoCompleteRestHandlerImpl)), + + util5.NewLoggingMiddlewareImpl, + wire.Bind(new(util5.LoggingMiddleware), new(*util5.LoggingMiddlewareImpl)), + pipeline2.NewPipelineRestHandlerImpl, + wire.Bind(new(pipeline2.PipelineConfigRestHandler), new(*pipeline2.PipelineConfigRestHandlerImpl)), + + pipeline4.NewPipelineRouterImpl, + wire.Bind(new(pipeline4.PipelineConfigRouter), new(*pipeline4.PipelineConfigRouterImpl)), + history2.NewPipelineHistoryRouterImpl, + wire.Bind(new(history2.PipelineHistoryRouter), new(*history2.PipelineHistoryRouterImpl)), + status3.NewPipelineStatusRouterImpl, + wire.Bind(new(status3.PipelineStatusRouter), new(*status3.PipelineStatusRouterImpl)), + pipeline5.NewDevtronAppAutoCompleteRouterImpl, + wire.Bind(new(pipeline5.DevtronAppAutoCompleteRouter), new(*pipeline5.DevtronAppAutoCompleteRouterImpl)), + workflow2.NewAppWorkflowRouterImpl, + wire.Bind(new(workflow2.AppWorkflowRouter), new(*workflow2.AppWorkflowRouterImpl)), + + pipeline.NewCiCdPipelineOrchestrator, + wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)), + pipelineConfig.NewMaterialRepositoryImpl, + wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), + + util.NewChartTemplateServiceImpl, + wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)), + + // scoped variables start + variables.NewScopedVariableServiceImpl, + wire.Bind(new(variables.ScopedVariableService), new(*variables.ScopedVariableServiceImpl)), + + parsers.NewVariableTemplateParserImpl, + wire.Bind(new(parsers.VariableTemplateParser), new(*parsers.VariableTemplateParserImpl)), + repository10.NewVariableEntityMappingRepository, + wire.Bind(new(repository10.VariableEntityMappingRepository), new(*repository10.VariableEntityMappingRepositoryImpl)), + + repository10.NewVariableSnapshotHistoryRepository, + wire.Bind(new(repository10.VariableSnapshotHistoryRepository), new(*repository10.VariableSnapshotHistoryRepositoryImpl)), + variables.NewVariableEntityMappingServiceImpl, + wire.Bind(new(variables.VariableEntityMappingService), new(*variables.VariableEntityMappingServiceImpl)), + variables.NewVariableSnapshotHistoryServiceImpl, + wire.Bind(new(variables.VariableSnapshotHistoryService), new(*variables.VariableSnapshotHistoryServiceImpl)), + + variables.NewScopedVariableManagerImpl, + wire.Bind(new(variables.ScopedVariableManager), new(*variables.ScopedVariableManagerImpl)), + + variables.NewScopedVariableCMCSManagerImpl, + wire.Bind(new(variables.ScopedVariableCMCSManager), new(*variables.ScopedVariableCMCSManagerImpl)), + + // end + + chart.NewChartServiceImpl, + wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)), + bulkAction.NewBulkUpdateServiceImpl, + wire.Bind(new(bulkAction.BulkUpdateService), new(*bulkAction.BulkUpdateServiceImpl)), + + repository.NewImageTagRepository, + wire.Bind(new(repository.ImageTagRepository), new(*repository.ImageTagRepositoryImpl)), + + pipeline.NewCustomTagService, + wire.Bind(new(pipeline.CustomTagService), new(*pipeline.CustomTagServiceImpl)), + + repository.NewGitProviderRepositoryImpl, + wire.Bind(new(repository.GitProviderRepository), new(*repository.GitProviderRepositoryImpl)), + pipeline.NewGitRegistryConfigImpl, + wire.Bind(new(pipeline.GitRegistryConfig), new(*pipeline.GitRegistryConfigImpl)), + + appList.NewAppFilteringRouterImpl, + wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), + appList2.NewAppFilteringRestHandlerImpl, + wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), + + appList.NewAppListingRouterImpl, + wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)), + appList2.NewAppListingRestHandlerImpl, + wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)), + app.NewAppListingServiceImpl, + wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)), + repository.NewAppListingRepositoryImpl, + wire.Bind(new(repository.AppListingRepository), new(*repository.AppListingRepositoryImpl)), + + repository.NewDeploymentTemplateRepositoryImpl, + wire.Bind(new(repository.DeploymentTemplateRepository), new(*repository.DeploymentTemplateRepositoryImpl)), + generateManifest.NewDeploymentTemplateServiceImpl, + wire.Bind(new(generateManifest.DeploymentTemplateService), new(*generateManifest.DeploymentTemplateServiceImpl)), + + router.NewJobRouterImpl, + wire.Bind(new(router.JobRouter), new(*router.JobRouterImpl)), + + pipelineConfig.NewPipelineRepositoryImpl, + wire.Bind(new(pipelineConfig.PipelineRepository), new(*pipelineConfig.PipelineRepositoryImpl)), + pipeline.NewPropertiesConfigServiceImpl, + wire.Bind(new(pipeline.PropertiesConfigService), new(*pipeline.PropertiesConfigServiceImpl)), + + eClient.NewEventRESTClientImpl, + wire.Bind(new(eClient.EventClient), new(*eClient.EventRESTClientImpl)), + + eClient.NewEventSimpleFactoryImpl, + wire.Bind(new(eClient.EventFactory), new(*eClient.EventSimpleFactoryImpl)), + + repository.NewCiArtifactRepositoryImpl, + wire.Bind(new(repository.CiArtifactRepository), new(*repository.CiArtifactRepositoryImpl)), + pipeline.NewWebhookServiceImpl, + wire.Bind(new(pipeline.WebhookService), new(*pipeline.WebhookServiceImpl)), + + router.NewWebhookRouterImpl, + wire.Bind(new(router.WebhookRouter), new(*router.WebhookRouterImpl)), + pipelineConfig.NewCiTemplateRepositoryImpl, + wire.Bind(new(pipelineConfig.CiTemplateRepository), new(*pipelineConfig.CiTemplateRepositoryImpl)), + pipelineConfig.NewCiPipelineRepositoryImpl, + wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), + pipelineConfig.NewCiPipelineMaterialRepositoryImpl, + wire.Bind(new(pipelineConfig.CiPipelineMaterialRepository), new(*pipelineConfig.CiPipelineMaterialRepositoryImpl)), + git2.NewGitFactory, + + application.NewApplicationClientImpl, + wire.Bind(new(application.ServiceClient), new(*application.ServiceClientImpl)), + cluster2.NewServiceClientImpl, + wire.Bind(new(cluster2.ServiceClient), new(*cluster2.ServiceClientImpl)), + connector.NewPumpImpl, + repository2.NewServiceClientImpl, + wire.Bind(new(repository2.ServiceClient), new(*repository2.ServiceClientImpl)), + wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), + + //app.GetConfig, + + pipeline.GetEcrConfig, + // otel.NewOtelTracingServiceImpl, + // wire.Bind(new(otel.OtelTracingService), new(*otel.OtelTracingServiceImpl)), + // session.NewK8sClient, + repository8.NewImageTaggingRepositoryImpl, + wire.Bind(new(repository8.ImageTaggingRepository), new(*repository8.ImageTaggingRepositoryImpl)), + pipeline.NewImageTaggingServiceImpl, + wire.Bind(new(pipeline.ImageTaggingService), new(*pipeline.ImageTaggingServiceImpl)), + argocdServer.NewVersionServiceImpl, + wire.Bind(new(argocdServer.VersionService), new(*argocdServer.VersionServiceImpl)), + + router.NewGitProviderRouterImpl, + wire.Bind(new(router.GitProviderRouter), new(*router.GitProviderRouterImpl)), + restHandler.NewGitProviderRestHandlerImpl, + wire.Bind(new(restHandler.GitProviderRestHandler), new(*restHandler.GitProviderRestHandlerImpl)), + + router.NewNotificationRouterImpl, + wire.Bind(new(router.NotificationRouter), new(*router.NotificationRouterImpl)), + restHandler.NewNotificationRestHandlerImpl, + wire.Bind(new(restHandler.NotificationRestHandler), new(*restHandler.NotificationRestHandlerImpl)), + + notifier.NewSlackNotificationServiceImpl, + wire.Bind(new(notifier.SlackNotificationService), new(*notifier.SlackNotificationServiceImpl)), + repository.NewSlackNotificationRepositoryImpl, + wire.Bind(new(repository.SlackNotificationRepository), new(*repository.SlackNotificationRepositoryImpl)), + notifier.NewWebhookNotificationServiceImpl, + wire.Bind(new(notifier.WebhookNotificationService), new(*notifier.WebhookNotificationServiceImpl)), + repository.NewWebhookNotificationRepositoryImpl, + wire.Bind(new(repository.WebhookNotificationRepository), new(*repository.WebhookNotificationRepositoryImpl)), + + notifier.NewNotificationConfigServiceImpl, + wire.Bind(new(notifier.NotificationConfigService), new(*notifier.NotificationConfigServiceImpl)), + app.NewAppListingViewBuilderImpl, + wire.Bind(new(app.AppListingViewBuilder), new(*app.AppListingViewBuilderImpl)), + repository.NewNotificationSettingsRepositoryImpl, + wire.Bind(new(repository.NotificationSettingsRepository), new(*repository.NotificationSettingsRepositoryImpl)), + types.GetCiCdConfig, + + pipeline.NewWorkflowServiceImpl, + wire.Bind(new(pipeline.WorkflowService), new(*pipeline.WorkflowServiceImpl)), + + pipeline.NewCiServiceImpl, + wire.Bind(new(pipeline.CiService), new(*pipeline.CiServiceImpl)), + + pipelineConfig.NewCiWorkflowRepositoryImpl, + wire.Bind(new(pipelineConfig.CiWorkflowRepository), new(*pipelineConfig.CiWorkflowRepositoryImpl)), + + restHandler.NewGitWebhookRestHandlerImpl, + wire.Bind(new(restHandler.GitWebhookRestHandler), new(*restHandler.GitWebhookRestHandlerImpl)), + + git.NewGitWebhookServiceImpl, + wire.Bind(new(git.GitWebhookService), new(*git.GitWebhookServiceImpl)), + + repository.NewGitWebhookRepositoryImpl, + wire.Bind(new(repository.GitWebhookRepository), new(*repository.GitWebhookRepositoryImpl)), + + pipeline.NewCiHandlerImpl, + wire.Bind(new(pipeline.CiHandler), new(*pipeline.CiHandlerImpl)), + + pipeline.NewCiLogServiceImpl, + wire.Bind(new(pipeline.CiLogService), new(*pipeline.CiLogServiceImpl)), + + pubsub.NewGitWebhookHandler, + wire.Bind(new(pubsub.GitWebhookHandler), new(*pubsub.GitWebhookHandlerImpl)), + + pubsub.NewApplicationStatusHandlerImpl, + wire.Bind(new(pubsub.ApplicationStatusHandler), new(*pubsub.ApplicationStatusHandlerImpl)), + + rbac.NewEnforcerUtilImpl, + wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), + + chartConfig.NewPipelineConfigRepository, + wire.Bind(new(chartConfig.PipelineConfigRepository), new(*chartConfig.PipelineConfigRepositoryImpl)), + + repository10.NewScopedVariableRepository, + wire.Bind(new(repository10.ScopedVariableRepository), new(*repository10.ScopedVariableRepositoryImpl)), + + repository.NewLinkoutsRepositoryImpl, + wire.Bind(new(repository.LinkoutsRepository), new(*repository.LinkoutsRepositoryImpl)), + + router.NewChartRefRouterImpl, + wire.Bind(new(router.ChartRefRouter), new(*router.ChartRefRouterImpl)), + restHandler.NewChartRefRestHandlerImpl, + wire.Bind(new(restHandler.ChartRefRestHandler), new(*restHandler.ChartRefRestHandlerImpl)), + + router.NewConfigMapRouterImpl, + wire.Bind(new(router.ConfigMapRouter), new(*router.ConfigMapRouterImpl)), + restHandler.NewConfigMapRestHandlerImpl, + wire.Bind(new(restHandler.ConfigMapRestHandler), new(*restHandler.ConfigMapRestHandlerImpl)), + pipeline.NewConfigMapServiceImpl, + wire.Bind(new(pipeline.ConfigMapService), new(*pipeline.ConfigMapServiceImpl)), + chartConfig.NewConfigMapRepositoryImpl, + wire.Bind(new(chartConfig.ConfigMapRepository), new(*chartConfig.ConfigMapRepositoryImpl)), + + notifier.NewSESNotificationServiceImpl, + wire.Bind(new(notifier.SESNotificationService), new(*notifier.SESNotificationServiceImpl)), + + repository.NewSESNotificationRepositoryImpl, + wire.Bind(new(repository.SESNotificationRepository), new(*repository.SESNotificationRepositoryImpl)), + + notifier.NewSMTPNotificationServiceImpl, + wire.Bind(new(notifier.SMTPNotificationService), new(*notifier.SMTPNotificationServiceImpl)), + + repository.NewSMTPNotificationRepositoryImpl, + wire.Bind(new(repository.SMTPNotificationRepository), new(*repository.SMTPNotificationRepositoryImpl)), + + notifier.NewNotificationConfigBuilderImpl, + wire.Bind(new(notifier.NotificationConfigBuilder), new(*notifier.NotificationConfigBuilderImpl)), + appStoreRestHandler.NewAppStoreStatusTimelineRestHandlerImpl, + wire.Bind(new(appStoreRestHandler.AppStoreStatusTimelineRestHandler), new(*appStoreRestHandler.AppStoreStatusTimelineRestHandlerImpl)), + appStoreRestHandler.NewInstalledAppRestHandlerImpl, + wire.Bind(new(appStoreRestHandler.InstalledAppRestHandler), new(*appStoreRestHandler.InstalledAppRestHandlerImpl)), + FullMode.NewInstalledAppDBExtendedServiceImpl, + wire.Bind(new(FullMode.InstalledAppDBExtendedService), new(*FullMode.InstalledAppDBExtendedServiceImpl)), + resource.NewInstalledAppResourceServiceImpl, + wire.Bind(new(resource.InstalledAppResourceService), new(*resource.InstalledAppResourceServiceImpl)), + deploymentTypeChange.NewInstalledAppDeploymentTypeChangeServiceImpl, + wire.Bind(new(deploymentTypeChange.InstalledAppDeploymentTypeChangeService), new(*deploymentTypeChange.InstalledAppDeploymentTypeChangeServiceImpl)), + + appStoreRestHandler.NewAppStoreRouterImpl, + wire.Bind(new(appStoreRestHandler.AppStoreRouter), new(*appStoreRestHandler.AppStoreRouterImpl)), + + workflow.NewAppWorkflowRestHandlerImpl, + wire.Bind(new(workflow.AppWorkflowRestHandler), new(*workflow.AppWorkflowRestHandlerImpl)), + + appWorkflow.NewAppWorkflowServiceImpl, + wire.Bind(new(appWorkflow.AppWorkflowService), new(*appWorkflow.AppWorkflowServiceImpl)), + + appWorkflow2.NewAppWorkflowRepositoryImpl, + wire.Bind(new(appWorkflow2.AppWorkflowRepository), new(*appWorkflow2.AppWorkflowRepositoryImpl)), + + restHandler.NewExternalCiRestHandlerImpl, + wire.Bind(new(restHandler.ExternalCiRestHandler), new(*restHandler.ExternalCiRestHandlerImpl)), + + grafana.GetGrafanaClientConfig, + grafana.NewGrafanaClientImpl, + wire.Bind(new(grafana.GrafanaClient), new(*grafana.GrafanaClientImpl)), + + app.NewReleaseDataServiceImpl, + wire.Bind(new(app.ReleaseDataService), new(*app.ReleaseDataServiceImpl)), + restHandler.NewReleaseMetricsRestHandlerImpl, + wire.Bind(new(restHandler.ReleaseMetricsRestHandler), new(*restHandler.ReleaseMetricsRestHandlerImpl)), + router.NewReleaseMetricsRouterImpl, + wire.Bind(new(router.ReleaseMetricsRouter), new(*router.ReleaseMetricsRouterImpl)), + lens.GetLensConfig, + lens.NewLensClientImpl, + wire.Bind(new(lens.LensClient), new(*lens.LensClientImpl)), + + pipelineConfig.NewCdWorkflowRepositoryImpl, + wire.Bind(new(pipelineConfig.CdWorkflowRepository), new(*pipelineConfig.CdWorkflowRepositoryImpl)), + + pipeline.NewCdHandlerImpl, + wire.Bind(new(pipeline.CdHandler), new(*pipeline.CdHandlerImpl)), + + pipeline.NewBlobStorageConfigServiceImpl, + wire.Bind(new(pipeline.BlobStorageConfigService), new(*pipeline.BlobStorageConfigServiceImpl)), + + dag.NewWorkflowDagExecutorImpl, + wire.Bind(new(dag.WorkflowDagExecutor), new(*dag.WorkflowDagExecutorImpl)), + appClone.NewAppCloneServiceImpl, + wire.Bind(new(appClone.AppCloneService), new(*appClone.AppCloneServiceImpl)), + + router.NewDeploymentGroupRouterImpl, + wire.Bind(new(router.DeploymentGroupRouter), new(*router.DeploymentGroupRouterImpl)), + restHandler.NewDeploymentGroupRestHandlerImpl, + wire.Bind(new(restHandler.DeploymentGroupRestHandler), new(*restHandler.DeploymentGroupRestHandlerImpl)), + deploymentGroup.NewDeploymentGroupServiceImpl, + wire.Bind(new(deploymentGroup.DeploymentGroupService), new(*deploymentGroup.DeploymentGroupServiceImpl)), + repository.NewDeploymentGroupRepositoryImpl, + wire.Bind(new(repository.DeploymentGroupRepository), new(*repository.DeploymentGroupRepositoryImpl)), + + repository.NewDeploymentGroupAppRepositoryImpl, + wire.Bind(new(repository.DeploymentGroupAppRepository), new(*repository.DeploymentGroupAppRepositoryImpl)), + restHandler.NewPubSubClientRestHandlerImpl, + wire.Bind(new(restHandler.PubSubClientRestHandler), new(*restHandler.PubSubClientRestHandlerImpl)), + + // Batch actions + batch.NewWorkflowActionImpl, + wire.Bind(new(batch.WorkflowAction), new(*batch.WorkflowActionImpl)), + batch.NewDeploymentActionImpl, + wire.Bind(new(batch.DeploymentAction), new(*batch.DeploymentActionImpl)), + batch.NewBuildActionImpl, + wire.Bind(new(batch.BuildAction), new(*batch.BuildActionImpl)), + batch.NewDataHolderActionImpl, + wire.Bind(new(batch.DataHolderAction), new(*batch.DataHolderActionImpl)), + batch.NewDeploymentTemplateActionImpl, + wire.Bind(new(batch.DeploymentTemplateAction), new(*batch.DeploymentTemplateActionImpl)), + restHandler.NewBatchOperationRestHandlerImpl, + wire.Bind(new(restHandler.BatchOperationRestHandler), new(*restHandler.BatchOperationRestHandlerImpl)), + router.NewBatchOperationRouterImpl, + wire.Bind(new(router.BatchOperationRouter), new(*router.BatchOperationRouterImpl)), + + repository4.NewChartGroupReposotoryImpl, + wire.Bind(new(repository4.ChartGroupReposotory), new(*repository4.ChartGroupReposotoryImpl)), + repository4.NewChartGroupEntriesRepositoryImpl, + wire.Bind(new(repository4.ChartGroupEntriesRepository), new(*repository4.ChartGroupEntriesRepositoryImpl)), + chartGroup.NewChartGroupServiceImpl, + wire.Bind(new(chartGroup.ChartGroupService), new(*chartGroup.ChartGroupServiceImpl)), + chartGroup2.NewChartGroupRestHandlerImpl, + wire.Bind(new(chartGroup2.ChartGroupRestHandler), new(*chartGroup2.ChartGroupRestHandlerImpl)), + chartGroup2.NewChartGroupRouterImpl, + wire.Bind(new(chartGroup2.ChartGroupRouter), new(*chartGroup2.ChartGroupRouterImpl)), + repository4.NewChartGroupDeploymentRepositoryImpl, + wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)), + + commonService.NewCommonServiceImpl, + wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)), + + router.NewImageScanRouterImpl, + wire.Bind(new(router.ImageScanRouter), new(*router.ImageScanRouterImpl)), + restHandler.NewImageScanRestHandlerImpl, + wire.Bind(new(restHandler.ImageScanRestHandler), new(*restHandler.ImageScanRestHandlerImpl)), + security.NewImageScanServiceImpl, + wire.Bind(new(security.ImageScanService), new(*security.ImageScanServiceImpl)), + security2.NewImageScanHistoryRepositoryImpl, + wire.Bind(new(security2.ImageScanHistoryRepository), new(*security2.ImageScanHistoryRepositoryImpl)), + security2.NewImageScanResultRepositoryImpl, + wire.Bind(new(security2.ImageScanResultRepository), new(*security2.ImageScanResultRepositoryImpl)), + security2.NewImageScanObjectMetaRepositoryImpl, + wire.Bind(new(security2.ImageScanObjectMetaRepository), new(*security2.ImageScanObjectMetaRepositoryImpl)), + security2.NewCveStoreRepositoryImpl, + wire.Bind(new(security2.CveStoreRepository), new(*security2.CveStoreRepositoryImpl)), + security2.NewImageScanDeployInfoRepositoryImpl, + wire.Bind(new(security2.ImageScanDeployInfoRepository), new(*security2.ImageScanDeployInfoRepositoryImpl)), + security2.NewScanToolMetadataRepositoryImpl, + wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), + router.NewPolicyRouterImpl, + wire.Bind(new(router.PolicyRouter), new(*router.PolicyRouterImpl)), + restHandler.NewPolicyRestHandlerImpl, + wire.Bind(new(restHandler.PolicyRestHandler), new(*restHandler.PolicyRestHandlerImpl)), + security.NewPolicyServiceImpl, + wire.Bind(new(security.PolicyService), new(*security.PolicyServiceImpl)), + security2.NewPolicyRepositoryImpl, + wire.Bind(new(security2.CvePolicyRepository), new(*security2.CvePolicyRepositoryImpl)), + security2.NewScanToolExecutionHistoryMappingRepositoryImpl, + wire.Bind(new(security2.ScanToolExecutionHistoryMappingRepository), new(*security2.ScanToolExecutionHistoryMappingRepositoryImpl)), + + argocdServer.NewArgoK8sClientImpl, + wire.Bind(new(argocdServer.ArgoK8sClient), new(*argocdServer.ArgoK8sClientImpl)), + + grafana.GetConfig, + router.NewGrafanaRouterImpl, + wire.Bind(new(router.GrafanaRouter), new(*router.GrafanaRouterImpl)), + + router.NewGitOpsConfigRouterImpl, + wire.Bind(new(router.GitOpsConfigRouter), new(*router.GitOpsConfigRouterImpl)), + restHandler.NewGitOpsConfigRestHandlerImpl, + wire.Bind(new(restHandler.GitOpsConfigRestHandler), new(*restHandler.GitOpsConfigRestHandlerImpl)), + gitops.NewGitOpsConfigServiceImpl, + wire.Bind(new(gitops.GitOpsConfigService), new(*gitops.GitOpsConfigServiceImpl)), + + router.NewAttributesRouterImpl, + wire.Bind(new(router.AttributesRouter), new(*router.AttributesRouterImpl)), + restHandler.NewAttributesRestHandlerImpl, + wire.Bind(new(restHandler.AttributesRestHandler), new(*restHandler.AttributesRestHandlerImpl)), + attributes.NewAttributesServiceImpl, + wire.Bind(new(attributes.AttributesService), new(*attributes.AttributesServiceImpl)), + repository.NewAttributesRepositoryImpl, + wire.Bind(new(repository.AttributesRepository), new(*repository.AttributesRepositoryImpl)), + + router.NewCommonRouterImpl, + wire.Bind(new(router.CommonRouter), new(*router.CommonRouterImpl)), + restHandler.NewCommonRestHanlderImpl, + wire.Bind(new(restHandler.CommonRestHanlder), new(*restHandler.CommonRestHanlderImpl)), + + router.NewScopedVariableRouterImpl, + wire.Bind(new(router.ScopedVariableRouter), new(*router.ScopedVariableRouterImpl)), + scopedVariable.NewScopedVariableRestHandlerImpl, + wire.Bind(new(scopedVariable.ScopedVariableRestHandler), new(*scopedVariable.ScopedVariableRestHandlerImpl)), + + router.NewTelemetryRouterImpl, + wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), + restHandler.NewTelemetryRestHandlerImpl, + wire.Bind(new(restHandler.TelemetryRestHandler), new(*restHandler.TelemetryRestHandlerImpl)), + telemetry.NewPosthogClient, + + telemetry.NewTelemetryEventClientImplExtended, + wire.Bind(new(telemetry.TelemetryEventClient), new(*telemetry.TelemetryEventClientImplExtended)), + + router.NewBulkUpdateRouterImpl, + wire.Bind(new(router.BulkUpdateRouter), new(*router.BulkUpdateRouterImpl)), + restHandler.NewBulkUpdateRestHandlerImpl, + wire.Bind(new(restHandler.BulkUpdateRestHandler), new(*restHandler.BulkUpdateRestHandlerImpl)), + + router.NewCoreAppRouterImpl, + wire.Bind(new(router.CoreAppRouter), new(*router.CoreAppRouterImpl)), + restHandler.NewCoreAppRestHandlerImpl, + wire.Bind(new(restHandler.CoreAppRestHandler), new(*restHandler.CoreAppRestHandlerImpl)), + + // Webhook + repository.NewGitHostRepositoryImpl, + wire.Bind(new(repository.GitHostRepository), new(*repository.GitHostRepositoryImpl)), + restHandler.NewGitHostRestHandlerImpl, + wire.Bind(new(restHandler.GitHostRestHandler), new(*restHandler.GitHostRestHandlerImpl)), + restHandler.NewWebhookEventHandlerImpl, + wire.Bind(new(restHandler.WebhookEventHandler), new(*restHandler.WebhookEventHandlerImpl)), + router.NewGitHostRouterImpl, + wire.Bind(new(router.GitHostRouter), new(*router.GitHostRouterImpl)), + router.NewWebhookListenerRouterImpl, + wire.Bind(new(router.WebhookListenerRouter), new(*router.WebhookListenerRouterImpl)), + git.NewWebhookSecretValidatorImpl, + wire.Bind(new(git.WebhookSecretValidator), new(*git.WebhookSecretValidatorImpl)), + pipeline.NewGitHostConfigImpl, + wire.Bind(new(pipeline.GitHostConfig), new(*pipeline.GitHostConfigImpl)), + repository.NewWebhookEventDataRepositoryImpl, + wire.Bind(new(repository.WebhookEventDataRepository), new(*repository.WebhookEventDataRepositoryImpl)), + pipeline.NewWebhookEventDataConfigImpl, + wire.Bind(new(pipeline.WebhookEventDataConfig), new(*pipeline.WebhookEventDataConfigImpl)), + webhook.NewWebhookDataRestHandlerImpl, + wire.Bind(new(webhook.WebhookDataRestHandler), new(*webhook.WebhookDataRestHandlerImpl)), + + app3.NewAppRouterImpl, + wire.Bind(new(app3.AppRouter), new(*app3.AppRouterImpl)), + appInfo2.NewAppInfoRouterImpl, + wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), + appInfo.NewAppInfoRestHandlerImpl, + wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), + + app.NewAppCrudOperationServiceImpl, + wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), + pipelineConfig.NewAppLabelRepositoryImpl, + wire.Bind(new(pipelineConfig.AppLabelRepository), new(*pipelineConfig.AppLabelRepositoryImpl)), + + delete2.NewDeleteServiceExtendedImpl, + wire.Bind(new(delete2.DeleteService), new(*delete2.DeleteServiceExtendedImpl)), + delete2.NewDeleteServiceFullModeImpl, + wire.Bind(new(delete2.DeleteServiceFullMode), new(*delete2.DeleteServiceFullModeImpl)), + + deployment3.NewFullModeDeploymentServiceImpl, + wire.Bind(new(deployment3.FullModeDeploymentService), new(*deployment3.FullModeDeploymentServiceImpl)), + // util2.NewGoJsonSchemaCustomFormatChecker, + + //history starts + history.NewPipelineHistoryRestHandlerImpl, + wire.Bind(new(history.PipelineHistoryRestHandler), new(*history.PipelineHistoryRestHandlerImpl)), + + repository3.NewConfigMapHistoryRepositoryImpl, + wire.Bind(new(repository3.ConfigMapHistoryRepository), new(*repository3.ConfigMapHistoryRepositoryImpl)), + repository3.NewDeploymentTemplateHistoryRepositoryImpl, + wire.Bind(new(repository3.DeploymentTemplateHistoryRepository), new(*repository3.DeploymentTemplateHistoryRepositoryImpl)), + repository3.NewPrePostCiScriptHistoryRepositoryImpl, + wire.Bind(new(repository3.PrePostCiScriptHistoryRepository), new(*repository3.PrePostCiScriptHistoryRepositoryImpl)), + repository3.NewPrePostCdScriptHistoryRepositoryImpl, + wire.Bind(new(repository3.PrePostCdScriptHistoryRepository), new(*repository3.PrePostCdScriptHistoryRepositoryImpl)), + repository3.NewPipelineStrategyHistoryRepositoryImpl, + wire.Bind(new(repository3.PipelineStrategyHistoryRepository), new(*repository3.PipelineStrategyHistoryRepositoryImpl)), + repository3.NewGitMaterialHistoryRepositoyImpl, + wire.Bind(new(repository3.GitMaterialHistoryRepository), new(*repository3.GitMaterialHistoryRepositoryImpl)), + + history3.NewCiTemplateHistoryServiceImpl, + wire.Bind(new(history3.CiTemplateHistoryService), new(*history3.CiTemplateHistoryServiceImpl)), + + repository3.NewCiTemplateHistoryRepositoryImpl, + wire.Bind(new(repository3.CiTemplateHistoryRepository), new(*repository3.CiTemplateHistoryRepositoryImpl)), + + history3.NewCiPipelineHistoryServiceImpl, + wire.Bind(new(history3.CiPipelineHistoryService), new(*history3.CiPipelineHistoryServiceImpl)), + + repository3.NewCiPipelineHistoryRepositoryImpl, + wire.Bind(new(repository3.CiPipelineHistoryRepository), new(*repository3.CiPipelineHistoryRepositoryImpl)), + + history3.NewPrePostCdScriptHistoryServiceImpl, + wire.Bind(new(history3.PrePostCdScriptHistoryService), new(*history3.PrePostCdScriptHistoryServiceImpl)), + history3.NewPrePostCiScriptHistoryServiceImpl, + wire.Bind(new(history3.PrePostCiScriptHistoryService), new(*history3.PrePostCiScriptHistoryServiceImpl)), + history3.NewDeploymentTemplateHistoryServiceImpl, + wire.Bind(new(history3.DeploymentTemplateHistoryService), new(*history3.DeploymentTemplateHistoryServiceImpl)), + history3.NewConfigMapHistoryServiceImpl, + wire.Bind(new(history3.ConfigMapHistoryService), new(*history3.ConfigMapHistoryServiceImpl)), + history3.NewPipelineStrategyHistoryServiceImpl, + wire.Bind(new(history3.PipelineStrategyHistoryService), new(*history3.PipelineStrategyHistoryServiceImpl)), + history3.NewGitMaterialHistoryServiceImpl, + wire.Bind(new(history3.GitMaterialHistoryService), new(*history3.GitMaterialHistoryServiceImpl)), + + history3.NewDeployedConfigurationHistoryServiceImpl, + wire.Bind(new(history3.DeployedConfigurationHistoryService), new(*history3.DeployedConfigurationHistoryServiceImpl)), + // history ends + + // plugin starts + repository6.NewGlobalPluginRepository, + wire.Bind(new(repository6.GlobalPluginRepository), new(*repository6.GlobalPluginRepositoryImpl)), + + plugin.NewGlobalPluginService, + wire.Bind(new(plugin.GlobalPluginService), new(*plugin.GlobalPluginServiceImpl)), + + restHandler.NewGlobalPluginRestHandler, + wire.Bind(new(restHandler.GlobalPluginRestHandler), new(*restHandler.GlobalPluginRestHandlerImpl)), + + router.NewGlobalPluginRouter, + wire.Bind(new(router.GlobalPluginRouter), new(*router.GlobalPluginRouterImpl)), + + repository5.NewPipelineStageRepository, + wire.Bind(new(repository5.PipelineStageRepository), new(*repository5.PipelineStageRepositoryImpl)), + + pipeline.NewPipelineStageService, + wire.Bind(new(pipeline.PipelineStageService), new(*pipeline.PipelineStageServiceImpl)), + // plugin ends + + connection.NewArgoCDConnectionManagerImpl, + wire.Bind(new(connection.ArgoCDConnectionManager), new(*connection.ArgoCDConnectionManagerImpl)), + argo.NewArgoUserServiceImpl, + wire.Bind(new(argo.ArgoUserService), new(*argo.ArgoUserServiceImpl)), + //util2.GetEnvironmentVariables, + // AuthWireSet, + + cron.NewCdApplicationStatusUpdateHandlerImpl, + wire.Bind(new(cron.CdApplicationStatusUpdateHandler), new(*cron.CdApplicationStatusUpdateHandlerImpl)), + + // app_status + appStatusRepo.NewAppStatusRepositoryImpl, + wire.Bind(new(appStatusRepo.AppStatusRepository), new(*appStatusRepo.AppStatusRepositoryImpl)), + appStatus.NewAppStatusServiceImpl, + wire.Bind(new(appStatus.AppStatusService), new(*appStatus.AppStatusServiceImpl)), + // app_status ends + + cron.GetCiWorkflowStatusUpdateConfig, + cron.NewCiStatusUpdateCronImpl, + wire.Bind(new(cron.CiStatusUpdateCron), new(*cron.CiStatusUpdateCronImpl)), + + cron.GetCiTriggerCronConfig, + cron.NewCiTriggerCronImpl, + wire.Bind(new(cron.CiTriggerCron), new(*cron.CiTriggerCronImpl)), + + status2.NewPipelineStatusTimelineRestHandlerImpl, + wire.Bind(new(status2.PipelineStatusTimelineRestHandler), new(*status2.PipelineStatusTimelineRestHandlerImpl)), + + status.NewPipelineStatusTimelineServiceImpl, + wire.Bind(new(status.PipelineStatusTimelineService), new(*status.PipelineStatusTimelineServiceImpl)), + + router.NewUserAttributesRouterImpl, + wire.Bind(new(router.UserAttributesRouter), new(*router.UserAttributesRouterImpl)), + restHandler.NewUserAttributesRestHandlerImpl, + wire.Bind(new(restHandler.UserAttributesRestHandler), new(*restHandler.UserAttributesRestHandlerImpl)), + attributes.NewUserAttributesServiceImpl, + wire.Bind(new(attributes.UserAttributesService), new(*attributes.UserAttributesServiceImpl)), + repository.NewUserAttributesRepositoryImpl, + wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)), + pipelineConfig.NewPipelineStatusTimelineRepositoryImpl, + wire.Bind(new(pipelineConfig.PipelineStatusTimelineRepository), new(*pipelineConfig.PipelineStatusTimelineRepositoryImpl)), + wire.Bind(new(pipeline.DeploymentConfigService), new(*pipeline.DeploymentConfigServiceImpl)), + pipeline.NewDeploymentConfigServiceImpl, + pipelineConfig.NewCiTemplateOverrideRepositoryImpl, + wire.Bind(new(pipelineConfig.CiTemplateOverrideRepository), new(*pipelineConfig.CiTemplateOverrideRepositoryImpl)), + pipelineConfig.NewCiBuildConfigRepositoryImpl, + wire.Bind(new(pipelineConfig.CiBuildConfigRepository), new(*pipelineConfig.CiBuildConfigRepositoryImpl)), + pipeline.NewCiBuildConfigServiceImpl, + wire.Bind(new(pipeline.CiBuildConfigService), new(*pipeline.CiBuildConfigServiceImpl)), + pipeline.NewCiTemplateServiceImpl, + wire.Bind(new(pipeline.CiTemplateService), new(*pipeline.CiTemplateServiceImpl)), + router.NewGlobalCMCSRouterImpl, + wire.Bind(new(router.GlobalCMCSRouter), new(*router.GlobalCMCSRouterImpl)), + restHandler.NewGlobalCMCSRestHandlerImpl, + wire.Bind(new(restHandler.GlobalCMCSRestHandler), new(*restHandler.GlobalCMCSRestHandlerImpl)), + pipeline.NewGlobalCMCSServiceImpl, + wire.Bind(new(pipeline.GlobalCMCSService), new(*pipeline.GlobalCMCSServiceImpl)), + repository.NewGlobalCMCSRepositoryImpl, + wire.Bind(new(repository.GlobalCMCSRepository), new(*repository.GlobalCMCSRepositoryImpl)), + + // chartRepoRepository.NewGlobalStrategyMetadataRepositoryImpl, + // wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataRepository), new(*chartRepoRepository.GlobalStrategyMetadataRepositoryImpl)), + chartRepoRepository.NewGlobalStrategyMetadataChartRefMappingRepositoryImpl, + wire.Bind(new(chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepository), new(*chartRepoRepository.GlobalStrategyMetadataChartRefMappingRepositoryImpl)), + + status.NewPipelineStatusTimelineResourcesServiceImpl, + wire.Bind(new(status.PipelineStatusTimelineResourcesService), new(*status.PipelineStatusTimelineResourcesServiceImpl)), + pipelineConfig.NewPipelineStatusTimelineResourcesRepositoryImpl, + wire.Bind(new(pipelineConfig.PipelineStatusTimelineResourcesRepository), new(*pipelineConfig.PipelineStatusTimelineResourcesRepositoryImpl)), + + status.NewPipelineStatusSyncDetailServiceImpl, + wire.Bind(new(status.PipelineStatusSyncDetailService), new(*status.PipelineStatusSyncDetailServiceImpl)), + pipelineConfig.NewPipelineStatusSyncDetailRepositoryImpl, + wire.Bind(new(pipelineConfig.PipelineStatusSyncDetailRepository), new(*pipelineConfig.PipelineStatusSyncDetailRepositoryImpl)), + + repository7.NewK8sResourceHistoryRepositoryImpl, + wire.Bind(new(repository7.K8sResourceHistoryRepository), new(*repository7.K8sResourceHistoryRepositoryImpl)), + + kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl, + wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)), + + router.NewResourceGroupingRouterImpl, + wire.Bind(new(router.ResourceGroupingRouter), new(*router.ResourceGroupingRouterImpl)), + restHandler.NewResourceGroupRestHandlerImpl, + wire.Bind(new(restHandler.ResourceGroupRestHandler), new(*restHandler.ResourceGroupRestHandlerImpl)), + resourceGroup2.NewResourceGroupServiceImpl, + wire.Bind(new(resourceGroup2.ResourceGroupService), new(*resourceGroup2.ResourceGroupServiceImpl)), + resourceGroup.NewResourceGroupRepositoryImpl, + wire.Bind(new(resourceGroup.ResourceGroupRepository), new(*resourceGroup.ResourceGroupRepositoryImpl)), + resourceGroup.NewResourceGroupMappingRepositoryImpl, + wire.Bind(new(resourceGroup.ResourceGroupMappingRepository), new(*resourceGroup.ResourceGroupMappingRepositoryImpl)), + executors.NewArgoWorkflowExecutorImpl, + wire.Bind(new(executors.ArgoWorkflowExecutor), new(*executors.ArgoWorkflowExecutorImpl)), + executors.NewSystemWorkflowExecutorImpl, + wire.Bind(new(executors.SystemWorkflowExecutor), new(*executors.SystemWorkflowExecutorImpl)), + repository5.NewManifestPushConfigRepository, + wire.Bind(new(repository5.ManifestPushConfigRepository), new(*repository5.ManifestPushConfigRepositoryImpl)), + app.NewGitOpsManifestPushServiceImpl, + wire.Bind(new(app.GitOpsPushService), new(*app.GitOpsManifestPushServiceImpl)), + + // start: docker registry wire set injection + router.NewDockerRegRouterImpl, + wire.Bind(new(router.DockerRegRouter), new(*router.DockerRegRouterImpl)), + restHandler.NewDockerRegRestHandlerExtendedImpl, + wire.Bind(new(restHandler.DockerRegRestHandler), new(*restHandler.DockerRegRestHandlerExtendedImpl)), + pipeline.NewDockerRegistryConfigImpl, + wire.Bind(new(pipeline.DockerRegistryConfig), new(*pipeline.DockerRegistryConfigImpl)), + dockerRegistry.NewDockerRegistryIpsConfigServiceImpl, + wire.Bind(new(dockerRegistry.DockerRegistryIpsConfigService), new(*dockerRegistry.DockerRegistryIpsConfigServiceImpl)), + dockerRegistryRepository.NewDockerArtifactStoreRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.DockerArtifactStoreRepository), new(*dockerRegistryRepository.DockerArtifactStoreRepositoryImpl)), + dockerRegistryRepository.NewDockerRegistryIpsConfigRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.DockerRegistryIpsConfigRepository), new(*dockerRegistryRepository.DockerRegistryIpsConfigRepositoryImpl)), + dockerRegistryRepository.NewOCIRegistryConfigRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.OCIRegistryConfigRepository), new(*dockerRegistryRepository.OCIRegistryConfigRepositoryImpl)), + + // end: docker registry wire set injection + + resourceQualifiers.NewQualifiersMappingRepositoryImpl, + wire.Bind(new(resourceQualifiers.QualifiersMappingRepository), new(*resourceQualifiers.QualifiersMappingRepositoryImpl)), + + resourceQualifiers.NewQualifierMappingServiceImpl, + wire.Bind(new(resourceQualifiers.QualifierMappingService), new(*resourceQualifiers.QualifierMappingServiceImpl)), + + repository9.NewDevtronResourceSearchableKeyRepositoryImpl, + wire.Bind(new(repository9.DevtronResourceSearchableKeyRepository), new(*repository9.DevtronResourceSearchableKeyRepositoryImpl)), + + devtronResource.NewDevtronResourceSearchableKeyServiceImpl, + wire.Bind(new(devtronResource.DevtronResourceSearchableKeyService), new(*devtronResource.DevtronResourceSearchableKeyServiceImpl)), + + argocdServer.NewArgoClientWrapperServiceImpl, + wire.Bind(new(argocdServer.ArgoClientWrapperService), new(*argocdServer.ArgoClientWrapperServiceImpl)), + + pipeline.NewPluginInputVariableParserImpl, + wire.Bind(new(pipeline.PluginInputVariableParser), new(*pipeline.PluginInputVariableParserImpl)), + + pipeline.NewPipelineConfigListenerServiceImpl, + wire.Bind(new(pipeline.PipelineConfigListenerService), new(*pipeline.PipelineConfigListenerServiceImpl)), + cron2.NewCronLoggerImpl, + + imageDigestPolicy.NewImageDigestPolicyServiceImpl, + wire.Bind(new(imageDigestPolicy.ImageDigestPolicyService), new(*imageDigestPolicy.ImageDigestPolicyServiceImpl)), +) From e5faa7b978eea9a172f96510cc355154d1d032f7 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Mon, 26 Feb 2024 18:20:14 +0530 Subject: [PATCH 61/83] refactoring done --- .../AppStoreDeploymentRestHandler.go | 25 +++++++++++++------ api/appStore/values/AppStoreValuesRouter.go | 1 + pkg/appStore/bean/bean.go | 3 +++ util/rbac/EnforcerUtilHelm.go | 16 ++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index 882108592f..d7fd36df1b 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -595,13 +595,24 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res handler.Logger.Errorw("service err, InstalledAppId", "err", err, "InstalledAppId", request.InstalledAppId) common.WriteJsonResp(w, fmt.Errorf("Unable to fetch installed app details"), nil, http.StatusBadRequest) } - rbacObjectForCurrentProject, rbacObjectForCurrentProject2 := handler.enforcerUtilHelm.GetHelmObjectByClusterIdNamespaceAndAppName(installedApp.ClusterId, installedApp.Namespace, installedApp.AppName) - ok := handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForCurrentProject) || handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForCurrentProject2) - rbacObjectForRequestedProject := handler.enforcerUtilHelm.GetHelmObjectByTeamIdAndClusterId(request.TeamId, installedApp.ClusterId, installedApp.Namespace, installedApp.AppName) - ok = handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForRequestedProject) - if !ok { - common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden) - return + if installedApp.IsVirtualEnvironment { + rbacObjectForCurrentProject, _ := handler.enforcerUtilHelm.GetAppRBACNameByInstalledAppId(request.InstalledAppId) + ok := handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForCurrentProject) + rbacObjectForRequestedProject := handler.enforcerUtilHelm.GetAppRBACNameByInstalledAppIdAndTeamId(request.InstalledAppId, request.TeamId) + ok = handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForRequestedProject) + if !ok { + common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden) + return + } + } else { + rbacObjectForCurrentProject, rbacObjectForCurrentProject2 := handler.enforcerUtilHelm.GetHelmObjectByClusterIdNamespaceAndAppName(installedApp.ClusterId, installedApp.Namespace, installedApp.AppName) + ok := handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForCurrentProject) || handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForCurrentProject2) + rbacObjectForRequestedProject := handler.enforcerUtilHelm.GetHelmObjectByTeamIdAndClusterId(request.TeamId, installedApp.ClusterId, installedApp.Namespace, installedApp.AppName) + ok = handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObjectForRequestedProject) + if !ok { + common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden) + return + } } } err = handler.appStoreDeploymentService.UpdateProjectHelmApp(&request) diff --git a/api/appStore/values/AppStoreValuesRouter.go b/api/appStore/values/AppStoreValuesRouter.go index 659e265036..55ec8f91d4 100644 --- a/api/appStore/values/AppStoreValuesRouter.go +++ b/api/appStore/values/AppStoreValuesRouter.go @@ -56,4 +56,5 @@ func (router AppStoreValuesRouterImpl) Init(configRouter *mux.Router) { configRouter.Path("/chart/selected/metadata"). HandlerFunc(router.appStoreValuesRestHandler.GetSelectedChartMetadata).Methods("POST") + } diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 0549ded071..3964559361 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -99,6 +99,9 @@ type InstallAppVersionDTO struct { DeploymentAppType string `json:"deploymentAppType"` // TODO: instead of string, use enum AcdPartialDelete bool `json:"acdPartialDelete"` InstalledAppDeleteResponse *InstalledAppDeleteResponseDTO `json:"deleteResponse,omitempty"` + UpdatedOn time.Time `json:"updatedOn"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` + HelmPackageName string `json:"helmPackageName"` AppStoreApplicationVersionId int } diff --git a/util/rbac/EnforcerUtilHelm.go b/util/rbac/EnforcerUtilHelm.go index 2203f2b976..7084732fcc 100644 --- a/util/rbac/EnforcerUtilHelm.go +++ b/util/rbac/EnforcerUtilHelm.go @@ -15,6 +15,7 @@ type EnforcerUtilHelm interface { GetHelmObjectByTeamIdAndClusterId(teamId int, clusterId int, namespace string, appName string) string GetHelmObjectByClusterIdNamespaceAndAppName(clusterId int, namespace string, appName string) (string, string) GetAppRBACNameByInstalledAppId(installedAppId int) (string, string) + GetAppRBACNameByInstalledAppIdAndTeamId(installedAppId, teamId int) string } type EnforcerUtilHelmImpl struct { logger *zap.SugaredLogger @@ -140,3 +141,18 @@ func (impl EnforcerUtilHelmImpl) GetAppRBACNameByInstalledAppId(installedAppVers return rbacOne, "" } + +func (impl EnforcerUtilHelmImpl) GetAppRBACNameByInstalledAppIdAndTeamId(installedAppId, teamId int) string { + installedApp, err := impl.InstalledAppRepository.GetInstalledApp(installedAppId) + if err != nil { + impl.logger.Errorw("error in fetching installed app version data", "err", err) + return fmt.Sprintf("%s/%s/%s", "", "", "") + } + project, err := impl.teamRepository.FindOne(teamId) + if err != nil { + impl.logger.Errorw("error in fetching project by teamID", "err", err) + return fmt.Sprintf("%s/%s/%s", "", "", "") + } + rbac := fmt.Sprintf("%s/%s/%s", project.Name, installedApp.Environment.EnvironmentIdentifier, installedApp.App.AppName) + return rbac +} From f0309e0bc54d943edb84533f012a3dccd188a2f2 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Mon, 26 Feb 2024 18:20:16 +0530 Subject: [PATCH 62/83] chore: fixed main merge changes --- .../installedApp/service/AppStoreDeploymentDBService.go | 1 + pkg/pipeline/DeploymentPipelineConfigService.go | 4 ++-- pkg/workflow/status/WorkflowStatusService.go | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index 290c8bcfb7..5c7765f814 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -435,6 +435,7 @@ func (impl *AppStoreDeploymentDBServiceImpl) createAppForAppStore(createRequest if activeApp != nil && activeApp.Id > 0 { impl.logger.Infow(" app already exists", "name", createRequest.AppName) err = &util.ApiError{ + HttpStatusCode: http.StatusBadRequest, Code: constants.AppAlreadyExists.Code, InternalMessage: "app already exists", UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 54bed48156..4813c6b708 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -380,7 +380,7 @@ func (impl *CdPipelineConfigServiceImpl) CreateCdPipelines(pipelineCreateRequest impl.logger.Errorw("app not found", "err", err, "appId", pipelineCreateRequest.AppId) return nil, err } - _, err = impl.ValidateCDPipelineRequest(pipelineCreateRequest) + _, err = impl.validateCDPipelineRequest(pipelineCreateRequest) if err != nil { return nil, err } @@ -1501,7 +1501,7 @@ func (impl *CdPipelineConfigServiceImpl) GetEnvironmentListForAutocompleteFilter return result, nil } -func (impl *CdPipelineConfigServiceImpl) ValidateCDPipelineRequest(pipelineCreateRequest *bean.CdPipelines) (bool, error) { +func (impl *CdPipelineConfigServiceImpl) validateCDPipelineRequest(pipelineCreateRequest *bean.CdPipelines) (bool, error) { envPipelineMap := make(map[int]string) for _, pipeline := range pipelineCreateRequest.Pipelines { if envPipelineMap[pipeline.EnvironmentId] != "" { diff --git a/pkg/workflow/status/WorkflowStatusService.go b/pkg/workflow/status/WorkflowStatusService.go index e121e83bd8..e92c7f0cd6 100644 --- a/pkg/workflow/status/WorkflowStatusService.go +++ b/pkg/workflow/status/WorkflowStatusService.go @@ -364,10 +364,9 @@ func (impl *WorkflowStatusServiceImpl) UpdatePipelineTimelineAndStatusByLiveAppl if isSucceeded { // handling deployment success event // updating cdWfr status - installedAppVersionHistory.Status = pipelineConfig.WorkflowSucceeded - installedAppVersionHistory.FinishedOn = time.Now() - installedAppVersionHistory.UpdatedOn = time.Now() - installedAppVersionHistory.UpdatedBy = 1 + installedAppVersionHistory.SetStatus(pipelineConfig.WorkflowSucceeded) + installedAppVersionHistory.SetFinishedOn() + installedAppVersionHistory.UpdateAuditLog(1) installedAppVersionHistory, err = impl.installedAppVersionHistoryRepository.UpdateInstalledAppVersionHistory(installedAppVersionHistory, nil) if err != nil { impl.logger.Errorw("error on update installedAppVersionHistory", "installedAppVersionHistory", installedAppVersionHistory, "err", err) From 69049baac00dd40b3b8cff514d28006cd7692f07 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Mon, 26 Feb 2024 19:25:05 +0530 Subject: [PATCH 63/83] code refactored --- api/appStore/InstalledAppRestHandler.go | 11 ++-- api/bean/AppView.go | 40 +++++++++++--- pkg/appStore/adapter/Adapter.go | 40 +++++++++----- pkg/appStore/bean/bean.go | 53 +++++++++++++++++++ .../repository/InstalledAppModels.go | 1 + .../repository/InstalledAppRepository.go | 11 +++- .../service/EAMode/InstalledAppDBService.go | 31 ++++++----- pkg/bean/app.go | 7 +-- 8 files changed, 153 insertions(+), 41 deletions(-) diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index 66a23c0a05..af2bd45877 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -33,7 +33,6 @@ import ( "time" bean2 "github.com/devtron-labs/devtron/api/bean" - openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/cron" @@ -270,7 +269,7 @@ func (handler InstalledAppRestHandlerImpl) GetAllInstalledApp(w http.ResponseWri return } - appIdToAppMap := make(map[string]openapi.HelmApp) + appIdToAppMap := make(map[string]appStoreBean.HelmAppDetails) //the value of this map is array of strings because the GetHelmObjectByAppNameAndEnvId method may return "//" for error cases //so different apps may contain same object, to handle that we are using (map[string] []string) @@ -326,7 +325,7 @@ func (handler InstalledAppRestHandlerImpl) GetAllInstalledApp(w http.ResponseWri } } - authorizedApps := make([]openapi.HelmApp, 0) + authorizedApps := make([]appStoreBean.HelmAppDetails, 0) for appId, _ := range authorizedAppIdSet { authorizedApp := appIdToAppMap[appId] authorizedApps = append(authorizedApps, authorizedApp) @@ -726,6 +725,10 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri common.WriteJsonResp(w, err, "App not found in database", http.StatusBadRequest) return } + if installedApp.Environment.IsVirtualEnvironment { + common.WriteJsonResp(w, nil, nil, http.StatusOK) + return + } token := r.Header.Get("token") object, object2 := handler.enforcerUtil.GetHelmObjectByAppNameAndEnvId(installedApp.App.AppName, installedApp.EnvironmentId) var ok bool @@ -756,7 +759,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri apiError, ok := err.(*util2.ApiError) if ok && apiError != nil { if apiError.Code == constants.AppDetailResourceTreeNotFound && installedApp.DeploymentAppDeleteRequest == true { - // TODO refactoring: should be performed in go routine + // TODO refactoring: should be performed through nats err = handler.appStoreDeploymentService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId) appDeleteErr, appDeleteErrOk := err.(*util2.ApiError) if appDeleteErrOk && appDeleteErr != nil { diff --git a/api/bean/AppView.go b/api/bean/AppView.go index 85054ab6b7..27a1b60317 100644 --- a/api/bean/AppView.go +++ b/api/bean/AppView.go @@ -44,13 +44,14 @@ type JobContainerResponse struct { } type DeploymentGroupDTO struct { - Id int `json:"id"` - Name string `json:"name"` - AppCount int `json:"appCount"` - NoOfApps string `json:"noOfApps"` - EnvironmentId int `json:"environmentId"` - CiPipelineId int `json:"ciPipelineId"` - CiMaterialDTOs []CiMaterialDTO `json:"ciMaterialDTOs"` + Id int `json:"id"` + Name string `json:"name"` + AppCount int `json:"appCount"` + NoOfApps string `json:"noOfApps"` + EnvironmentId int `json:"environmentId"` + CiPipelineId int `json:"ciPipelineId"` + CiMaterialDTOs []CiMaterialDTO `json:"ciMaterialDTOs"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` } type CiMaterialDTO struct { @@ -136,6 +137,7 @@ type AppEnvironmentContainer struct { TeamName string `json:"teamName"` Description string `json:"description" validate:"max=40"` TotalCount int `json:"-"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` } type DeploymentDetailContainer struct { @@ -173,7 +175,11 @@ type DeploymentDetailContainer struct { IpsAccessProvided bool `json:"ipsAccessProvided"` DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"` Description string `json:"description" validate:"max=40"` + UserApprovalConfig string `json:"userApprovalConfig"` IsVirtualEnvironment bool `json:"isVirtualEnvironment"` + Image string `json:"image"` + ImageTag string `json:"imageTag"` + HelmPackageName string `json:"helmPackageName"` HelmReleaseInstallStatus string `json:"-"` } @@ -194,6 +200,26 @@ type Notes struct { Notes string `json:"gitOpsNotes,omitempty"` } +type EnvironmentForDependency struct { + AppStatus string `json:"appStatus"` //this is not the status of environment , this make sense with a specific app only + AppName string `json:"appName"` + AppId int `json:"appId"` + EnvironmentId int `json:"environmentId"` + EnvironmentName string `json:"environmentName"` + Prod bool `json:"prod"` + ChartRefId int `json:"chartRefId"` + LastDeployed string `json:"lastDeployed"` + LastDeployedBy string `json:"lastDeployedBy"` + LastDeployedImage string `json:"lastDeployedImage"` + DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"` + Description string `json:"description" validate:"max=40"` + IsVirtualEnvironment bool `json:"isVirtualEnvironment"` + ClusterId int `json:"clusterId"` + PipelineId int `json:"pipelineId"` + PipelineName string `json:"pipelineName"` + LatestCdWorkflowRunnerId int `json:"latestCdWorkflowRunnerId,omitempty"` +} + type Environment struct { AppStatus string `json:"appStatus"` //this is not the status of environment , this make sense with a specific app only EnvironmentId int `json:"environmentId"` diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go index e3a49dc680..4f4035c04b 100644 --- a/pkg/appStore/adapter/Adapter.go +++ b/pkg/appStore/adapter/Adapter.go @@ -8,7 +8,9 @@ import ( appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" - "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" + "github.com/devtron-labs/devtron/pkg/bean" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" + "time" ) // NewInstallAppModel is used to generate new repository.InstalledApps model to be saved; @@ -142,6 +144,8 @@ func GenerateInstallAppVersionDTO(chart *repository.InstalledApps, installedAppV }, }, AppStoreApplicationVersionId: installedAppVersion.AppStoreApplicationVersionId, + UpdatedOn: installedAppVersion.UpdatedOn, + IsVirtualEnvironment: chart.Environment.IsVirtualEnvironment, } } @@ -149,20 +153,30 @@ func GenerateInstallAppVersionDTO(chart *repository.InstalledApps, installedAppV // Note: It only generates a minimal DTO and doesn't include repository.InstalledAppVersions data func GenerateInstallAppVersionMinDTO(chart *repository.InstalledApps) *appStoreBean.InstallAppVersionDTO { return &appStoreBean.InstallAppVersionDTO{ - EnvironmentId: chart.EnvironmentId, - InstalledAppId: chart.Id, - AppId: chart.AppId, - AppOfferingMode: chart.App.AppOfferingMode, - ClusterId: chart.Environment.ClusterId, - Namespace: chart.Environment.Namespace, - AppName: chart.App.AppName, - EnvironmentName: chart.Environment.Name, - TeamId: chart.App.TeamId, - TeamName: chart.App.Team.Name, - DeploymentAppType: chart.DeploymentAppType, + EnvironmentId: chart.EnvironmentId, + InstalledAppId: chart.Id, + AppId: chart.AppId, + AppOfferingMode: chart.App.AppOfferingMode, + ClusterId: chart.Environment.ClusterId, + Namespace: chart.Environment.Namespace, + AppName: chart.App.AppName, + EnvironmentName: chart.Environment.Name, + TeamId: chart.App.TeamId, + TeamName: chart.App.Team.Name, + DeploymentAppType: chart.DeploymentAppType, + IsVirtualEnvironment: chart.Environment.IsVirtualEnvironment, } } +func GetGeneratedHelmPackageName(appName, envName string, updatedOn time.Time) string { + timeStampTag := updatedOn.Format(bean.LayoutDDMMYY_HHMM12hr) + return fmt.Sprintf( + "%s-%s-%s (GMT)", + appName, + envName, + timeStampTag) +} + // NewInstalledAppVersionModel will generate a new repository.InstalledAppVersions for the given appStoreBean.InstallAppVersionDTO func NewInstalledAppVersionModel(request *appStoreBean.InstallAppVersionDTO) *repository.InstalledAppVersions { installedAppVersion := &repository.InstalledAppVersions{ @@ -191,7 +205,7 @@ func UpdateInstalledAppVersionModel(model *repository.InstalledAppVersions, requ } // UpdateAdditionalEnvDetails update cluster.EnvironmentBean data into the same InstallAppVersionDTO -func UpdateAdditionalEnvDetails(request *appStoreBean.InstallAppVersionDTO, envBean *bean.EnvironmentBean) { +func UpdateAdditionalEnvDetails(request *appStoreBean.InstallAppVersionDTO, envBean *bean2.EnvironmentBean) { if request == nil { return } diff --git a/pkg/appStore/bean/bean.go b/pkg/appStore/bean/bean.go index 3964559361..5a5ffa36f4 100644 --- a/pkg/appStore/bean/bean.go +++ b/pkg/appStore/bean/bean.go @@ -20,6 +20,7 @@ package appStoreBean import ( "encoding/json" "fmt" + openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "time" ) @@ -383,6 +384,8 @@ type ChartComponent struct { } const ( + DEFAULT_CLUSTER_ID = 1 + DEFAULT_NAMESPACE = "default" DEFAULT_ENVIRONMENT_OR_NAMESPACE_OR_PROJECT = "devtron" CLUSTER_COMPONENT_DIR_PATH = "/cluster/component" HELM_RELEASE_STATUS_FAILED = "Failed" @@ -393,3 +396,53 @@ const ( COULD_NOT_FETCH_APP_NAME_AND_ENV_NAME_ERR = "could not fetch app name or environment name" APP_NOT_DELETED_YET_ERROR = "App Not Yet Deleted." ) + +type EnvironmentDetails struct { + EnvironmentName *string `json:"environmentName,omitempty"` + // id in which app is deployed + EnvironmentId *int32 `json:"environmentId,omitempty"` + // namespace corresponding to the environemnt + Namespace *string `json:"namespace,omitempty"` + // if given environemnt is marked as production or not, nullable + IsPrduction *bool `json:"isPrduction,omitempty"` + // cluster corresponding to the environemt where application is deployed + ClusterName *string `json:"clusterName,omitempty"` + // clusterId corresponding to the environemt where application is deployed + ClusterId *int32 `json:"clusterId,omitempty"` + + IsVirtualEnvironment *bool `json:"isVirtualEnvironment"` +} + +type HelmAppDetails struct { + // time when this application was last deployed/updated + LastDeployedAt *time.Time `json:"lastDeployedAt,omitempty"` + // name of the helm application/helm release name + AppName *string `json:"appName,omitempty"` + // unique identifier for app + AppId *string `json:"appId,omitempty"` + // name of the chart + ChartName *string `json:"chartName,omitempty"` + // url/location of the chart icon + ChartAvatar *string `json:"chartAvatar,omitempty"` + // unique identifier for the project, APP with no project will have id `0` + ProjectId *int32 `json:"projectId,omitempty"` + // chart version + ChartVersion *string `json:"chartVersion,omitempty"` + EnvironmentDetail *EnvironmentDetails `json:"environmentDetail,omitempty"` + AppStatus *string `json:"appStatus,omitempty"` +} + +type AppListDetail struct { + // clusters to which result corresponds + ClusterIds *[]int32 `json:"clusterIds,omitempty"` + // application type inside the array + ApplicationType *string `json:"applicationType,omitempty"` + // if data fetch for that cluster produced error + Errored *bool `json:"errored,omitempty"` + // error msg if client failed to fetch + ErrorMsg *string `json:"errorMsg,omitempty"` + // all helm app list, EA+ devtronapp + HelmApps *[]HelmAppDetails `json:"helmApps,omitempty"` + // all helm app list, EA+ devtronapp + DevtronApps *[]openapi.DevtronApp `json:"devtronApps,omitempty"` +} diff --git a/pkg/appStore/installedApp/repository/InstalledAppModels.go b/pkg/appStore/installedApp/repository/InstalledAppModels.go index 56ea99d0d7..320f0fbe48 100644 --- a/pkg/appStore/installedApp/repository/InstalledAppModels.go +++ b/pkg/appStore/installedApp/repository/InstalledAppModels.go @@ -37,6 +37,7 @@ type InstalledAppsWithChartDetails struct { AppOfferingMode string `json:"app_offering_mode"` AppStatus string `json:"app_status"` DeploymentAppDeleteRequest bool `json:"deploymentAppDeleteRequest"` + IsVirtualEnvironment bool `json:"is_virtual_environment"` } // InstalledAppAndEnvDetails is used to operate on native query; This should be avoided. diff --git a/pkg/appStore/installedApp/repository/InstalledAppRepository.go b/pkg/appStore/installedApp/repository/InstalledAppRepository.go index cf4078d23b..c3726e0f0d 100644 --- a/pkg/appStore/installedApp/repository/InstalledAppRepository.go +++ b/pkg/appStore/installedApp/repository/InstalledAppRepository.go @@ -94,6 +94,7 @@ type InstalledAppRepository interface { UpdateInstalledApp(model *InstalledApps, tx *pg.Tx) (*InstalledApps, error) UpdateInstalledAppVersion(model *InstalledAppVersions, tx *pg.Tx) (*InstalledAppVersions, error) GetInstalledApp(id int) (*InstalledApps, error) + GetInstalledAppsByAppId(appId int) (InstalledApps, error) GetInstalledAppVersion(id int) (*InstalledAppVersions, error) GetInstalledAppVersionAny(id int) (*InstalledAppVersions, error) GetAllInstalledApps(filter *appStoreBean.AppStoreFilter) ([]InstalledAppsWithChartDetails, error) @@ -199,6 +200,14 @@ func (impl InstalledAppRepositoryImpl) GetInstalledApp(id int) (*InstalledApps, return model, err } +func (impl InstalledAppRepositoryImpl) GetInstalledAppsByAppId(appId int) (InstalledApps, error) { + var model InstalledApps + err := impl.dbConnection.Model(&model). + Column("installed_apps.*", "App", "Environment", "App.Team", "Environment.Cluster"). + Where("installed_apps.app_id = ?", appId).Where("installed_apps.active = true").Select() + return model, err +} + func (impl InstalledAppRepositoryImpl) GetInstalledAppVersionByAppStoreId(appStoreId int) ([]*InstalledAppVersions, error) { var model []*InstalledAppVersions err := impl.dbConnection.Model(&model). @@ -352,7 +361,7 @@ func (impl InstalledAppRepositoryImpl) GetAllInstalledApps(filter *appStoreBean. var installedAppsWithChartDetails []InstalledAppsWithChartDetails var query string query = "select iav.updated_on, iav.id as installed_app_version_id, ch.name as chart_repo_name, das.id as docker_artifact_store_id," - query = query + " env.environment_name, env.id as environment_id, a.app_name, a.app_offering_mode, asav.icon, asav.name as app_store_application_name," + query = query + " env.environment_name, env.id as environment_id, env.is_virtual_environment, a.app_name, a.app_offering_mode, asav.icon, asav.name as app_store_application_name," query = query + " env.namespace, cluster.cluster_name, a.team_id, cluster.id as cluster_id, " query = query + " asav.id as app_store_application_version_id, ia.id , asav.deprecated , app_status.status as app_status, ia.deployment_app_delete_request" query = query + " from installed_app_versions iav" diff --git a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go index b67e85b57a..58833815c4 100644 --- a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go +++ b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go @@ -18,7 +18,6 @@ package EAMode import ( - "github.com/devtron-labs/devtron/pkg/appStore/adapter" "github.com/devtron-labs/devtron/pkg/cluster" "net/http" "strconv" @@ -27,10 +26,10 @@ import ( "github.com/Pallinder/go-randomdata" bean2 "github.com/devtron-labs/devtron/api/bean" - openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreRepo "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" @@ -41,7 +40,7 @@ import ( ) type InstalledAppDBService interface { - GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) + GetAll(filter *appStoreBean.AppStoreFilter) (appStoreBean.AppListDetail, error) CheckAppExists(appNames []*appStoreBean.AppNames) ([]*appStoreBean.AppNames, error) FindAppDetailsForAppstoreApplication(installedAppId, envId int) (bean2.AppDetailContainer, error) GetInstalledAppById(installedAppId int) (*appStoreRepo.InstalledApps, error) @@ -77,13 +76,13 @@ func NewInstalledAppDBServiceImpl(logger *zap.SugaredLogger, } } -func (impl *InstalledAppDBServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) (openapi.AppList, error) { +func (impl *InstalledAppDBServiceImpl) GetAll(filter *appStoreBean.AppStoreFilter) (appStoreBean.AppListDetail, error) { applicationType := "DEVTRON-CHART-STORE" var clusterIdsConverted []int32 for _, clusterId := range filter.ClusterIds { clusterIdsConverted = append(clusterIdsConverted, int32(clusterId)) } - installedAppsResponse := openapi.AppList{ + installedAppsResponse := appStoreBean.AppListDetail{ ApplicationType: &applicationType, ClusterIds: &clusterIdsConverted, } @@ -94,7 +93,7 @@ func (impl *InstalledAppDBServiceImpl) GetAll(filter *appStoreBean.AppStoreFilte impl.Logger.Error(err) return installedAppsResponse, err } - var helmAppsResponse []openapi.HelmApp + var helmAppsResponse []appStoreBean.HelmAppDetails for _, a := range installedApps { appLocal := a // copied data from here because value is passed as reference if appLocal.TeamId == 0 && appLocal.AppOfferingMode != util3.SERVER_MODE_HYPERION { @@ -105,14 +104,15 @@ func (impl *InstalledAppDBServiceImpl) GetAll(filter *appStoreBean.AppStoreFilte projectId := int32(appLocal.TeamId) envId := int32(appLocal.EnvironmentId) clusterId := int32(appLocal.ClusterId) - environmentDetails := openapi.AppEnvironmentDetail{ - EnvironmentName: &appLocal.EnvironmentName, - EnvironmentId: &envId, - Namespace: &appLocal.Namespace, - ClusterName: &appLocal.ClusterName, - ClusterId: &clusterId, + environmentDetails := appStoreBean.EnvironmentDetails{ + EnvironmentName: &appLocal.EnvironmentName, + EnvironmentId: &envId, + Namespace: &appLocal.Namespace, + ClusterName: &appLocal.ClusterName, + ClusterId: &clusterId, + IsVirtualEnvironment: &appLocal.IsVirtualEnvironment, } - helmAppResp := openapi.HelmApp{ + helmAppResp := appStoreBean.HelmAppDetails{ AppName: &appLocal.AppName, ChartName: &appLocal.AppStoreApplicationName, AppId: &appId, @@ -171,6 +171,7 @@ func (impl *InstalledAppDBServiceImpl) FindAppDetailsForAppstoreApplication(inst } else { chartName = installedAppVerison.AppStoreApplicationVersion.AppStore.DockerArtifactStore.Id } + deploymentContainer := bean2.DeploymentDetailContainer{ InstalledAppId: installedAppVerison.InstalledApp.Id, AppId: installedAppVerison.InstalledApp.App.Id, @@ -191,6 +192,10 @@ func (impl *InstalledAppDBServiceImpl) FindAppDetailsForAppstoreApplication(inst IsVirtualEnvironment: installedAppVerison.InstalledApp.Environment.IsVirtualEnvironment, HelmReleaseInstallStatus: helmReleaseInstallStatus, Status: status, + HelmPackageName: adapter.GetGeneratedHelmPackageName( + installedAppVerison.InstalledApp.App.AppName, + installedAppVerison.InstalledApp.Environment.Name, + installedAppVerison.InstalledApp.UpdatedOn), } userInfo, err := impl.UserService.GetByIdIncludeDeleted(installedAppVerison.AuditLog.UpdatedBy) if err != nil { diff --git a/pkg/bean/app.go b/pkg/bean/app.go index e9ed75825f..25f600d926 100644 --- a/pkg/bean/app.go +++ b/pkg/bean/app.go @@ -33,9 +33,10 @@ import ( ) const ( - LayoutISO = "2006-01-02 15:04:05" - LayoutUS = "January 2, 2006 15:04:05" - LayoutRFC3339 = "2006-01-02T15:04:05Z07:00" + LayoutISO = "2006-01-02 15:04:05" + LayoutUS = "January 2, 2006 15:04:05" + LayoutRFC3339 = "2006-01-02T15:04:05Z07:00" + LayoutDDMMYY_HHMM12hr = "2 January,2006 15.04PM" ) type SourceTypeConfig struct { From fdf71f87d3fd95a9cbbc0edad9f6ba0dd9b2934c Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 11:03:36 +0530 Subject: [PATCH 64/83] app store service refactored --- internal/util/ChartTemplateService.go | 5 +++-- .../repository/AppStoreApplicationVersionRepository.go | 7 ++++--- pkg/appStore/installedApp/adapter/Adapter.go | 5 +++-- .../FullMode/deployment/FullModeDeploymentService.go | 6 ++++++ .../FullMode/deployment/InstalledAppGitOpsService.go | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/internal/util/ChartTemplateService.go b/internal/util/ChartTemplateService.go index 24c6153ea6..bd25fa384c 100644 --- a/internal/util/ChartTemplateService.go +++ b/internal/util/ChartTemplateService.go @@ -46,8 +46,9 @@ const ( ) type ChartCreateRequest struct { - ChartMetaData *chart.Metadata - ChartPath string + ChartMetaData *chart.Metadata + ChartPath string + IncludePackageChart bool } type ChartCreateResponse struct { diff --git a/pkg/appStore/discover/repository/AppStoreApplicationVersionRepository.go b/pkg/appStore/discover/repository/AppStoreApplicationVersionRepository.go index 04e7c2ce73..2a5ca60ceb 100644 --- a/pkg/appStore/discover/repository/AppStoreApplicationVersionRepository.go +++ b/pkg/appStore/discover/repository/AppStoreApplicationVersionRepository.go @@ -18,13 +18,14 @@ package appStoreDiscoverRepository import ( + "strconv" + "time" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "github.com/go-pg/pg/orm" "go.uber.org/zap" - "strconv" - "time" ) type AppStoreApplicationVersionRepository interface { @@ -187,7 +188,7 @@ func (impl AppStoreApplicationVersionRepositoryImpl) FindById(id int) (*AppStore Column("app_store_application_version.*", "AppStore", "AppStore.ChartRepo", "AppStore.DockerArtifactStore", "AppStore.DockerArtifactStore.OCIRegistryConfig"). Join("INNER JOIN app_store aps on app_store_application_version.app_store_id = aps.id"). Join("LEFT JOIN chart_repo ch on aps.chart_repo_id = ch.id"). - Join("LEFT JOIN docker_artifact_store das on aps.docker_artifact_store_id = das.id"). + Join("LEFT JOIN docker_artifact_store das on (aps.docker_artifact_store_id = das.id and das.active IS TRUE)"). Join("LEFT JOIN oci_registry_config orc on orc.docker_artifact_store_id=das.id"). Relation("AppStore.DockerArtifactStore.OCIRegistryConfig", func(q *orm.Query) (query *orm.Query, err error) { return q.Where("deleted IS FALSE and " + diff --git a/pkg/appStore/installedApp/adapter/Adapter.go b/pkg/appStore/installedApp/adapter/Adapter.go index c14505699b..424219e6bb 100644 --- a/pkg/appStore/installedApp/adapter/Adapter.go +++ b/pkg/appStore/installedApp/adapter/Adapter.go @@ -19,14 +19,15 @@ func ParseChartGitPushRequest(installAppRequestDTO *appStoreBean.InstallAppVersi } } -func ParseChartCreateRequest(appName string) *util.ChartCreateRequest { +func ParseChartCreateRequest(appName string, includePackageChart bool) *util.ChartCreateRequest { chartPath := getRefProxyChartPath() return &util.ChartCreateRequest{ ChartMetaData: &chart.Metadata{ Name: appName, Version: "1.0.1", }, - ChartPath: chartPath, + ChartPath: chartPath, + IncludePackageChart: includePackageChart, } } diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go index d0da7bfb43..4bd6eac5af 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go @@ -414,6 +414,12 @@ func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context. appStoreApplicationVersionId, err := impl.installedAppRepositoryHistory.GetAppStoreApplicationVersionIdByInstalledAppVersionHistoryId(int(version)) appStoreVersionId := pointer.Int32(int32(appStoreApplicationVersionId)) + // as virtual environment doesn't exist on actual cluster, we will use default cluster for running helm template command + if installedApp.IsVirtualEnvironment { + clusterId = appStoreBean.DEFAULT_CLUSTER_ID + installedApp.Namespace = appStoreBean.DEFAULT_NAMESPACE + } + manifestRequest := openapi2.TemplateChartRequest{ EnvironmentId: &envId, ClusterId: &clusterId, diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go index 465d958d81..1a6f5df018 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go @@ -248,7 +248,7 @@ func (impl *FullModeDeploymentServiceImpl) updateRequirementYamlInGit(installApp // createChartProxyAndGetPath parse chart in local directory and returns path of local dir and values.yaml func (impl *FullModeDeploymentServiceImpl) createChartProxyAndGetPath(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*util.ChartCreateResponse, error) { - chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest.AppName) + chartCreateRequest := adapter.ParseChartCreateRequest(installAppVersionRequest.AppName, true) chartCreateResponse, err := impl.appStoreDeploymentCommonService.CreateChartProxyAndGetPath(chartCreateRequest) if err != nil { impl.Logger.Errorw("Error in building chart proxy", "err", err) From d1b521bba79cf536470bdf608440fd229354c679 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 12:08:00 +0530 Subject: [PATCH 65/83] internal name changed to internals --- App.go | 2 +- Wire.go | 2 +- api/appStore/InstalledAppRestHandler.go | 6 +- .../AppStoreDeploymentRestHandler.go | 2 +- .../deployment/CommonDeploymentRestHandler.go | 2 +- api/appbean/AppDetail.go | 4 +- api/auth/user/UserRestHandler.go | 2 +- api/bean/ValuesOverrideRequest.go | 2 +- api/chartRepo/ChartRepositoryRestHandler.go | 2 +- api/helm-app/HelmAppRestHandler.go | 2 +- api/helm-app/service/HelmAppService.go | 12 +- .../application/k8sApplicationRestHandler.go | 2 +- api/restHandler/BulkUpdateRestHandler.go | 6 +- api/restHandler/ConfigMapRestHandler.go | 2 +- api/restHandler/CoreAppRestHandler.go | 12 +- api/restHandler/DockerRegRestHandler.go | 4 +- api/restHandler/ImageScanRestHandler.go | 4 +- api/restHandler/NotificationRestHandler.go | 2 +- api/restHandler/PolicyRestHandler.go | 2 +- api/restHandler/ReleaseMetricsRestHandler.go | 2 +- .../app/appInfo/AppInfoRestHandler.go | 2 +- .../app/appList/AppListingRestHandler.go | 10 +- .../app/pipeline/AutoCompleteRestHandler.go | 4 +- .../configure/BuildPipelineRestHandler.go | 10 +- .../BuildPipelineRestHandler_test.go | 4 +- .../DeploymentPipelineRestHandler.go | 8 +- .../configure/PipelineConfigRestHandler.go | 8 +- .../PipelineStatusTimelineRestHandler.go | 2 +- .../webhook/WebhookDataRestHandler.go | 2 +- .../app/workflow/AppWorkflowRestHandler.go | 8 +- api/restHandler/common/ApiResponseWriter.go | 2 +- api/restHandler/common/apiError.go | 2 +- api/router/pubsub/ApplicationStatusHandler.go | 2 +- api/terminal/UserTerminalAccessRestHandler.go | 2 +- api/terminal/wire_terminal.go | 2 +- api/util/logger.go | 2 +- .../cron/CdApplicationStatusUpdateHandler.go | 8 +- client/cron/CiStatusUpdateCron.go | 2 +- client/cron/CiTriggerCron.go | 2 +- client/events/EventBuilder.go | 6 +- client/events/EventClient.go | 4 +- client/gitSensor/GitSensorClient_test.go | 2 +- client/gitSensor/GitSensorRestClient.go | 2 +- client/grafana/GrafanaClient.go | 2 +- client/jira/JiraClient.go | 2 +- client/telemetry/TelemetryEventClient.go | 2 +- .../telemetry/TelemetryEventClientExtended.go | 8 +- cmd/external-app/externalApp.go | 2 +- cmd/external-app/wire.go | 14 +- cmd/external-app/wire_gen.go | 14 +- commonWireset/commonWireset.go | 26 +-- .../constants/InternalErrorCode.go | 0 .../middleware/delegator.go | 0 .../middleware/instrument.go | 0 {internal => internals}/sql/models/Enums.go | 0 .../sql/models/HelmValues_test.go | 0 .../sql/models/TerminalAccessData.go | 0 .../sql/models/UserTerminalSession.go | 0 .../sql/models/helmValues.go | 0 .../sql/repository/AppListingRepository.go | 4 +- .../sql/repository/AttributesRepository.go | 0 .../sql/repository/CiArtifactRepository.go | 2 +- .../repository/CiArtifactRepository_test.go | 0 .../CiArtifactsListingQueryBuilder.go | 2 +- .../sql/repository/CustomTagRepository.go | 0 .../DeploymentGroupAppRepository.go | 0 .../repository/DeploymentGroupRepository.go | 0 .../DeploymentTemplateRepository.go | 0 .../sql/repository/GitHostRepository.go | 0 .../sql/repository/GitOpsConfigRepository.go | 0 .../sql/repository/GitProviderRepository.go | 0 .../sql/repository/GitWebhookRepository.go | 0 .../sql/repository/GlobalCMCSRepository.go | 0 .../sql/repository/LinkoutsRepository.go | 0 .../NotificationSettingsRepository.go | 0 .../repository/SESNotificationRepository.go | 0 .../repository/SMTPNotificationRepository.go | 0 .../repository/SlackNotificationRepository.go | 0 .../repository/TerminalAccessRepository.go | 2 +- .../repository/UserAttributesRepository.go | 0 .../repository/WebhookEventDataRepository.go | 0 .../WebhookNotificationRepository.go | 0 .../sql/repository/app/AppRepository.go | 2 +- .../sql/repository/app/AppRepository_test.go | 0 .../sql/repository/app/mocks/AppRepository.go | 4 +- .../appStatus/AppStatusRepository.go | 0 .../appStatus/mocks/AppStatusRepository.go | 2 +- .../tests/AppStatusRepository_test.go | 4 +- .../appWorkflow/AppWorkflowRepository.go | 0 .../mocks/AppWorkflowRepository.go | 2 +- .../bulkUpdate/BulkUpdateRepository.go | 4 +- .../chartConfig/ConfigMapRepository.go | 0 .../EnvConfigOverrideRepository.go | 2 +- .../EnvConfigOverrideRepository_test.go | 2 +- .../chartConfig/PipelineConfigRepository.go | 0 .../chartConfig/PipelineOverrideRepository.go | 8 +- .../PipelineOverrideRepository_test.go | 2 +- .../chartConfig/mocks/ConfigMapRepository.go | 2 +- .../mocks/EnvConfigOverrideRepository.go | 2 +- .../mocks/PipelineConfigRepository.go | 2 +- .../mocks/PipelineOverrideRepository.go | 4 +- .../DockerArtifactStoreRepository.go | 0 .../DockerRegistryIpsConfigRepository.go | 0 .../OCIRegistryConfigRepository.go | 0 .../AppListingRepositoryQueryBuilder.go | 0 .../imageTagging/ImageTaggingRepository.go | 0 .../mocks/ImageTaggingRepository.go | 2 +- .../mocks/AppLevelMetricsRepository.go | 0 .../repository/mocks/AppListingRepository.go | 2 +- .../repository/mocks/AttributesRepository.go | 2 +- .../repository/mocks/CiArtifactRepository.go | 2 +- .../mocks/CiTemplateOverrideRepository.go | 2 +- .../repository/mocks/CiTemplateRepository.go | 2 +- .../mocks/DeploymentTemplateRepository.go | 2 +- .../mocks/EnvLevelAppMetricsRepository.go | 0 .../mocks/NotificationSettingsRepository.go | 2 +- .../mocks/TerminalAccessRepository.go | 2 +- .../mocks/WebhookNotificationRepository.go | 2 +- .../pipelineConfig/AppLabelsRepository.go | 2 +- .../pipelineConfig/CdWorfkflowRepository.go | 6 +- .../pipelineConfig/CiBuildConfigRepository.go | 0 .../CiBuildConfigRepository_test.go | 0 .../pipelineConfig/CiPipelineMaterial.go | 0 .../pipelineConfig/CiPipelineRepository.go | 2 +- .../CiPipelineRepository_test.go | 0 .../CiTemplateOverrideRepository.go | 2 +- .../pipelineConfig/CiTemplateRepository.go | 4 +- .../CiTemplateRepository_test.go | 0 .../pipelineConfig/CiWorkflowRepository.go | 2 +- .../CiWorkflowRepository_test.go | 0 .../pipelineConfig/MaterialRepository.go | 4 +- .../pipelineConfig/PipelineRepository.go | 8 +- .../PipelineStatusSyncDetailRepository.go | 2 +- .../PipelineStatusTimelineRepository.go | 0 ...pelineStatusTimelineResourcesRepository.go | 0 .../mocks/CdWorkflowRepository.go | 2 +- .../mocks/CiPipelineMaterial.go | 2 +- .../mocks/CiPipelineRepository.go | 2 +- .../mocks/CiWorkflowRepository.go | 2 +- .../mocks/PipelineRepository.go | 2 +- .../mocks/PipelineStatusTimelineRepository.go | 2 +- .../ResourceGroupMappingRepository.go | 0 .../resourceGroup/ResourceGroupRepository.go | 0 .../repository/security/CvePolicyControle.go | 0 .../security/CvePolicyControle_test.go | 0 .../repository/security/CveStoreRepository.go | 2 +- .../security/ImageScanDeployInfoRepository.go | 0 .../security/ImageScanHistoryRepository.go | 0 .../security/ImageScanObjectMetaRepository.go | 0 .../security/ImageScanResultRepository.go | 0 .../ScanToolExecutionHistoryMapping.go | 0 .../security/ScanToolMetaDataRepository.go | 0 .../util/BasicProviders.go | 0 .../util/ChartTemplateService.go | 2 +- .../util/ChartTemplateService_test.go | 0 .../util/CollectionUtil.go | 0 .../util/CollectionUtil_test.go | 0 {internal => internals}/util/EcrService.go | 2 +- {internal => internals}/util/ErrorCoreApp.go | 0 {internal => internals}/util/ErrorUtil.go | 0 .../util/JiraUtil/EncryptionUtil.go | 0 {internal => internals}/util/MergeUtil.go | 0 {internal => internals}/util/TopoSort.go | 0 {internal => internals}/util/TopoSort_test.go | 0 {internal => internals}/util/UrlUtil.go | 0 {internal => internals}/util/ValidateUtil.go | 0 .../util/mocks/ChartTemplateService.go | 2 +- pkg/app/AppCrudOperationService.go | 6 +- pkg/app/AppListingService.go | 16 +- pkg/app/AppListingViewBuilder.go | 2 +- pkg/app/AppService.go | 10 +- pkg/app/DeploymentEventHandler.go | 2 +- pkg/app/ManifestPushService.go | 2 +- pkg/app/ReleaseDataService.go | 4 +- .../AppServiceDeployment_test.go | 10 +- pkg/app/integrationTest/AppService_test.go | 12 +- pkg/app/mocks/AppService.go | 4 +- .../status/PipelineStatusSyncDetailService.go | 2 +- .../PipelineStatusTimelineResourcesService.go | 2 +- .../status/PipelineStatusTimelineService.go | 4 +- pkg/appClone/AppCloneService.go | 12 +- pkg/appClone/batch/Build.go | 6 +- pkg/appClone/batch/DataHolder.go | 2 +- pkg/appClone/batch/DataHolder_test.go | 2 +- pkg/appClone/batch/Deployment.go | 6 +- pkg/appClone/batch/DeploymentTemplate.go | 2 +- pkg/appClone/batch/Mocks_test.go | 6 +- pkg/appClone/batch/Workflow.go | 2 +- pkg/appStatus/AppStatusService.go | 2 +- pkg/appStatus/AppStatusService_test.go | 6 +- pkg/appStore/adapter/Adapter.go | 4 +- pkg/appStore/chartGroup/ChartGroupService.go | 4 +- .../chartProvider/ChartProviderService.go | 4 +- pkg/appStore/chartProvider/bean.go | 2 +- .../discover/repository/AppStoreRepository.go | 2 +- .../discover/service/AppStoreService.go | 2 +- pkg/appStore/installedApp/adapter/Adapter.go | 2 +- .../repository/InstalledAppRepository.go | 6 +- .../service/AppStoreDeploymentDBService.go | 10 +- .../service/AppStoreDeploymentService.go | 6 +- .../service/AppStoreDeploymentService_test.go | 4 +- .../service/EAMode/EAModeDeploymentService.go | 4 +- .../service/EAMode/InstalledAppDBService.go | 6 +- .../FullMode/InstalledAppDBExtendedService.go | 4 +- .../deployment/DeploymentStatusService.go | 4 +- .../deployment/FullModeDeploymentService.go | 4 +- .../deployment/InstalledAppArgoCdService.go | 4 +- .../deployment/InstalledAppGitOpsService.go | 4 +- ...InstalledAppDeploymentTypeChangeService.go | 8 +- .../service/FullMode/resource/NotesService.go | 2 +- .../FullMode/resource/ResourceTreeService.go | 4 +- .../installedApp/service/bean/bean.go | 2 +- .../common/AppStoreDeploymentCommonService.go | 2 +- .../values/service/AppStoreValuesService.go | 2 +- pkg/appWorkflow/AppWorkflowService.go | 8 +- pkg/attributes/AttributesService.go | 4 +- pkg/attributes/UserAttributesService.go | 2 +- pkg/auth/user/RoleGroupService.go | 4 +- pkg/auth/user/UserAuthService.go | 4 +- pkg/auth/user/UserFlows_test.go | 2 +- pkg/auth/user/UserService.go | 4 +- pkg/auth/user/UserService_test.go | 2 +- pkg/auth/user/helper/helper.go | 2 +- pkg/bean/app.go | 10 +- pkg/build/artifacts/CommonArtifactService.go | 2 +- pkg/bulkAction/BulkUpdateService.go | 14 +- pkg/chart/ChartService.go | 8 +- pkg/chart/bean.go | 2 +- pkg/chart/mocks/ChartService.go | 2 +- pkg/chartRepo/ChartRepositoryService.go | 4 +- pkg/chartRepo/ChartRepositoryService_test.go | 4 +- pkg/chartRepo/bean.go | 2 +- .../repository/ChartRepoRepository.go | 2 +- .../repository/ChartRepoRepository_test.go | 2 +- pkg/chartRepo/repository/ChartsRepository.go | 2 +- pkg/cluster/ClusterService.go | 4 +- pkg/cluster/ClusterServiceExtended.go | 4 +- pkg/cluster/ClusterService_test.go | 2 +- pkg/cluster/EnvironmentService.go | 4 +- pkg/cluster/EnvironmentService_test.go | 4 +- pkg/cluster/EphemeralContainerService_test.go | 2 +- pkg/cluster/mocks/ClusterService.go | 2 +- .../repository/EnvironmentRepository.go | 4 +- .../UserTerminalAccessService.go | 4 +- .../UserTerminalAccessServiceIT_test.go | 8 +- .../UserTerminalAccessService_test.go | 6 +- .../clusterTerminalUtils/utils.go | 2 +- pkg/commonService/CommonService.go | 10 +- pkg/delete/DeleteService.go | 2 +- pkg/delete/DeleteServiceExtended.go | 8 +- pkg/delete/DeleteServiceFullMode.go | 4 +- .../deployedApp/DeployedAppService.go | 4 +- .../gitOps/config/GitOpsConfigReadService.go | 2 +- pkg/deployment/gitOps/git/GitFactory.go | 2 +- .../gitOps/git/GitOperationService.go | 2 +- pkg/deployment/gitOps/git/GitOpsClient.go | 2 +- pkg/deployment/gitOps/git/GitService_test.go | 2 +- pkg/deployment/gitOps/wire_gitOps.go | 2 +- .../manifest/ManifestCreationService.go | 12 +- .../deployedAppMetrics/DeployedAppMetrics.go | 2 +- .../DeploymentTemplateService.go | 4 +- .../chartRef/ChartRefService.go | 4 +- .../DeploymentTypeOverrideService.go | 2 +- .../devtronApps/PostStageTriggerService.go | 2 +- .../devtronApps/PreStageTriggerService.go | 8 +- .../trigger/devtronApps/TriggerService.go | 16 +- .../trigger/devtronApps/bean/bean.go | 4 +- pkg/deploymentGroup/DeploymentGroupService.go | 10 +- .../DockerRegistryIpsConfigService.go | 6 +- pkg/eventProcessor/bean/workflowEventBean.go | 2 +- .../in/WorkflowEventProcessorService.go | 4 +- .../out/WorkflowEventPublishService.go | 4 +- pkg/externalLink/ExternalLinkService.go | 2 +- .../intergrationTests/ExternalLinks_test.go | 2 +- .../mocks/ExternalLinkService_test.go | 2 +- .../DeployementTemplateService.go | 6 +- .../DeployementTemplateService_test.go | 8 +- .../GenericNoteHistoryService_test.go | 2 +- pkg/genericNotes/GenericNoteServiceIT_test.go | 2 +- .../repository/GenericNoteRepository.go | 4 +- .../tests/GenericNoteService_test.go | 2 +- pkg/git/GitWebhookService.go | 4 +- pkg/gitops/GitOpsConfigService.go | 4 +- pkg/k8s/K8sCommonService.go | 2 +- .../K8sApplicationServiceIT_test.go | 2 +- pkg/k8s/application/k8sApplicationService.go | 2 +- pkg/k8s/capacity/k8sCapacityService.go | 2 +- .../kubernetesResourceHistoryService.go | 2 +- pkg/module/ModuleService.go | 2 +- pkg/notifier/NotificationConfigBuilder.go | 4 +- pkg/notifier/NotificationConfigService.go | 8 +- pkg/notifier/SESNotificationService.go | 4 +- pkg/notifier/SMTPNotificationService.go | 4 +- pkg/notifier/SlackNotificationService.go | 4 +- pkg/notifier/WebhookNotificationService.go | 4 +- .../WebhookNotificationService_test.go | 6 +- pkg/pipeline/AppArtifactManager.go | 6 +- .../AppDeploymentTypeChangeManager.go | 8 +- pkg/pipeline/ArgoWorkflowExecutor_test.go | 2 +- pkg/pipeline/BuildPipelineConfigService.go | 12 +- pkg/pipeline/BuildPipelineSwitchService.go | 4 +- pkg/pipeline/CdHandler.go | 6 +- pkg/pipeline/CiBuildConfigService.go | 2 +- pkg/pipeline/CiBuildConfigService_test.go | 4 +- pkg/pipeline/CiCdPipelineOrchestrator.go | 16 +- pkg/pipeline/CiCdPipelineOrchestrator_test.go | 16 +- pkg/pipeline/CiHandler.go | 8 +- pkg/pipeline/CiHandlerIT_test.go | 4 +- pkg/pipeline/CiMaterialConfigService.go | 2 +- pkg/pipeline/CiService.go | 14 +- pkg/pipeline/CiTemplateService.go | 2 +- pkg/pipeline/CiTemplateService_test.go | 6 +- pkg/pipeline/ConfigMapService.go | 6 +- pkg/pipeline/ConfigMapService_test.go | 8 +- pkg/pipeline/CustomTagService.go | 2 +- pkg/pipeline/DeploymentConfigService.go | 4 +- .../DeploymentPipelineConfigService.go | 16 +- pkg/pipeline/DevtronAppCMCSService.go | 2 +- pkg/pipeline/DevtronAppConfigService.go | 6 +- pkg/pipeline/DockerRegistryConfig.go | 6 +- pkg/pipeline/DockerRegistryConfig_test.go | 4 +- pkg/pipeline/GitHostConfig.go | 6 +- pkg/pipeline/GitRegistryConfig.go | 6 +- pkg/pipeline/GitopsOrHelmOption_test.go | 4 +- pkg/pipeline/GlobalCMCSService.go | 2 +- pkg/pipeline/GlobalCmcsService_test.go | 2 +- pkg/pipeline/ImageTaggingService.go | 4 +- pkg/pipeline/ImageTaggingService_test.go | 10 +- pkg/pipeline/PipelineBuilder.go | 6 +- pkg/pipeline/PipelineBuilder_test.go | 6 +- pkg/pipeline/PipelineStageService.go | 2 +- pkg/pipeline/PipelineStageServiceIT_test.go | 4 +- pkg/pipeline/PropertiesConfig.go | 4 +- pkg/pipeline/StageServiceUtil.go | 2 +- pkg/pipeline/SystemWorkflowExecutor_test.go | 2 +- pkg/pipeline/WebhookEventDataConfig.go | 2 +- pkg/pipeline/WebhookService.go | 4 +- pkg/pipeline/WorkflowService.go | 2 +- pkg/pipeline/WorkflowServiceIT_test.go | 10 +- pkg/pipeline/WorkflowService_test.go | 2 +- pkg/pipeline/bean/CiBuildConfig.go | 2 +- pkg/pipeline/bean/CiTemplateBean.go | 2 +- pkg/pipeline/bean/EnvironmentProperties.go | 2 +- pkg/pipeline/bean/GlobalCMCSDto.go | 2 +- pkg/pipeline/bean/pipelineStage.go | 2 +- pkg/pipeline/bean/workFlowRequestBean.go | 4 +- pkg/pipeline/executors/WorkflowUtils.go | 2 +- .../history/CiPipelineHistoryService.go | 2 +- .../history/CiPipelineHistoryService_test.go | 6 +- .../history/ConfigMapHistoryService.go | 4 +- .../DeployedConfigurationHistoryService.go | 6 +- .../DeploymentTemplateHistoryService.go | 4 +- .../history/GitMaterialHistoryService.go | 2 +- .../history/GitMaterialHistoryService_test.go | 4 +- .../history/PipelineStrategyHistoryService.go | 4 +- .../history/PrePostCdScriptHistoryService.go | 4 +- .../history/PrePostCiScriptHistoryService.go | 2 +- pkg/pipeline/history/bean.go | 2 +- .../history/ciTemplateHistoryService_test.go | 4 +- .../history/mocks/ConfigMapHistoryService.go | 4 +- .../PipelineStrategyHistoryRepository.go | 2 +- .../PrePostCdScriptHistoryRepository.go | 2 +- .../repository/ciTemplateHistoryRepository.go | 4 +- pkg/pipeline/mock_pipeline/PipelineBuilder.go | 4 +- pkg/pipeline/pipelineStageVariableParser.go | 4 +- pkg/pipeline/types/CiCdConfig.go | 2 +- pkg/pipeline/types/DockerRegistry.go | 2 +- pkg/pipeline/types/Git.go | 2 +- pkg/pipeline/types/ImageTagging.go | 2 +- pkg/pipeline/types/Workflow.go | 6 +- pkg/resourceGroup/ResourceGroupService.go | 6 +- pkg/security/ImageScanService.go | 10 +- pkg/security/policyService.go | 12 +- pkg/security/policyService_test.go | 2 +- pkg/sql/connection.go | 2 +- pkg/team/TeamService.go | 4 +- pkg/variables/ScopedVariableCMCSManager.go | 2 +- .../parsers/VariableTemplateParser_test.go | 2 +- pkg/workflow/cd/CdWorkflowCommonService.go | 4 +- pkg/workflow/cd/CdWorkflowRunnerService.go | 2 +- pkg/workflow/cd/CdWorkflowService.go | 2 +- pkg/workflow/cd/adapter/adapter.go | 2 +- pkg/workflow/cd/bean/bean.go | 2 +- pkg/workflow/dag/WorkflowDagExecutor.go | 12 +- pkg/workflow/dag/bean/bean.go | 2 +- pkg/workflow/status/WorkflowStatusService.go | 6 +- tests/e2e/BasicTestConf.go | 175 +++++++++--------- tests/e2e/CheckList_test.go | 65 ++++--- tests/pipeline/ChartService_test.go | 4 +- util/helper.go | 2 +- util/mocks/rbac/EnforcerUtil.go | 2 +- util/rbac/EnforcerUtil.go | 6 +- util/rbac/EnforcerUtilHelm.go | 2 +- util/response/response.go | 2 +- wire_gen.go | 26 +-- 395 files changed, 806 insertions(+), 808 deletions(-) rename {internal => internals}/constants/InternalErrorCode.go (100%) rename {internal => internals}/middleware/delegator.go (100%) rename {internal => internals}/middleware/instrument.go (100%) rename {internal => internals}/sql/models/Enums.go (100%) rename {internal => internals}/sql/models/HelmValues_test.go (100%) rename {internal => internals}/sql/models/TerminalAccessData.go (100%) rename {internal => internals}/sql/models/UserTerminalSession.go (100%) rename {internal => internals}/sql/models/helmValues.go (100%) rename {internal => internals}/sql/repository/AppListingRepository.go (99%) rename {internal => internals}/sql/repository/AttributesRepository.go (100%) rename {internal => internals}/sql/repository/CiArtifactRepository.go (99%) rename {internal => internals}/sql/repository/CiArtifactRepository_test.go (100%) rename {internal => internals}/sql/repository/CiArtifactsListingQueryBuilder.go (99%) rename {internal => internals}/sql/repository/CustomTagRepository.go (100%) rename {internal => internals}/sql/repository/DeploymentGroupAppRepository.go (100%) rename {internal => internals}/sql/repository/DeploymentGroupRepository.go (100%) rename {internal => internals}/sql/repository/DeploymentTemplateRepository.go (100%) rename {internal => internals}/sql/repository/GitHostRepository.go (100%) rename {internal => internals}/sql/repository/GitOpsConfigRepository.go (100%) rename {internal => internals}/sql/repository/GitProviderRepository.go (100%) rename {internal => internals}/sql/repository/GitWebhookRepository.go (100%) rename {internal => internals}/sql/repository/GlobalCMCSRepository.go (100%) rename {internal => internals}/sql/repository/LinkoutsRepository.go (100%) rename {internal => internals}/sql/repository/NotificationSettingsRepository.go (100%) rename {internal => internals}/sql/repository/SESNotificationRepository.go (100%) rename {internal => internals}/sql/repository/SMTPNotificationRepository.go (100%) rename {internal => internals}/sql/repository/SlackNotificationRepository.go (100%) rename {internal => internals}/sql/repository/TerminalAccessRepository.go (98%) rename {internal => internals}/sql/repository/UserAttributesRepository.go (100%) rename {internal => internals}/sql/repository/WebhookEventDataRepository.go (100%) rename {internal => internals}/sql/repository/WebhookNotificationRepository.go (100%) rename {internal => internals}/sql/repository/app/AppRepository.go (99%) rename {internal => internals}/sql/repository/app/AppRepository_test.go (100%) rename {internal => internals}/sql/repository/app/mocks/AppRepository.go (99%) rename {internal => internals}/sql/repository/appStatus/AppStatusRepository.go (100%) rename {internal => internals}/sql/repository/appStatus/mocks/AppStatusRepository.go (97%) rename {internal => internals}/sql/repository/appStatus/tests/AppStatusRepository_test.go (98%) rename {internal => internals}/sql/repository/appWorkflow/AppWorkflowRepository.go (100%) rename {internal => internals}/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go (99%) rename {internal => internals}/sql/repository/bulkUpdate/BulkUpdateRepository.go (98%) rename {internal => internals}/sql/repository/chartConfig/ConfigMapRepository.go (100%) rename {internal => internals}/sql/repository/chartConfig/EnvConfigOverrideRepository.go (99%) rename {internal => internals}/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go (97%) rename {internal => internals}/sql/repository/chartConfig/PipelineConfigRepository.go (100%) rename {internal => internals}/sql/repository/chartConfig/PipelineOverrideRepository.go (97%) rename {internal => internals}/sql/repository/chartConfig/PipelineOverrideRepository_test.go (98%) rename {internal => internals}/sql/repository/chartConfig/mocks/ConfigMapRepository.go (99%) rename {internal => internals}/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go (99%) rename {internal => internals}/sql/repository/chartConfig/mocks/PipelineConfigRepository.go (98%) rename {internal => internals}/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go (98%) rename {internal => internals}/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go (100%) rename {internal => internals}/sql/repository/dockerRegistry/DockerRegistryIpsConfigRepository.go (100%) rename {internal => internals}/sql/repository/dockerRegistry/OCIRegistryConfigRepository.go (100%) rename {internal => internals}/sql/repository/helper/AppListingRepositoryQueryBuilder.go (100%) rename {internal => internals}/sql/repository/imageTagging/ImageTaggingRepository.go (100%) rename {internal => internals}/sql/repository/imageTagging/mocks/ImageTaggingRepository.go (98%) rename {internal => internals}/sql/repository/mocks/AppLevelMetricsRepository.go (100%) rename {internal => internals}/sql/repository/mocks/AppListingRepository.go (99%) rename {internal => internals}/sql/repository/mocks/AttributesRepository.go (98%) rename {internal => internals}/sql/repository/mocks/CiArtifactRepository.go (99%) rename {internal => internals}/sql/repository/mocks/CiTemplateOverrideRepository.go (97%) rename {internal => internals}/sql/repository/mocks/CiTemplateRepository.go (97%) rename {internal => internals}/sql/repository/mocks/DeploymentTemplateRepository.go (97%) rename {internal => internals}/sql/repository/mocks/EnvLevelAppMetricsRepository.go (100%) rename {internal => internals}/sql/repository/mocks/NotificationSettingsRepository.go (99%) rename {internal => internals}/sql/repository/mocks/TerminalAccessRepository.go (98%) rename {internal => internals}/sql/repository/mocks/WebhookNotificationRepository.go (98%) rename {internal => internals}/sql/repository/pipelineConfig/AppLabelsRepository.go (98%) rename {internal => internals}/sql/repository/pipelineConfig/CdWorfkflowRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/CiBuildConfigRepository.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/CiBuildConfigRepository_test.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/CiPipelineMaterial.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/CiPipelineRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/CiPipelineRepository_test.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go (98%) rename {internal => internals}/sql/repository/pipelineConfig/CiTemplateRepository.go (97%) rename {internal => internals}/sql/repository/pipelineConfig/CiTemplateRepository_test.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/CiWorkflowRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/CiWorkflowRepository_test.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/MaterialRepository.go (98%) rename {internal => internals}/sql/repository/pipelineConfig/PipelineRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/PipelineStatusTimelineRepository.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/PipelineStatusTimelineResourcesRepository.go (100%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/PipelineRepository.go (99%) rename {internal => internals}/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go (98%) rename {internal => internals}/sql/repository/resourceGroup/ResourceGroupMappingRepository.go (100%) rename {internal => internals}/sql/repository/resourceGroup/ResourceGroupRepository.go (100%) rename {internal => internals}/sql/repository/security/CvePolicyControle.go (100%) rename {internal => internals}/sql/repository/security/CvePolicyControle_test.go (100%) rename {internal => internals}/sql/repository/security/CveStoreRepository.go (98%) rename {internal => internals}/sql/repository/security/ImageScanDeployInfoRepository.go (100%) rename {internal => internals}/sql/repository/security/ImageScanHistoryRepository.go (100%) rename {internal => internals}/sql/repository/security/ImageScanObjectMetaRepository.go (100%) rename {internal => internals}/sql/repository/security/ImageScanResultRepository.go (100%) rename {internal => internals}/sql/repository/security/ScanToolExecutionHistoryMapping.go (100%) rename {internal => internals}/sql/repository/security/ScanToolMetaDataRepository.go (100%) rename {internal => internals}/util/BasicProviders.go (100%) rename {internal => internals}/util/ChartTemplateService.go (99%) rename {internal => internals}/util/ChartTemplateService_test.go (100%) rename {internal => internals}/util/CollectionUtil.go (100%) rename {internal => internals}/util/CollectionUtil_test.go (100%) rename {internal => internals}/util/EcrService.go (99%) rename {internal => internals}/util/ErrorCoreApp.go (100%) rename {internal => internals}/util/ErrorUtil.go (100%) rename {internal => internals}/util/JiraUtil/EncryptionUtil.go (100%) rename {internal => internals}/util/MergeUtil.go (100%) rename {internal => internals}/util/TopoSort.go (100%) rename {internal => internals}/util/TopoSort_test.go (100%) rename {internal => internals}/util/UrlUtil.go (100%) rename {internal => internals}/util/ValidateUtil.go (100%) rename {internal => internals}/util/mocks/ChartTemplateService.go (99%) diff --git a/App.go b/App.go index 5132d9c7a5..111b5b66cc 100644 --- a/App.go +++ b/App.go @@ -38,7 +38,7 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/api/router" "github.com/devtron-labs/devtron/api/sse" - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" "github.com/go-pg/pg" _ "github.com/lib/pq" "go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux" diff --git a/Wire.go b/Wire.go index 7391db1584..f6e291a2b0 100644 --- a/Wire.go +++ b/Wire.go @@ -24,7 +24,7 @@ import ( cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/commonWireset" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/google/wire" ) diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index af2bd45877..ca91a9e0cb 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -36,9 +36,9 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/cron" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/middleware" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/middleware" + util2 "github.com/devtron-labs/devtron/internals/util" app2 "github.com/devtron-labs/devtron/pkg/app" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" diff --git a/api/appStore/deployment/AppStoreDeploymentRestHandler.go b/api/appStore/deployment/AppStoreDeploymentRestHandler.go index d7fd36df1b..222bbd2e80 100644 --- a/api/appStore/deployment/AppStoreDeploymentRestHandler.go +++ b/api/appStore/deployment/AppStoreDeploymentRestHandler.go @@ -32,7 +32,7 @@ import ( client "github.com/devtron-labs/devtron/api/helm-app" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/attributes" diff --git a/api/appStore/deployment/CommonDeploymentRestHandler.go b/api/appStore/deployment/CommonDeploymentRestHandler.go index 1963952319..b06c06fe52 100644 --- a/api/appStore/deployment/CommonDeploymentRestHandler.go +++ b/api/appStore/deployment/CommonDeploymentRestHandler.go @@ -31,7 +31,7 @@ import ( client "github.com/devtron-labs/devtron/api/helm-app" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" diff --git a/api/appbean/AppDetail.go b/api/appbean/AppDetail.go index 0e46233476..24f8c360cf 100644 --- a/api/appbean/AppDetail.go +++ b/api/appbean/AppDetail.go @@ -1,8 +1,8 @@ package appbean import ( - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/pipeline/bean" ) diff --git a/api/auth/user/UserRestHandler.go b/api/auth/user/UserRestHandler.go index 296fc7568a..9aaece96da 100644 --- a/api/auth/user/UserRestHandler.go +++ b/api/auth/user/UserRestHandler.go @@ -29,7 +29,7 @@ import ( "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" user2 "github.com/devtron-labs/devtron/pkg/auth/user" bean2 "github.com/devtron-labs/devtron/pkg/auth/user/bean" diff --git a/api/bean/ValuesOverrideRequest.go b/api/bean/ValuesOverrideRequest.go index b7374ca7f7..fe541bd2fa 100644 --- a/api/bean/ValuesOverrideRequest.go +++ b/api/bean/ValuesOverrideRequest.go @@ -19,7 +19,7 @@ package bean import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/devtron-labs/devtron/pkg/pipeline/repository" ) diff --git a/api/chartRepo/ChartRepositoryRestHandler.go b/api/chartRepo/ChartRepositoryRestHandler.go index b7c0486d5f..7696a23a5f 100644 --- a/api/chartRepo/ChartRepositoryRestHandler.go +++ b/api/chartRepo/ChartRepositoryRestHandler.go @@ -25,7 +25,7 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/helm-app/HelmAppRestHandler.go b/api/helm-app/HelmAppRestHandler.go index 6990ad279e..9c75b6cf79 100644 --- a/api/helm-app/HelmAppRestHandler.go +++ b/api/helm-app/HelmAppRestHandler.go @@ -17,7 +17,7 @@ import ( openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/helm-app/service/HelmAppService.go b/api/helm-app/service/HelmAppService.go index d0efce9c0f..a4f306a499 100644 --- a/api/helm-app/service/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -8,8 +8,8 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/models" - "github.com/devtron-labs/devtron/internal/constants" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/constants" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/go-pg/pg" "google.golang.org/grpc/codes" "net/http" @@ -22,10 +22,10 @@ import ( "github.com/devtron-labs/devtron/api/connector" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/api/k8s/application/k8sApplicationRestHandler.go b/api/k8s/application/k8sApplicationRestHandler.go index 019c372b9d..9c0df49817 100644 --- a/api/k8s/application/k8sApplicationRestHandler.go +++ b/api/k8s/application/k8sApplicationRestHandler.go @@ -15,7 +15,7 @@ import ( "github.com/devtron-labs/devtron/api/connector" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/api/restHandler/common" - util2 "github.com/devtron-labs/devtron/internal/util" + util2 "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/api/restHandler/BulkUpdateRestHandler.go b/api/restHandler/BulkUpdateRestHandler.go index 3a4a0293a6..bcaeae2276 100644 --- a/api/restHandler/BulkUpdateRestHandler.go +++ b/api/restHandler/BulkUpdateRestHandler.go @@ -11,9 +11,9 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/appClone" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" diff --git a/api/restHandler/ConfigMapRestHandler.go b/api/restHandler/ConfigMapRestHandler.go index 3802b52fad..f87d0292ac 100644 --- a/api/restHandler/ConfigMapRestHandler.go +++ b/api/restHandler/ConfigMapRestHandler.go @@ -24,7 +24,7 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/chart" diff --git a/api/restHandler/CoreAppRestHandler.go b/api/restHandler/CoreAppRestHandler.go index 5274fdd8da..01264281ac 100644 --- a/api/restHandler/CoreAppRestHandler.go +++ b/api/restHandler/CoreAppRestHandler.go @@ -30,12 +30,12 @@ import ( appBean "github.com/devtron-labs/devtron/api/appbean" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + appWorkflow2 "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + util2 "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" diff --git a/api/restHandler/DockerRegRestHandler.go b/api/restHandler/DockerRegRestHandler.go index eb6e33fb56..d739a40f0a 100644 --- a/api/restHandler/DockerRegRestHandler.go +++ b/api/restHandler/DockerRegRestHandler.go @@ -24,8 +24,8 @@ import ( "strings" "github.com/devtron-labs/devtron/api/restHandler/common" - repository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/util" + repository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/util" chartProviderService "github.com/devtron-labs/devtron/pkg/appStore/chartProvider" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/restHandler/ImageScanRestHandler.go b/api/restHandler/ImageScanRestHandler.go index ca33c82b34..a0befdeb8d 100644 --- a/api/restHandler/ImageScanRestHandler.go +++ b/api/restHandler/ImageScanRestHandler.go @@ -24,8 +24,8 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/api/restHandler/NotificationRestHandler.go b/api/restHandler/NotificationRestHandler.go index 996ecd52e9..e069325823 100644 --- a/api/restHandler/NotificationRestHandler.go +++ b/api/restHandler/NotificationRestHandler.go @@ -28,7 +28,7 @@ import ( "strings" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/api/restHandler/PolicyRestHandler.go b/api/restHandler/PolicyRestHandler.go index 81e133c79f..37eedab103 100644 --- a/api/restHandler/PolicyRestHandler.go +++ b/api/restHandler/PolicyRestHandler.go @@ -26,7 +26,7 @@ import ( "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/restHandler/common" - security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" + security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" user2 "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/api/restHandler/ReleaseMetricsRestHandler.go b/api/restHandler/ReleaseMetricsRestHandler.go index 28f7fcf47c..3a424a9bc7 100644 --- a/api/restHandler/ReleaseMetricsRestHandler.go +++ b/api/restHandler/ReleaseMetricsRestHandler.go @@ -24,7 +24,7 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/lens" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/restHandler/app/appInfo/AppInfoRestHandler.go b/api/restHandler/app/appInfo/AppInfoRestHandler.go index b6e614c1d7..db2d2603c3 100644 --- a/api/restHandler/app/appInfo/AppInfoRestHandler.go +++ b/api/restHandler/app/appInfo/AppInfoRestHandler.go @@ -25,7 +25,7 @@ import ( "strings" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 373f14bf85..b9a98b730c 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -41,11 +41,11 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/cron" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/api/restHandler/app/pipeline/AutoCompleteRestHandler.go b/api/restHandler/app/pipeline/AutoCompleteRestHandler.go index ac03a3d052..50c5e070a6 100644 --- a/api/restHandler/app/pipeline/AutoCompleteRestHandler.go +++ b/api/restHandler/app/pipeline/AutoCompleteRestHandler.go @@ -12,8 +12,8 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - repository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/gorilla/mux" diff --git a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go index 7117c76b0e..ded386cf1e 100644 --- a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler.go @@ -13,11 +13,11 @@ import ( "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline" diff --git a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go index 13cbe791e5..7d54570e6e 100644 --- a/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go +++ b/api/restHandler/app/pipeline/configure/BuildPipelineRestHandler_test.go @@ -7,8 +7,8 @@ import ( "net/http/httptest" "testing" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user/mocks" "github.com/devtron-labs/devtron/pkg/auth/user/mocks/casbin" "github.com/devtron-labs/devtron/pkg/bean" diff --git a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go index 605aec3c1a..57e9cb89cb 100644 --- a/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go +++ b/api/restHandler/app/pipeline/configure/DeploymentPipelineRestHandler.go @@ -14,10 +14,10 @@ import ( bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/chart" diff --git a/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go b/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go index 99809d282e..3b97537a7b 100644 --- a/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go +++ b/api/restHandler/app/pipeline/configure/PipelineConfigRestHandler.go @@ -44,10 +44,10 @@ import ( "github.com/go-pg/pg" "go.opentelemetry.io/otel" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appClone" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/bean" diff --git a/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go b/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go index dd604e31e1..c4f94fc37b 100644 --- a/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go +++ b/api/restHandler/app/pipeline/status/PipelineStatusTimelineRestHandler.go @@ -3,7 +3,7 @@ package status import ( "fmt" "github.com/devtron-labs/devtron/client/cron" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/pipeline" "net/http" diff --git a/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go b/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go index c0dd12c85b..b4a047714d 100644 --- a/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go +++ b/api/restHandler/app/pipeline/webhook/WebhookDataRestHandler.go @@ -24,7 +24,7 @@ import ( "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/pipeline" diff --git a/api/restHandler/app/workflow/AppWorkflowRestHandler.go b/api/restHandler/app/workflow/AppWorkflowRestHandler.go index f0b2016bc8..efc8607f53 100644 --- a/api/restHandler/app/workflow/AppWorkflowRestHandler.go +++ b/api/restHandler/app/workflow/AppWorkflowRestHandler.go @@ -24,10 +24,10 @@ import ( "strings" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + appWorkflow2 "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/util" bean3 "github.com/devtron-labs/devtron/pkg/app/bean" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" diff --git a/api/restHandler/common/ApiResponseWriter.go b/api/restHandler/common/ApiResponseWriter.go index ac64a86377..b622b84f68 100644 --- a/api/restHandler/common/ApiResponseWriter.go +++ b/api/restHandler/common/ApiResponseWriter.go @@ -2,7 +2,7 @@ package common import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "net/http" ) diff --git a/api/restHandler/common/apiError.go b/api/restHandler/common/apiError.go index b95074876b..9fdbba0614 100644 --- a/api/restHandler/common/apiError.go +++ b/api/restHandler/common/apiError.go @@ -20,7 +20,7 @@ package common import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/hashicorp/go-multierror" "github.com/juju/errors" "gopkg.in/go-playground/validator.v9" diff --git a/api/router/pubsub/ApplicationStatusHandler.go b/api/router/pubsub/ApplicationStatusHandler.go index 9ea6ea25a3..9e0f0e65bb 100644 --- a/api/router/pubsub/ApplicationStatusHandler.go +++ b/api/router/pubsub/ApplicationStatusHandler.go @@ -32,7 +32,7 @@ import ( "k8s.io/utils/pointer" "time" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/bean" diff --git a/api/terminal/UserTerminalAccessRestHandler.go b/api/terminal/UserTerminalAccessRestHandler.go index 4b71273c97..72841e91d2 100644 --- a/api/terminal/UserTerminalAccessRestHandler.go +++ b/api/terminal/UserTerminalAccessRestHandler.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/devtron-labs/devtron/api/restHandler/common" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" diff --git a/api/terminal/wire_terminal.go b/api/terminal/wire_terminal.go index bc3bb71778..757aabde7b 100644 --- a/api/terminal/wire_terminal.go +++ b/api/terminal/wire_terminal.go @@ -1,7 +1,7 @@ package terminal import ( - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess" "github.com/google/wire" ) diff --git a/api/util/logger.go b/api/util/logger.go index bdeeaf742c..200f23ed32 100644 --- a/api/util/logger.go +++ b/api/util/logger.go @@ -7,7 +7,7 @@ import ( "net/http" "time" - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" "github.com/devtron-labs/devtron/pkg/auth/user" ) diff --git a/client/cron/CdApplicationStatusUpdateHandler.go b/client/cron/CdApplicationStatusUpdateHandler.go index c110eb6ca1..ce6a72076c 100644 --- a/client/cron/CdApplicationStatusUpdateHandler.go +++ b/client/cron/CdApplicationStatusUpdateHandler.go @@ -7,10 +7,10 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" "github.com/devtron-labs/devtron/api/bean" client2 "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + util2 "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" diff --git a/client/cron/CiStatusUpdateCron.go b/client/cron/CiStatusUpdateCron.go index 1eae7f5134..216465715f 100644 --- a/client/cron/CiStatusUpdateCron.go +++ b/client/cron/CiStatusUpdateCron.go @@ -3,7 +3,7 @@ package cron import ( "fmt" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/pipeline" cron2 "github.com/devtron-labs/devtron/util/cron" diff --git a/client/cron/CiTriggerCron.go b/client/cron/CiTriggerCron.go index c6a0f97f83..d08e117ec9 100644 --- a/client/cron/CiTriggerCron.go +++ b/client/cron/CiTriggerCron.go @@ -3,7 +3,7 @@ package cron import ( "fmt" "github.com/caarlos0/env" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline" bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean" diff --git a/client/events/EventBuilder.go b/client/events/EventBuilder.go index 63060238ea..9635ec226f 100644 --- a/client/events/EventBuilder.go +++ b/client/events/EventBuilder.go @@ -24,9 +24,9 @@ import ( "time" bean2 "github.com/devtron-labs/devtron/api/bean" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/util/event" diff --git a/client/events/EventClient.go b/client/events/EventClient.go index b32a06c9ff..80c6003ac3 100644 --- a/client/events/EventClient.go +++ b/client/events/EventClient.go @@ -30,8 +30,8 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/attributes" util "github.com/devtron-labs/devtron/util/event" "go.uber.org/zap" diff --git a/client/gitSensor/GitSensorClient_test.go b/client/gitSensor/GitSensorClient_test.go index 4be305b152..f6fee2e848 100644 --- a/client/gitSensor/GitSensorClient_test.go +++ b/client/gitSensor/GitSensorClient_test.go @@ -1,7 +1,7 @@ package gitSensor import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/stretchr/testify/assert" "testing" ) diff --git a/client/gitSensor/GitSensorRestClient.go b/client/gitSensor/GitSensorRestClient.go index 3e2b7de06f..e96fcead2e 100644 --- a/client/gitSensor/GitSensorRestClient.go +++ b/client/gitSensor/GitSensorRestClient.go @@ -22,7 +22,7 @@ import ( "context" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "go.uber.org/zap" "io" "io/ioutil" diff --git a/client/grafana/GrafanaClient.go b/client/grafana/GrafanaClient.go index 652aa1cfaa..484383b47a 100644 --- a/client/grafana/GrafanaClient.go +++ b/client/grafana/GrafanaClient.go @@ -28,7 +28,7 @@ import ( "strings" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "go.uber.org/zap" ) diff --git a/client/jira/JiraClient.go b/client/jira/JiraClient.go index d227303972..3ea610ff38 100644 --- a/client/jira/JiraClient.go +++ b/client/jira/JiraClient.go @@ -21,7 +21,7 @@ import ( "bytes" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/util/JiraUtil" + "github.com/devtron-labs/devtron/internals/util/JiraUtil" "go.uber.org/zap" "net/http" ) diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index 352e51ff37..229a5dc28a 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -13,7 +13,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/sso" diff --git a/client/telemetry/TelemetryEventClientExtended.go b/client/telemetry/TelemetryEventClientExtended.go index 2a8e725546..2192d8831f 100644 --- a/client/telemetry/TelemetryEventClientExtended.go +++ b/client/telemetry/TelemetryEventClientExtended.go @@ -10,10 +10,10 @@ import ( "time" util2 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/sso" user2 "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/cmd/external-app/externalApp.go b/cmd/external-app/externalApp.go index 0f737d4cf2..5bbec997a9 100644 --- a/cmd/external-app/externalApp.go +++ b/cmd/external-app/externalApp.go @@ -8,7 +8,7 @@ import ( authMiddleware "github.com/devtron-labs/authenticator/middleware" "github.com/devtron-labs/common-lib/middlewares" "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index a455dc7d93..e3a75179c7 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -37,13 +37,13 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/session" "github.com/devtron-labs/devtron/client/dashboard" "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internal/sql/repository" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index f9a755a96d..e31b1d6301 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -44,13 +44,13 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/dashboard" "github.com/devtron-labs/devtron/client/telemetry" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - repository5 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + repository5 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" repository7 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" diff --git a/commonWireset/commonWireset.go b/commonWireset/commonWireset.go index 8192ca7060..677c889d2f 100644 --- a/commonWireset/commonWireset.go +++ b/commonWireset/commonWireset.go @@ -65,19 +65,19 @@ import ( "github.com/devtron-labs/devtron/client/lens" "github.com/devtron-labs/devtron/client/proxy" "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internal/sql/repository" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" - security2 "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + appStatusRepo "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + appWorkflow2 "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/bulkUpdate" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + repository8 "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + resourceGroup "github.com/devtron-labs/devtron/internals/sql/repository/resourceGroup" + security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appClone" diff --git a/internal/constants/InternalErrorCode.go b/internals/constants/InternalErrorCode.go similarity index 100% rename from internal/constants/InternalErrorCode.go rename to internals/constants/InternalErrorCode.go diff --git a/internal/middleware/delegator.go b/internals/middleware/delegator.go similarity index 100% rename from internal/middleware/delegator.go rename to internals/middleware/delegator.go diff --git a/internal/middleware/instrument.go b/internals/middleware/instrument.go similarity index 100% rename from internal/middleware/instrument.go rename to internals/middleware/instrument.go diff --git a/internal/sql/models/Enums.go b/internals/sql/models/Enums.go similarity index 100% rename from internal/sql/models/Enums.go rename to internals/sql/models/Enums.go diff --git a/internal/sql/models/HelmValues_test.go b/internals/sql/models/HelmValues_test.go similarity index 100% rename from internal/sql/models/HelmValues_test.go rename to internals/sql/models/HelmValues_test.go diff --git a/internal/sql/models/TerminalAccessData.go b/internals/sql/models/TerminalAccessData.go similarity index 100% rename from internal/sql/models/TerminalAccessData.go rename to internals/sql/models/TerminalAccessData.go diff --git a/internal/sql/models/UserTerminalSession.go b/internals/sql/models/UserTerminalSession.go similarity index 100% rename from internal/sql/models/UserTerminalSession.go rename to internals/sql/models/UserTerminalSession.go diff --git a/internal/sql/models/helmValues.go b/internals/sql/models/helmValues.go similarity index 100% rename from internal/sql/models/helmValues.go rename to internals/sql/models/helmValues.go diff --git a/internal/sql/repository/AppListingRepository.go b/internals/sql/repository/AppListingRepository.go similarity index 99% rename from internal/sql/repository/AppListingRepository.go rename to internals/sql/repository/AppListingRepository.go index d5d791d30d..566afc1c83 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internals/sql/repository/AppListingRepository.go @@ -24,14 +24,14 @@ import ( "context" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "go.opentelemetry.io/otel" "strings" "time" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/go-pg/pg" "go.uber.org/zap" ) diff --git a/internal/sql/repository/AttributesRepository.go b/internals/sql/repository/AttributesRepository.go similarity index 100% rename from internal/sql/repository/AttributesRepository.go rename to internals/sql/repository/AttributesRepository.go diff --git a/internal/sql/repository/CiArtifactRepository.go b/internals/sql/repository/CiArtifactRepository.go similarity index 99% rename from internal/sql/repository/CiArtifactRepository.go rename to internals/sql/repository/CiArtifactRepository.go index caf53ddb83..90aef6ba24 100644 --- a/internal/sql/repository/CiArtifactRepository.go +++ b/internals/sql/repository/CiArtifactRepository.go @@ -20,7 +20,7 @@ package repository import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/sql" "golang.org/x/exp/slices" "strings" diff --git a/internal/sql/repository/CiArtifactRepository_test.go b/internals/sql/repository/CiArtifactRepository_test.go similarity index 100% rename from internal/sql/repository/CiArtifactRepository_test.go rename to internals/sql/repository/CiArtifactRepository_test.go diff --git a/internal/sql/repository/CiArtifactsListingQueryBuilder.go b/internals/sql/repository/CiArtifactsListingQueryBuilder.go similarity index 99% rename from internal/sql/repository/CiArtifactsListingQueryBuilder.go rename to internals/sql/repository/CiArtifactsListingQueryBuilder.go index 2d17fe73d9..0e5e2140bb 100644 --- a/internal/sql/repository/CiArtifactsListingQueryBuilder.go +++ b/internals/sql/repository/CiArtifactsListingQueryBuilder.go @@ -3,7 +3,7 @@ package repository import ( "fmt" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" ) const EmptyLikeRegex = "%%" diff --git a/internal/sql/repository/CustomTagRepository.go b/internals/sql/repository/CustomTagRepository.go similarity index 100% rename from internal/sql/repository/CustomTagRepository.go rename to internals/sql/repository/CustomTagRepository.go diff --git a/internal/sql/repository/DeploymentGroupAppRepository.go b/internals/sql/repository/DeploymentGroupAppRepository.go similarity index 100% rename from internal/sql/repository/DeploymentGroupAppRepository.go rename to internals/sql/repository/DeploymentGroupAppRepository.go diff --git a/internal/sql/repository/DeploymentGroupRepository.go b/internals/sql/repository/DeploymentGroupRepository.go similarity index 100% rename from internal/sql/repository/DeploymentGroupRepository.go rename to internals/sql/repository/DeploymentGroupRepository.go diff --git a/internal/sql/repository/DeploymentTemplateRepository.go b/internals/sql/repository/DeploymentTemplateRepository.go similarity index 100% rename from internal/sql/repository/DeploymentTemplateRepository.go rename to internals/sql/repository/DeploymentTemplateRepository.go diff --git a/internal/sql/repository/GitHostRepository.go b/internals/sql/repository/GitHostRepository.go similarity index 100% rename from internal/sql/repository/GitHostRepository.go rename to internals/sql/repository/GitHostRepository.go diff --git a/internal/sql/repository/GitOpsConfigRepository.go b/internals/sql/repository/GitOpsConfigRepository.go similarity index 100% rename from internal/sql/repository/GitOpsConfigRepository.go rename to internals/sql/repository/GitOpsConfigRepository.go diff --git a/internal/sql/repository/GitProviderRepository.go b/internals/sql/repository/GitProviderRepository.go similarity index 100% rename from internal/sql/repository/GitProviderRepository.go rename to internals/sql/repository/GitProviderRepository.go diff --git a/internal/sql/repository/GitWebhookRepository.go b/internals/sql/repository/GitWebhookRepository.go similarity index 100% rename from internal/sql/repository/GitWebhookRepository.go rename to internals/sql/repository/GitWebhookRepository.go diff --git a/internal/sql/repository/GlobalCMCSRepository.go b/internals/sql/repository/GlobalCMCSRepository.go similarity index 100% rename from internal/sql/repository/GlobalCMCSRepository.go rename to internals/sql/repository/GlobalCMCSRepository.go diff --git a/internal/sql/repository/LinkoutsRepository.go b/internals/sql/repository/LinkoutsRepository.go similarity index 100% rename from internal/sql/repository/LinkoutsRepository.go rename to internals/sql/repository/LinkoutsRepository.go diff --git a/internal/sql/repository/NotificationSettingsRepository.go b/internals/sql/repository/NotificationSettingsRepository.go similarity index 100% rename from internal/sql/repository/NotificationSettingsRepository.go rename to internals/sql/repository/NotificationSettingsRepository.go diff --git a/internal/sql/repository/SESNotificationRepository.go b/internals/sql/repository/SESNotificationRepository.go similarity index 100% rename from internal/sql/repository/SESNotificationRepository.go rename to internals/sql/repository/SESNotificationRepository.go diff --git a/internal/sql/repository/SMTPNotificationRepository.go b/internals/sql/repository/SMTPNotificationRepository.go similarity index 100% rename from internal/sql/repository/SMTPNotificationRepository.go rename to internals/sql/repository/SMTPNotificationRepository.go diff --git a/internal/sql/repository/SlackNotificationRepository.go b/internals/sql/repository/SlackNotificationRepository.go similarity index 100% rename from internal/sql/repository/SlackNotificationRepository.go rename to internals/sql/repository/SlackNotificationRepository.go diff --git a/internal/sql/repository/TerminalAccessRepository.go b/internals/sql/repository/TerminalAccessRepository.go similarity index 98% rename from internal/sql/repository/TerminalAccessRepository.go rename to internals/sql/repository/TerminalAccessRepository.go index df2aac0288..34976e01fc 100644 --- a/internal/sql/repository/TerminalAccessRepository.go +++ b/internals/sql/repository/TerminalAccessRepository.go @@ -1,7 +1,7 @@ package repository import ( - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/go-pg/pg" "github.com/go-pg/pg/orm" "go.uber.org/zap" diff --git a/internal/sql/repository/UserAttributesRepository.go b/internals/sql/repository/UserAttributesRepository.go similarity index 100% rename from internal/sql/repository/UserAttributesRepository.go rename to internals/sql/repository/UserAttributesRepository.go diff --git a/internal/sql/repository/WebhookEventDataRepository.go b/internals/sql/repository/WebhookEventDataRepository.go similarity index 100% rename from internal/sql/repository/WebhookEventDataRepository.go rename to internals/sql/repository/WebhookEventDataRepository.go diff --git a/internal/sql/repository/WebhookNotificationRepository.go b/internals/sql/repository/WebhookNotificationRepository.go similarity index 100% rename from internal/sql/repository/WebhookNotificationRepository.go rename to internals/sql/repository/WebhookNotificationRepository.go diff --git a/internal/sql/repository/app/AppRepository.go b/internals/sql/repository/app/AppRepository.go similarity index 99% rename from internal/sql/repository/app/AppRepository.go rename to internals/sql/repository/app/AppRepository.go index 4988783ec6..30bc7b4933 100644 --- a/internal/sql/repository/app/AppRepository.go +++ b/internals/sql/repository/app/AppRepository.go @@ -19,7 +19,7 @@ package app import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" "github.com/go-pg/pg" diff --git a/internal/sql/repository/app/AppRepository_test.go b/internals/sql/repository/app/AppRepository_test.go similarity index 100% rename from internal/sql/repository/app/AppRepository_test.go rename to internals/sql/repository/app/AppRepository_test.go diff --git a/internal/sql/repository/app/mocks/AppRepository.go b/internals/sql/repository/app/mocks/AppRepository.go similarity index 99% rename from internal/sql/repository/app/mocks/AppRepository.go rename to internals/sql/repository/app/mocks/AppRepository.go index 6a944aca35..8979ab98f9 100644 --- a/internal/sql/repository/app/mocks/AppRepository.go +++ b/internals/sql/repository/app/mocks/AppRepository.go @@ -3,8 +3,8 @@ package mocks import ( - app "github.com/devtron-labs/devtron/internal/sql/repository/app" - helper "github.com/devtron-labs/devtron/internal/sql/repository/helper" + app "github.com/devtron-labs/devtron/internals/sql/repository/app" + helper "github.com/devtron-labs/devtron/internals/sql/repository/helper" mock "github.com/stretchr/testify/mock" diff --git a/internal/sql/repository/appStatus/AppStatusRepository.go b/internals/sql/repository/appStatus/AppStatusRepository.go similarity index 100% rename from internal/sql/repository/appStatus/AppStatusRepository.go rename to internals/sql/repository/appStatus/AppStatusRepository.go diff --git a/internal/sql/repository/appStatus/mocks/AppStatusRepository.go b/internals/sql/repository/appStatus/mocks/AppStatusRepository.go similarity index 97% rename from internal/sql/repository/appStatus/mocks/AppStatusRepository.go rename to internals/sql/repository/appStatus/mocks/AppStatusRepository.go index ca39b25eaa..28705f1893 100644 --- a/internal/sql/repository/appStatus/mocks/AppStatusRepository.go +++ b/internals/sql/repository/appStatus/mocks/AppStatusRepository.go @@ -3,7 +3,7 @@ package mocks import ( - appStatus "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" + appStatus "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" mock "github.com/stretchr/testify/mock" pg "github.com/go-pg/pg" diff --git a/internal/sql/repository/appStatus/tests/AppStatusRepository_test.go b/internals/sql/repository/appStatus/tests/AppStatusRepository_test.go similarity index 98% rename from internal/sql/repository/appStatus/tests/AppStatusRepository_test.go rename to internals/sql/repository/appStatus/tests/AppStatusRepository_test.go index bc6f101e4a..22f5342cfc 100644 --- a/internal/sql/repository/appStatus/tests/AppStatusRepository_test.go +++ b/internals/sql/repository/appStatus/tests/AppStatusRepository_test.go @@ -2,8 +2,8 @@ package tests import ( "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" "log" diff --git a/internal/sql/repository/appWorkflow/AppWorkflowRepository.go b/internals/sql/repository/appWorkflow/AppWorkflowRepository.go similarity index 100% rename from internal/sql/repository/appWorkflow/AppWorkflowRepository.go rename to internals/sql/repository/appWorkflow/AppWorkflowRepository.go diff --git a/internal/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go b/internals/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go similarity index 99% rename from internal/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go rename to internals/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go index 658679f795..9473bb80aa 100644 --- a/internal/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go +++ b/internals/sql/repository/appWorkflow/mocks/AppWorkflowRepository.go @@ -3,7 +3,7 @@ package mocks import ( - appWorkflow "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" + appWorkflow "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" mock "github.com/stretchr/testify/mock" pg "github.com/go-pg/pg" diff --git a/internal/sql/repository/bulkUpdate/BulkUpdateRepository.go b/internals/sql/repository/bulkUpdate/BulkUpdateRepository.go similarity index 98% rename from internal/sql/repository/bulkUpdate/BulkUpdateRepository.go rename to internals/sql/repository/bulkUpdate/BulkUpdateRepository.go index ea4869b94a..db846df2ea 100644 --- a/internal/sql/repository/bulkUpdate/BulkUpdateRepository.go +++ b/internals/sql/repository/bulkUpdate/BulkUpdateRepository.go @@ -2,8 +2,8 @@ package bulkUpdate import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/internal/sql/repository/chartConfig/ConfigMapRepository.go b/internals/sql/repository/chartConfig/ConfigMapRepository.go similarity index 100% rename from internal/sql/repository/chartConfig/ConfigMapRepository.go rename to internals/sql/repository/chartConfig/ConfigMapRepository.go diff --git a/internal/sql/repository/chartConfig/EnvConfigOverrideRepository.go b/internals/sql/repository/chartConfig/EnvConfigOverrideRepository.go similarity index 99% rename from internal/sql/repository/chartConfig/EnvConfigOverrideRepository.go rename to internals/sql/repository/chartConfig/EnvConfigOverrideRepository.go index 55c2f0cbd8..5f4488229b 100644 --- a/internal/sql/repository/chartConfig/EnvConfigOverrideRepository.go +++ b/internals/sql/repository/chartConfig/EnvConfigOverrideRepository.go @@ -18,7 +18,7 @@ package chartConfig import ( - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/internal/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go b/internals/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go similarity index 97% rename from internal/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go rename to internals/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go index f91c76e122..606572a7dc 100644 --- a/internal/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go +++ b/internals/sql/repository/chartConfig/EnvConfigOverrideRepository_test.go @@ -18,7 +18,7 @@ package chartConfig import ( - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/devtron-labs/devtron/pkg/sql" "github.com/stretchr/testify/assert" "testing" diff --git a/internal/sql/repository/chartConfig/PipelineConfigRepository.go b/internals/sql/repository/chartConfig/PipelineConfigRepository.go similarity index 100% rename from internal/sql/repository/chartConfig/PipelineConfigRepository.go rename to internals/sql/repository/chartConfig/PipelineConfigRepository.go diff --git a/internal/sql/repository/chartConfig/PipelineOverrideRepository.go b/internals/sql/repository/chartConfig/PipelineOverrideRepository.go similarity index 97% rename from internal/sql/repository/chartConfig/PipelineOverrideRepository.go rename to internals/sql/repository/chartConfig/PipelineOverrideRepository.go index 81548f1a07..eb22939ac8 100644 --- a/internal/sql/repository/chartConfig/PipelineOverrideRepository.go +++ b/internals/sql/repository/chartConfig/PipelineOverrideRepository.go @@ -20,10 +20,10 @@ package chartConfig import ( "github.com/devtron-labs/devtron/api/bean" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" deploymentStatus "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" diff --git a/internal/sql/repository/chartConfig/PipelineOverrideRepository_test.go b/internals/sql/repository/chartConfig/PipelineOverrideRepository_test.go similarity index 98% rename from internal/sql/repository/chartConfig/PipelineOverrideRepository_test.go rename to internals/sql/repository/chartConfig/PipelineOverrideRepository_test.go index 1a10d497c6..4b3169adec 100644 --- a/internal/sql/repository/chartConfig/PipelineOverrideRepository_test.go +++ b/internals/sql/repository/chartConfig/PipelineOverrideRepository_test.go @@ -23,7 +23,7 @@ import ( "testing" "time" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" ) diff --git a/internal/sql/repository/chartConfig/mocks/ConfigMapRepository.go b/internals/sql/repository/chartConfig/mocks/ConfigMapRepository.go similarity index 99% rename from internal/sql/repository/chartConfig/mocks/ConfigMapRepository.go rename to internals/sql/repository/chartConfig/mocks/ConfigMapRepository.go index f692778084..a655aee0b3 100644 --- a/internal/sql/repository/chartConfig/mocks/ConfigMapRepository.go +++ b/internals/sql/repository/chartConfig/mocks/ConfigMapRepository.go @@ -3,7 +3,7 @@ package mocks import ( - chartConfig "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + chartConfig "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go b/internals/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go similarity index 99% rename from internal/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go rename to internals/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go index 77d135109d..c190b759cf 100644 --- a/internal/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go +++ b/internals/sql/repository/chartConfig/mocks/EnvConfigOverrideRepository.go @@ -3,7 +3,7 @@ package mocks import ( - chartConfig "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + chartConfig "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" mock "github.com/stretchr/testify/mock" pg "github.com/go-pg/pg" diff --git a/internal/sql/repository/chartConfig/mocks/PipelineConfigRepository.go b/internals/sql/repository/chartConfig/mocks/PipelineConfigRepository.go similarity index 98% rename from internal/sql/repository/chartConfig/mocks/PipelineConfigRepository.go rename to internals/sql/repository/chartConfig/mocks/PipelineConfigRepository.go index 7122cb2671..4c8d2f67fb 100644 --- a/internal/sql/repository/chartConfig/mocks/PipelineConfigRepository.go +++ b/internals/sql/repository/chartConfig/mocks/PipelineConfigRepository.go @@ -3,7 +3,7 @@ package mocks import ( - chartConfig "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + chartConfig "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" mock "github.com/stretchr/testify/mock" diff --git a/internal/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go b/internals/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go similarity index 98% rename from internal/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go rename to internals/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go index 19e6cef2ad..3aa00d6a55 100644 --- a/internal/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go +++ b/internals/sql/repository/chartConfig/mocks/PipelineOverrideRepository.go @@ -3,10 +3,10 @@ package mocks import ( - chartConfig "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + chartConfig "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" mock "github.com/stretchr/testify/mock" - models "github.com/devtron-labs/devtron/internal/sql/models" + models "github.com/devtron-labs/devtron/internals/sql/models" ) // PipelineOverrideRepository is an autogenerated mock type for the PipelineOverrideRepository type diff --git a/internal/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go b/internals/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go similarity index 100% rename from internal/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go rename to internals/sql/repository/dockerRegistry/DockerArtifactStoreRepository.go diff --git a/internal/sql/repository/dockerRegistry/DockerRegistryIpsConfigRepository.go b/internals/sql/repository/dockerRegistry/DockerRegistryIpsConfigRepository.go similarity index 100% rename from internal/sql/repository/dockerRegistry/DockerRegistryIpsConfigRepository.go rename to internals/sql/repository/dockerRegistry/DockerRegistryIpsConfigRepository.go diff --git a/internal/sql/repository/dockerRegistry/OCIRegistryConfigRepository.go b/internals/sql/repository/dockerRegistry/OCIRegistryConfigRepository.go similarity index 100% rename from internal/sql/repository/dockerRegistry/OCIRegistryConfigRepository.go rename to internals/sql/repository/dockerRegistry/OCIRegistryConfigRepository.go diff --git a/internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go b/internals/sql/repository/helper/AppListingRepositoryQueryBuilder.go similarity index 100% rename from internal/sql/repository/helper/AppListingRepositoryQueryBuilder.go rename to internals/sql/repository/helper/AppListingRepositoryQueryBuilder.go diff --git a/internal/sql/repository/imageTagging/ImageTaggingRepository.go b/internals/sql/repository/imageTagging/ImageTaggingRepository.go similarity index 100% rename from internal/sql/repository/imageTagging/ImageTaggingRepository.go rename to internals/sql/repository/imageTagging/ImageTaggingRepository.go diff --git a/internal/sql/repository/imageTagging/mocks/ImageTaggingRepository.go b/internals/sql/repository/imageTagging/mocks/ImageTaggingRepository.go similarity index 98% rename from internal/sql/repository/imageTagging/mocks/ImageTaggingRepository.go rename to internals/sql/repository/imageTagging/mocks/ImageTaggingRepository.go index 8566ed44fb..3680c6225a 100644 --- a/internal/sql/repository/imageTagging/mocks/ImageTaggingRepository.go +++ b/internals/sql/repository/imageTagging/mocks/ImageTaggingRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - repository "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + repository "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" ) // ImageTaggingRepository is an autogenerated mock type for the ImageTaggingRepository type diff --git a/internal/sql/repository/mocks/AppLevelMetricsRepository.go b/internals/sql/repository/mocks/AppLevelMetricsRepository.go similarity index 100% rename from internal/sql/repository/mocks/AppLevelMetricsRepository.go rename to internals/sql/repository/mocks/AppLevelMetricsRepository.go diff --git a/internal/sql/repository/mocks/AppListingRepository.go b/internals/sql/repository/mocks/AppListingRepository.go similarity index 99% rename from internal/sql/repository/mocks/AppListingRepository.go rename to internals/sql/repository/mocks/AppListingRepository.go index 719eefbe6d..5dd8f0b337 100644 --- a/internal/sql/repository/mocks/AppListingRepository.go +++ b/internals/sql/repository/mocks/AppListingRepository.go @@ -7,7 +7,7 @@ import ( bean "github.com/devtron-labs/devtron/api/bean" - helper "github.com/devtron-labs/devtron/internal/sql/repository/helper" + helper "github.com/devtron-labs/devtron/internals/sql/repository/helper" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/AttributesRepository.go b/internals/sql/repository/mocks/AttributesRepository.go similarity index 98% rename from internal/sql/repository/mocks/AttributesRepository.go rename to internals/sql/repository/mocks/AttributesRepository.go index 46d3031a09..daf55d4037 100644 --- a/internal/sql/repository/mocks/AttributesRepository.go +++ b/internals/sql/repository/mocks/AttributesRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" ) // AttributesRepository is an autogenerated mock type for the AttributesRepository type diff --git a/internal/sql/repository/mocks/CiArtifactRepository.go b/internals/sql/repository/mocks/CiArtifactRepository.go similarity index 99% rename from internal/sql/repository/mocks/CiArtifactRepository.go rename to internals/sql/repository/mocks/CiArtifactRepository.go index b9e1304ca9..dfee85c00e 100644 --- a/internal/sql/repository/mocks/CiArtifactRepository.go +++ b/internals/sql/repository/mocks/CiArtifactRepository.go @@ -6,7 +6,7 @@ import ( bean "github.com/devtron-labs/devtron/api/bean" mock "github.com/stretchr/testify/mock" - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" ) // CiArtifactRepository is an autogenerated mock type for the CiArtifactRepository type diff --git a/internal/sql/repository/mocks/CiTemplateOverrideRepository.go b/internals/sql/repository/mocks/CiTemplateOverrideRepository.go similarity index 97% rename from internal/sql/repository/mocks/CiTemplateOverrideRepository.go rename to internals/sql/repository/mocks/CiTemplateOverrideRepository.go index 556b9acaad..53be6623ac 100644 --- a/internal/sql/repository/mocks/CiTemplateOverrideRepository.go +++ b/internals/sql/repository/mocks/CiTemplateOverrideRepository.go @@ -3,7 +3,7 @@ package mocks import ( - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/CiTemplateRepository.go b/internals/sql/repository/mocks/CiTemplateRepository.go similarity index 97% rename from internal/sql/repository/mocks/CiTemplateRepository.go rename to internals/sql/repository/mocks/CiTemplateRepository.go index f194ae4964..2208f7b964 100644 --- a/internal/sql/repository/mocks/CiTemplateRepository.go +++ b/internals/sql/repository/mocks/CiTemplateRepository.go @@ -3,7 +3,7 @@ package mocks import ( - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/DeploymentTemplateRepository.go b/internals/sql/repository/mocks/DeploymentTemplateRepository.go similarity index 97% rename from internal/sql/repository/mocks/DeploymentTemplateRepository.go rename to internals/sql/repository/mocks/DeploymentTemplateRepository.go index adc2f18860..049e77c00f 100644 --- a/internal/sql/repository/mocks/DeploymentTemplateRepository.go +++ b/internals/sql/repository/mocks/DeploymentTemplateRepository.go @@ -3,7 +3,7 @@ package mocks import ( - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go b/internals/sql/repository/mocks/EnvLevelAppMetricsRepository.go similarity index 100% rename from internal/sql/repository/mocks/EnvLevelAppMetricsRepository.go rename to internals/sql/repository/mocks/EnvLevelAppMetricsRepository.go diff --git a/internal/sql/repository/mocks/NotificationSettingsRepository.go b/internals/sql/repository/mocks/NotificationSettingsRepository.go similarity index 99% rename from internal/sql/repository/mocks/NotificationSettingsRepository.go rename to internals/sql/repository/mocks/NotificationSettingsRepository.go index f64a06e437..a3403ae0af 100644 --- a/internal/sql/repository/mocks/NotificationSettingsRepository.go +++ b/internals/sql/repository/mocks/NotificationSettingsRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" ) // NotificationSettingsRepository is an autogenerated mock type for the NotificationSettingsRepository type diff --git a/internal/sql/repository/mocks/TerminalAccessRepository.go b/internals/sql/repository/mocks/TerminalAccessRepository.go similarity index 98% rename from internal/sql/repository/mocks/TerminalAccessRepository.go rename to internals/sql/repository/mocks/TerminalAccessRepository.go index 32fb189ef5..740db09bfc 100644 --- a/internal/sql/repository/mocks/TerminalAccessRepository.go +++ b/internals/sql/repository/mocks/TerminalAccessRepository.go @@ -3,7 +3,7 @@ package mocks import ( - models "github.com/devtron-labs/devtron/internal/sql/models" + models "github.com/devtron-labs/devtron/internals/sql/models" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/mocks/WebhookNotificationRepository.go b/internals/sql/repository/mocks/WebhookNotificationRepository.go similarity index 98% rename from internal/sql/repository/mocks/WebhookNotificationRepository.go rename to internals/sql/repository/mocks/WebhookNotificationRepository.go index e48ce9ce1d..8252fc101d 100644 --- a/internal/sql/repository/mocks/WebhookNotificationRepository.go +++ b/internals/sql/repository/mocks/WebhookNotificationRepository.go @@ -3,7 +3,7 @@ package mocks import ( - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/pipelineConfig/AppLabelsRepository.go b/internals/sql/repository/pipelineConfig/AppLabelsRepository.go similarity index 98% rename from internal/sql/repository/pipelineConfig/AppLabelsRepository.go rename to internals/sql/repository/pipelineConfig/AppLabelsRepository.go index f64b0c5bb1..3cecf0705c 100644 --- a/internal/sql/repository/pipelineConfig/AppLabelsRepository.go +++ b/internals/sql/repository/pipelineConfig/AppLabelsRepository.go @@ -19,7 +19,7 @@ package pipelineConfig import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go b/internals/sql/repository/pipelineConfig/CdWorfkflowRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go rename to internals/sql/repository/pipelineConfig/CdWorfkflowRepository.go index b85959a672..88ee982eb8 100644 --- a/internal/sql/repository/pipelineConfig/CdWorfkflowRepository.go +++ b/internals/sql/repository/pipelineConfig/CdWorfkflowRepository.go @@ -25,9 +25,9 @@ import ( "github.com/devtron-labs/devtron/api/bean" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" util4 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" diff --git a/internal/sql/repository/pipelineConfig/CiBuildConfigRepository.go b/internals/sql/repository/pipelineConfig/CiBuildConfigRepository.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiBuildConfigRepository.go rename to internals/sql/repository/pipelineConfig/CiBuildConfigRepository.go diff --git a/internal/sql/repository/pipelineConfig/CiBuildConfigRepository_test.go b/internals/sql/repository/pipelineConfig/CiBuildConfigRepository_test.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiBuildConfigRepository_test.go rename to internals/sql/repository/pipelineConfig/CiBuildConfigRepository_test.go diff --git a/internal/sql/repository/pipelineConfig/CiPipelineMaterial.go b/internals/sql/repository/pipelineConfig/CiPipelineMaterial.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiPipelineMaterial.go rename to internals/sql/repository/pipelineConfig/CiPipelineMaterial.go diff --git a/internal/sql/repository/pipelineConfig/CiPipelineRepository.go b/internals/sql/repository/pipelineConfig/CiPipelineRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/CiPipelineRepository.go rename to internals/sql/repository/pipelineConfig/CiPipelineRepository.go index ff49491d7e..1882d2d0bb 100644 --- a/internal/sql/repository/pipelineConfig/CiPipelineRepository.go +++ b/internals/sql/repository/pipelineConfig/CiPipelineRepository.go @@ -18,7 +18,7 @@ package pipelineConfig import ( - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/internal/sql/repository/pipelineConfig/CiPipelineRepository_test.go b/internals/sql/repository/pipelineConfig/CiPipelineRepository_test.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiPipelineRepository_test.go rename to internals/sql/repository/pipelineConfig/CiPipelineRepository_test.go diff --git a/internal/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go b/internals/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go similarity index 98% rename from internal/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go rename to internals/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go index 8391649549..ec5ecb48fb 100644 --- a/internal/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go +++ b/internals/sql/repository/pipelineConfig/CiTemplateOverrideRepository.go @@ -1,7 +1,7 @@ package pipelineConfig import ( - "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/internal/sql/repository/pipelineConfig/CiTemplateRepository.go b/internals/sql/repository/pipelineConfig/CiTemplateRepository.go similarity index 97% rename from internal/sql/repository/pipelineConfig/CiTemplateRepository.go rename to internals/sql/repository/pipelineConfig/CiTemplateRepository.go index 6ee7a2c5ff..4d3a28d5e6 100644 --- a/internal/sql/repository/pipelineConfig/CiTemplateRepository.go +++ b/internals/sql/repository/pipelineConfig/CiTemplateRepository.go @@ -18,8 +18,8 @@ package pipelineConfig import ( - "github.com/devtron-labs/devtron/internal/sql/repository/app" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "github.com/juju/errors" diff --git a/internal/sql/repository/pipelineConfig/CiTemplateRepository_test.go b/internals/sql/repository/pipelineConfig/CiTemplateRepository_test.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiTemplateRepository_test.go rename to internals/sql/repository/pipelineConfig/CiTemplateRepository_test.go diff --git a/internal/sql/repository/pipelineConfig/CiWorkflowRepository.go b/internals/sql/repository/pipelineConfig/CiWorkflowRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/CiWorkflowRepository.go rename to internals/sql/repository/pipelineConfig/CiWorkflowRepository.go index 338032227a..0cc6f32040 100644 --- a/internal/sql/repository/pipelineConfig/CiWorkflowRepository.go +++ b/internals/sql/repository/pipelineConfig/CiWorkflowRepository.go @@ -19,7 +19,7 @@ package pipelineConfig import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/go-pg/pg" "go.uber.org/zap" "time" diff --git a/internal/sql/repository/pipelineConfig/CiWorkflowRepository_test.go b/internals/sql/repository/pipelineConfig/CiWorkflowRepository_test.go similarity index 100% rename from internal/sql/repository/pipelineConfig/CiWorkflowRepository_test.go rename to internals/sql/repository/pipelineConfig/CiWorkflowRepository_test.go diff --git a/internal/sql/repository/pipelineConfig/MaterialRepository.go b/internals/sql/repository/pipelineConfig/MaterialRepository.go similarity index 98% rename from internal/sql/repository/pipelineConfig/MaterialRepository.go rename to internals/sql/repository/pipelineConfig/MaterialRepository.go index 5dc8b4456e..1ecf8f1b42 100644 --- a/internal/sql/repository/pipelineConfig/MaterialRepository.go +++ b/internals/sql/repository/pipelineConfig/MaterialRepository.go @@ -18,8 +18,8 @@ package pipelineConfig import ( - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" ) diff --git a/internal/sql/repository/pipelineConfig/PipelineRepository.go b/internals/sql/repository/pipelineConfig/PipelineRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/PipelineRepository.go rename to internals/sql/repository/pipelineConfig/PipelineRepository.go index e541ffdb18..5e1dcb1b16 100644 --- a/internal/sql/repository/pipelineConfig/PipelineRepository.go +++ b/internals/sql/repository/pipelineConfig/PipelineRepository.go @@ -20,10 +20,10 @@ package pipelineConfig import ( "github.com/devtron-labs/common-lib/utils/k8s/health" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/util" util2 "github.com/devtron-labs/devtron/pkg/appStore/util" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/internal/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go b/internals/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go rename to internals/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go index 47744893d3..7af602e4da 100644 --- a/internal/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go +++ b/internals/sql/repository/pipelineConfig/PipelineStatusSyncDetailRepository.go @@ -1,7 +1,7 @@ package pipelineConfig import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/internal/sql/repository/pipelineConfig/PipelineStatusTimelineRepository.go b/internals/sql/repository/pipelineConfig/PipelineStatusTimelineRepository.go similarity index 100% rename from internal/sql/repository/pipelineConfig/PipelineStatusTimelineRepository.go rename to internals/sql/repository/pipelineConfig/PipelineStatusTimelineRepository.go diff --git a/internal/sql/repository/pipelineConfig/PipelineStatusTimelineResourcesRepository.go b/internals/sql/repository/pipelineConfig/PipelineStatusTimelineResourcesRepository.go similarity index 100% rename from internal/sql/repository/pipelineConfig/PipelineStatusTimelineResourcesRepository.go rename to internals/sql/repository/pipelineConfig/PipelineStatusTimelineResourcesRepository.go diff --git a/internal/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go b/internals/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go rename to internals/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go index 48cf4109e7..596f085e33 100644 --- a/internal/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go +++ b/internals/sql/repository/pipelineConfig/mocks/CdWorkflowRepository.go @@ -9,7 +9,7 @@ import ( pg "github.com/go-pg/pg" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" ) // CdWorkflowRepository is an autogenerated mock type for the CdWorkflowRepository type diff --git a/internal/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go b/internals/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go similarity index 99% rename from internal/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go rename to internals/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go index 67b0709cb9..397978f36e 100644 --- a/internal/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go +++ b/internals/sql/repository/pipelineConfig/mocks/CiPipelineMaterial.go @@ -7,7 +7,7 @@ package mocks import ( reflect "reflect" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" pg "github.com/go-pg/pg" gomock "github.com/golang/mock/gomock" ) diff --git a/internal/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go b/internals/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go rename to internals/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go index d062a059fc..bc0eab7ca2 100644 --- a/internal/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go +++ b/internals/sql/repository/pipelineConfig/mocks/CiPipelineRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" ) // CiPipelineRepository is an autogenerated mock type for the CiPipelineRepository type diff --git a/internal/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go b/internals/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go rename to internals/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go index d0ebafb3ba..d4418d03cd 100644 --- a/internal/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go +++ b/internals/sql/repository/pipelineConfig/mocks/CiWorkflowRepository.go @@ -3,7 +3,7 @@ package mocks import ( - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/sql/repository/pipelineConfig/mocks/PipelineRepository.go b/internals/sql/repository/pipelineConfig/mocks/PipelineRepository.go similarity index 99% rename from internal/sql/repository/pipelineConfig/mocks/PipelineRepository.go rename to internals/sql/repository/pipelineConfig/mocks/PipelineRepository.go index 9cc9003666..38d329748f 100644 --- a/internal/sql/repository/pipelineConfig/mocks/PipelineRepository.go +++ b/internals/sql/repository/pipelineConfig/mocks/PipelineRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" ) // PipelineRepository is an autogenerated mock type for the PipelineRepository type diff --git a/internal/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go b/internals/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go similarity index 98% rename from internal/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go rename to internals/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go index 70a1baba42..6c4ce99bcd 100644 --- a/internal/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go +++ b/internals/sql/repository/pipelineConfig/mocks/PipelineStatusTimelineRepository.go @@ -6,7 +6,7 @@ import ( pg "github.com/go-pg/pg" mock "github.com/stretchr/testify/mock" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" ) // PipelineStatusTimelineRepository is an autogenerated mock type for the PipelineStatusTimelineRepository type diff --git a/internal/sql/repository/resourceGroup/ResourceGroupMappingRepository.go b/internals/sql/repository/resourceGroup/ResourceGroupMappingRepository.go similarity index 100% rename from internal/sql/repository/resourceGroup/ResourceGroupMappingRepository.go rename to internals/sql/repository/resourceGroup/ResourceGroupMappingRepository.go diff --git a/internal/sql/repository/resourceGroup/ResourceGroupRepository.go b/internals/sql/repository/resourceGroup/ResourceGroupRepository.go similarity index 100% rename from internal/sql/repository/resourceGroup/ResourceGroupRepository.go rename to internals/sql/repository/resourceGroup/ResourceGroupRepository.go diff --git a/internal/sql/repository/security/CvePolicyControle.go b/internals/sql/repository/security/CvePolicyControle.go similarity index 100% rename from internal/sql/repository/security/CvePolicyControle.go rename to internals/sql/repository/security/CvePolicyControle.go diff --git a/internal/sql/repository/security/CvePolicyControle_test.go b/internals/sql/repository/security/CvePolicyControle_test.go similarity index 100% rename from internal/sql/repository/security/CvePolicyControle_test.go rename to internals/sql/repository/security/CvePolicyControle_test.go diff --git a/internal/sql/repository/security/CveStoreRepository.go b/internals/sql/repository/security/CveStoreRepository.go similarity index 98% rename from internal/sql/repository/security/CveStoreRepository.go rename to internals/sql/repository/security/CveStoreRepository.go index 7519c3f6e7..0d9c5fd523 100644 --- a/internal/sql/repository/security/CveStoreRepository.go +++ b/internals/sql/repository/security/CveStoreRepository.go @@ -19,7 +19,7 @@ package security import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/internal/sql/repository/security/ImageScanDeployInfoRepository.go b/internals/sql/repository/security/ImageScanDeployInfoRepository.go similarity index 100% rename from internal/sql/repository/security/ImageScanDeployInfoRepository.go rename to internals/sql/repository/security/ImageScanDeployInfoRepository.go diff --git a/internal/sql/repository/security/ImageScanHistoryRepository.go b/internals/sql/repository/security/ImageScanHistoryRepository.go similarity index 100% rename from internal/sql/repository/security/ImageScanHistoryRepository.go rename to internals/sql/repository/security/ImageScanHistoryRepository.go diff --git a/internal/sql/repository/security/ImageScanObjectMetaRepository.go b/internals/sql/repository/security/ImageScanObjectMetaRepository.go similarity index 100% rename from internal/sql/repository/security/ImageScanObjectMetaRepository.go rename to internals/sql/repository/security/ImageScanObjectMetaRepository.go diff --git a/internal/sql/repository/security/ImageScanResultRepository.go b/internals/sql/repository/security/ImageScanResultRepository.go similarity index 100% rename from internal/sql/repository/security/ImageScanResultRepository.go rename to internals/sql/repository/security/ImageScanResultRepository.go diff --git a/internal/sql/repository/security/ScanToolExecutionHistoryMapping.go b/internals/sql/repository/security/ScanToolExecutionHistoryMapping.go similarity index 100% rename from internal/sql/repository/security/ScanToolExecutionHistoryMapping.go rename to internals/sql/repository/security/ScanToolExecutionHistoryMapping.go diff --git a/internal/sql/repository/security/ScanToolMetaDataRepository.go b/internals/sql/repository/security/ScanToolMetaDataRepository.go similarity index 100% rename from internal/sql/repository/security/ScanToolMetaDataRepository.go rename to internals/sql/repository/security/ScanToolMetaDataRepository.go diff --git a/internal/util/BasicProviders.go b/internals/util/BasicProviders.go similarity index 100% rename from internal/util/BasicProviders.go rename to internals/util/BasicProviders.go diff --git a/internal/util/ChartTemplateService.go b/internals/util/ChartTemplateService.go similarity index 99% rename from internal/util/ChartTemplateService.go rename to internals/util/ChartTemplateService.go index bd25fa384c..e32cc39d93 100644 --- a/internal/util/ChartTemplateService.go +++ b/internals/util/ChartTemplateService.go @@ -29,7 +29,7 @@ import ( "strings" "time" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" dirCopy "github.com/otiai10/copy" "go.opentelemetry.io/otel" "go.uber.org/zap" diff --git a/internal/util/ChartTemplateService_test.go b/internals/util/ChartTemplateService_test.go similarity index 100% rename from internal/util/ChartTemplateService_test.go rename to internals/util/ChartTemplateService_test.go diff --git a/internal/util/CollectionUtil.go b/internals/util/CollectionUtil.go similarity index 100% rename from internal/util/CollectionUtil.go rename to internals/util/CollectionUtil.go diff --git a/internal/util/CollectionUtil_test.go b/internals/util/CollectionUtil_test.go similarity index 100% rename from internal/util/CollectionUtil_test.go rename to internals/util/CollectionUtil_test.go diff --git a/internal/util/EcrService.go b/internals/util/EcrService.go similarity index 99% rename from internal/util/EcrService.go rename to internals/util/EcrService.go index e2bd9f908d..7f629cf909 100644 --- a/internal/util/EcrService.go +++ b/internals/util/EcrService.go @@ -29,7 +29,7 @@ import ( "log" ) -//FIXME: this code is temp +// FIXME: this code is temp func CreateEcrRepo(repoName string, reg string, accessKey string, secretKey string) error { region := reg //fmt.Printf("repoName %s, reg %s, accessKey %s, secretKey %s\n", repoName, reg, accessKey, secretKey) diff --git a/internal/util/ErrorCoreApp.go b/internals/util/ErrorCoreApp.go similarity index 100% rename from internal/util/ErrorCoreApp.go rename to internals/util/ErrorCoreApp.go diff --git a/internal/util/ErrorUtil.go b/internals/util/ErrorUtil.go similarity index 100% rename from internal/util/ErrorUtil.go rename to internals/util/ErrorUtil.go diff --git a/internal/util/JiraUtil/EncryptionUtil.go b/internals/util/JiraUtil/EncryptionUtil.go similarity index 100% rename from internal/util/JiraUtil/EncryptionUtil.go rename to internals/util/JiraUtil/EncryptionUtil.go diff --git a/internal/util/MergeUtil.go b/internals/util/MergeUtil.go similarity index 100% rename from internal/util/MergeUtil.go rename to internals/util/MergeUtil.go diff --git a/internal/util/TopoSort.go b/internals/util/TopoSort.go similarity index 100% rename from internal/util/TopoSort.go rename to internals/util/TopoSort.go diff --git a/internal/util/TopoSort_test.go b/internals/util/TopoSort_test.go similarity index 100% rename from internal/util/TopoSort_test.go rename to internals/util/TopoSort_test.go diff --git a/internal/util/UrlUtil.go b/internals/util/UrlUtil.go similarity index 100% rename from internal/util/UrlUtil.go rename to internals/util/UrlUtil.go diff --git a/internal/util/ValidateUtil.go b/internals/util/ValidateUtil.go similarity index 100% rename from internal/util/ValidateUtil.go rename to internals/util/ValidateUtil.go diff --git a/internal/util/mocks/ChartTemplateService.go b/internals/util/mocks/ChartTemplateService.go similarity index 99% rename from internal/util/mocks/ChartTemplateService.go rename to internals/util/mocks/ChartTemplateService.go index b6af1f7ead..8a66733e27 100644 --- a/internal/util/mocks/ChartTemplateService.go +++ b/internals/util/mocks/ChartTemplateService.go @@ -10,7 +10,7 @@ import ( mock "github.com/stretchr/testify/mock" - util "github.com/devtron-labs/devtron/internal/util" + util "github.com/devtron-labs/devtron/internals/util" ) // ChartTemplateService is an autogenerated mock type for the ChartTemplateService type diff --git a/pkg/app/AppCrudOperationService.go b/pkg/app/AppCrudOperationService.go index 377144e0bf..bdf389528e 100644 --- a/pkg/app/AppCrudOperationService.go +++ b/pkg/app/AppCrudOperationService.go @@ -26,9 +26,9 @@ import ( "time" "github.com/devtron-labs/common-lib/utils/k8s" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/bean" diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 162133327d..a77d477b51 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -28,8 +28,8 @@ import ( "time" "github.com/devtron-labs/common-lib/utils/k8s/health" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository/app" userrepository "github.com/devtron-labs/devtron/pkg/auth/user/repository" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -41,12 +41,12 @@ import ( "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "go.uber.org/zap" ) diff --git a/pkg/app/AppListingViewBuilder.go b/pkg/app/AppListingViewBuilder.go index 02c5c14a6d..9a3e83765f 100644 --- a/pkg/app/AppListingViewBuilder.go +++ b/pkg/app/AppListingViewBuilder.go @@ -19,7 +19,7 @@ package app import ( "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "go.uber.org/zap" "sort" "strconv" diff --git a/pkg/app/AppService.go b/pkg/app/AppService.go index 343d615f63..7c51f6080c 100644 --- a/pkg/app/AppService.go +++ b/pkg/app/AppService.go @@ -42,11 +42,11 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" client "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - . "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + . "github.com/devtron-labs/devtron/internals/util" status2 "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appStatus" repository4 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/app/DeploymentEventHandler.go b/pkg/app/DeploymentEventHandler.go index 803113aba8..282bf1135e 100644 --- a/pkg/app/DeploymentEventHandler.go +++ b/pkg/app/DeploymentEventHandler.go @@ -24,7 +24,7 @@ import ( "github.com/devtron-labs/devtron/api/bean" client "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" util "github.com/devtron-labs/devtron/util/event" "go.uber.org/zap" ) diff --git a/pkg/app/ManifestPushService.go b/pkg/app/ManifestPushService.go index 6502a797d8..3daba0e4b0 100644 --- a/pkg/app/ManifestPushService.go +++ b/pkg/app/ManifestPushService.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app/bean" status2 "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" diff --git a/pkg/app/ReleaseDataService.go b/pkg/app/ReleaseDataService.go index 44b8f7928d..e2eeb69fd4 100644 --- a/pkg/app/ReleaseDataService.go +++ b/pkg/app/ReleaseDataService.go @@ -21,8 +21,8 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" client "github.com/devtron-labs/devtron/client/events" "github.com/devtron-labs/devtron/client/lens" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "go.uber.org/zap" ) diff --git a/pkg/app/integrationTest/AppServiceDeployment_test.go b/pkg/app/integrationTest/AppServiceDeployment_test.go index a05fb7ce07..188432f92b 100644 --- a/pkg/app/integrationTest/AppServiceDeployment_test.go +++ b/pkg/app/integrationTest/AppServiceDeployment_test.go @@ -3,11 +3,11 @@ package integrationTest import ( "context" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - mocks3 "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig/mocks" - mocks5 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + mocks3 "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig/mocks" + mocks5 "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" mocks2 "github.com/devtron-labs/devtron/pkg/chartRepo/repository/mocks" diff --git a/pkg/app/integrationTest/AppService_test.go b/pkg/app/integrationTest/AppService_test.go index de06a34394..0e0bb95015 100644 --- a/pkg/app/integrationTest/AppService_test.go +++ b/pkg/app/integrationTest/AppService_test.go @@ -15,12 +15,12 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" client1 "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" diff --git a/pkg/app/mocks/AppService.go b/pkg/app/mocks/AppService.go index a2654ac66c..853fb94414 100644 --- a/pkg/app/mocks/AppService.go +++ b/pkg/app/mocks/AppService.go @@ -9,9 +9,9 @@ import ( mock "github.com/stretchr/testify/mock" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" - repository "github.com/devtron-labs/devtron/internal/sql/repository" + repository "github.com/devtron-labs/devtron/internals/sql/repository" time "time" diff --git a/pkg/app/status/PipelineStatusSyncDetailService.go b/pkg/app/status/PipelineStatusSyncDetailService.go index 143926c533..28aa004c4b 100644 --- a/pkg/app/status/PipelineStatusSyncDetailService.go +++ b/pkg/app/status/PipelineStatusSyncDetailService.go @@ -1,7 +1,7 @@ package status import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/app/status/PipelineStatusTimelineResourcesService.go b/pkg/app/status/PipelineStatusTimelineResourcesService.go index 8c9d9a2ff6..a37b3579d4 100644 --- a/pkg/app/status/PipelineStatusTimelineResourcesService.go +++ b/pkg/app/status/PipelineStatusTimelineResourcesService.go @@ -3,7 +3,7 @@ package status import ( "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/app/status/PipelineStatusTimelineService.go b/pkg/app/status/PipelineStatusTimelineService.go index 113be7a596..3bcc368cfb 100644 --- a/pkg/app/status/PipelineStatusTimelineService.go +++ b/pkg/app/status/PipelineStatusTimelineService.go @@ -4,8 +4,8 @@ import ( "fmt" "time" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/appClone/AppCloneService.go b/pkg/appClone/AppCloneService.go index 47caeea1c6..1467f90027 100644 --- a/pkg/appClone/AppCloneService.go +++ b/pkg/appClone/AppCloneService.go @@ -21,12 +21,12 @@ import ( "context" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/constants" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + appWorkflow2 "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/pkg/attributes" diff --git a/pkg/appClone/batch/Build.go b/pkg/appClone/batch/Build.go index aa384aaa13..5f25cc3b69 100644 --- a/pkg/appClone/batch/Build.go +++ b/pkg/appClone/batch/Build.go @@ -19,9 +19,9 @@ package batch import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - pc "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + pc "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" v1 "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline" diff --git a/pkg/appClone/batch/DataHolder.go b/pkg/appClone/batch/DataHolder.go index 0c8e499ff1..ba713b3e86 100644 --- a/pkg/appClone/batch/DataHolder.go +++ b/pkg/appClone/batch/DataHolder.go @@ -20,7 +20,7 @@ package batch import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/cluster" bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" diff --git a/pkg/appClone/batch/DataHolder_test.go b/pkg/appClone/batch/DataHolder_test.go index b5e03d3913..eefa006f94 100644 --- a/pkg/appClone/batch/DataHolder_test.go +++ b/pkg/appClone/batch/DataHolder_test.go @@ -19,7 +19,7 @@ package batch import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" v1 "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/pipeline" diff --git a/pkg/appClone/batch/Deployment.go b/pkg/appClone/batch/Deployment.go index 69eba1a8e5..ead98c8548 100644 --- a/pkg/appClone/batch/Deployment.go +++ b/pkg/appClone/batch/Deployment.go @@ -21,9 +21,9 @@ import ( "context" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - pc "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + pc "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/pkg/appClone/batch/DeploymentTemplate.go b/pkg/appClone/batch/DeploymentTemplate.go index f214ebd991..f11bd7d0c5 100644 --- a/pkg/appClone/batch/DeploymentTemplate.go +++ b/pkg/appClone/batch/DeploymentTemplate.go @@ -21,7 +21,7 @@ import ( "context" "encoding/json" "fmt" - pc "github.com/devtron-labs/devtron/internal/sql/repository/app" + pc "github.com/devtron-labs/devtron/internals/sql/repository/app" v1 "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/util" diff --git a/pkg/appClone/batch/Mocks_test.go b/pkg/appClone/batch/Mocks_test.go index 2814607341..8cd9a431e1 100644 --- a/pkg/appClone/batch/Mocks_test.go +++ b/pkg/appClone/batch/Mocks_test.go @@ -21,9 +21,9 @@ import ( "context" "github.com/devtron-labs/common-lib/utils/k8s" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster" bean3 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" diff --git a/pkg/appClone/batch/Workflow.go b/pkg/appClone/batch/Workflow.go index 8f0bc308c6..c71f46a51a 100644 --- a/pkg/appClone/batch/Workflow.go +++ b/pkg/appClone/batch/Workflow.go @@ -20,7 +20,7 @@ package batch import ( "context" "fmt" - pc "github.com/devtron-labs/devtron/internal/sql/repository/app" + pc "github.com/devtron-labs/devtron/internals/sql/repository/app" v1 "github.com/devtron-labs/devtron/pkg/apis/devtron/v1" "github.com/devtron-labs/devtron/pkg/appWorkflow" "github.com/devtron-labs/devtron/util" diff --git a/pkg/appStatus/AppStatusService.go b/pkg/appStatus/AppStatusService.go index 071c16b0e1..77151efbec 100644 --- a/pkg/appStatus/AppStatusService.go +++ b/pkg/appStatus/AppStatusService.go @@ -1,7 +1,7 @@ package appStatus import ( - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/util/rbac" "github.com/go-pg/pg" diff --git a/pkg/appStatus/AppStatusService_test.go b/pkg/appStatus/AppStatusService_test.go index e8f24b2901..561c1ef0e6 100644 --- a/pkg/appStatus/AppStatusService_test.go +++ b/pkg/appStatus/AppStatusService_test.go @@ -3,9 +3,9 @@ package appStatus import ( "fmt" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus/mocks" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/pkg/appStore/adapter/Adapter.go b/pkg/appStore/adapter/Adapter.go index 4f4035c04b..a9de12f0c1 100644 --- a/pkg/appStore/adapter/Adapter.go +++ b/pkg/appStore/adapter/Adapter.go @@ -3,8 +3,8 @@ package adapter import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/appStore/chartGroup/ChartGroupService.go b/pkg/appStore/chartGroup/ChartGroupService.go index 011778c982..bda84fa434 100644 --- a/pkg/appStore/chartGroup/ChartGroupService.go +++ b/pkg/appStore/chartGroup/ChartGroupService.go @@ -27,8 +27,8 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" diff --git a/pkg/appStore/chartProvider/ChartProviderService.go b/pkg/appStore/chartProvider/ChartProviderService.go index 7f926798f5..b8c40b63b4 100644 --- a/pkg/appStore/chartProvider/ChartProviderService.go +++ b/pkg/appStore/chartProvider/ChartProviderService.go @@ -18,8 +18,8 @@ package chartProvider import ( - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/util" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/chartRepo" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/go-pg/pg" diff --git a/pkg/appStore/chartProvider/bean.go b/pkg/appStore/chartProvider/bean.go index 2efab9565b..77552e4a92 100644 --- a/pkg/appStore/chartProvider/bean.go +++ b/pkg/appStore/chartProvider/bean.go @@ -1,6 +1,6 @@ package chartProvider -import repository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" +import repository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" type ChartProviderResponseDto struct { Id string `json:"id" validate:"required"` diff --git a/pkg/appStore/discover/repository/AppStoreRepository.go b/pkg/appStore/discover/repository/AppStoreRepository.go index 1910fa26d9..a44c646066 100644 --- a/pkg/appStore/discover/repository/AppStoreRepository.go +++ b/pkg/appStore/discover/repository/AppStoreRepository.go @@ -18,7 +18,7 @@ package appStoreDiscoverRepository import ( - dockerArtifactStoreRegistry "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + dockerArtifactStoreRegistry "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/appStore/discover/service/AppStoreService.go b/pkg/appStore/discover/service/AppStoreService.go index c46fe7898c..41f693b062 100644 --- a/pkg/appStore/discover/service/AppStoreService.go +++ b/pkg/appStore/discover/service/AppStoreService.go @@ -18,7 +18,7 @@ package service import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "go.uber.org/zap" diff --git a/pkg/appStore/installedApp/adapter/Adapter.go b/pkg/appStore/installedApp/adapter/Adapter.go index 424219e6bb..27e1a7a54b 100644 --- a/pkg/appStore/installedApp/adapter/Adapter.go +++ b/pkg/appStore/installedApp/adapter/Adapter.go @@ -1,7 +1,7 @@ package adapter import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "k8s.io/helm/pkg/proto/hapi/chart" diff --git a/pkg/appStore/installedApp/repository/InstalledAppRepository.go b/pkg/appStore/installedApp/repository/InstalledAppRepository.go index c3726e0f0d..c94840e38e 100644 --- a/pkg/appStore/installedApp/repository/InstalledAppRepository.go +++ b/pkg/appStore/installedApp/repository/InstalledAppRepository.go @@ -19,9 +19,9 @@ package repository import ( "github.com/devtron-labs/common-lib/utils/k8s/health" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + util2 "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index 290c8bcfb7..d54b60b9bf 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -3,11 +3,11 @@ package service import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" discoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 6b5bbefe54..47c91d39c1 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -27,9 +27,9 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository3 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go index 8d2fe43283..f3d498bfd7 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService_test.go @@ -6,8 +6,8 @@ import ( "github.com/devtron-labs/authenticator/client" util2 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository6 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" diff --git a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 29ff651f40..28319eb280 100644 --- a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -6,7 +6,7 @@ import ( bean2 "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" bean3 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" @@ -14,7 +14,7 @@ import ( "time" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go index 58833815c4..7183b4e816 100644 --- a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go +++ b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go @@ -26,9 +26,9 @@ import ( "github.com/Pallinder/go-randomdata" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStore/adapter" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreRepo "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go index 379efe1836..99822ed68d 100644 --- a/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go +++ b/pkg/appStore/installedApp/service/FullMode/InstalledAppDBExtendedService.go @@ -22,13 +22,13 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/common-lib/pubsub-lib/model" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "time" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" "github.com/devtron-labs/devtron/pkg/appStatus" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go index 1975a62037..63767a872a 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/DeploymentStatusService.go @@ -3,8 +3,8 @@ package deployment import ( "fmt" "github.com/devtron-labs/common-lib/utils/k8s/health" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go index 4bd6eac5af..65f9c1edeb 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go @@ -20,8 +20,8 @@ import ( openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/client/argocdServer" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/appStatus" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go index 1ce39f07cb..85c4f32d90 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppArgoCdService.go @@ -7,8 +7,8 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" "github.com/devtron-labs/devtron/client/argocdServer" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" cluster2 "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go index 1a6f5df018..c06c6e531d 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/InstalledAppGitOpsService.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/adapter" diff --git a/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange/InstalledAppDeploymentTypeChangeService.go b/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange/InstalledAppDeploymentTypeChangeService.go index ecab3a2d5c..de7acbc430 100644 --- a/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange/InstalledAppDeploymentTypeChangeService.go +++ b/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange/InstalledAppDeploymentTypeChangeService.go @@ -11,10 +11,10 @@ import ( client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/client/argocdServer" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/constants" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - appStatus2 "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + appStatus2 "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go index df03d62471..9803558f04 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "github.com/devtron-labs/devtron/api/helm-app/gRPC" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "net/http" "regexp" diff --git a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 38359016a5..8180a038a6 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -12,8 +12,8 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" diff --git a/pkg/appStore/installedApp/service/bean/bean.go b/pkg/appStore/installedApp/service/bean/bean.go index bcd00a6c6b..fb384be95f 100644 --- a/pkg/appStore/installedApp/service/bean/bean.go +++ b/pkg/appStore/installedApp/service/bean/bean.go @@ -1,7 +1,7 @@ package bean import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" ) diff --git a/pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go b/pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go index 5000cb125e..e2af6a64da 100644 --- a/pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go +++ b/pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService.go @@ -19,7 +19,7 @@ package appStoreDeploymentCommon import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "go.uber.org/zap" diff --git a/pkg/appStore/values/service/AppStoreValuesService.go b/pkg/appStore/values/service/AppStoreValuesService.go index 94d5e51195..a0af54e872 100644 --- a/pkg/appStore/values/service/AppStoreValuesService.go +++ b/pkg/appStore/values/service/AppStoreValuesService.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" appStoreDiscoverRepository "github.com/devtron-labs/devtron/pkg/appStore/discover/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" diff --git a/pkg/appWorkflow/AppWorkflowService.go b/pkg/appWorkflow/AppWorkflowService.go index 20833d5fbe..24d5681677 100644 --- a/pkg/appWorkflow/AppWorkflowService.go +++ b/pkg/appWorkflow/AppWorkflowService.go @@ -23,10 +23,10 @@ import ( "time" mapset "github.com/deckarep/golang-set" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" bean2 "github.com/devtron-labs/devtron/pkg/app/bean" "github.com/devtron-labs/devtron/pkg/auth/user" bean3 "github.com/devtron-labs/devtron/pkg/auth/user/bean" diff --git a/pkg/attributes/AttributesService.go b/pkg/attributes/AttributesService.go index 53aefaefba..bdbed88ddf 100644 --- a/pkg/attributes/AttributesService.go +++ b/pkg/attributes/AttributesService.go @@ -21,8 +21,8 @@ import ( "encoding/json" "errors" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "go.uber.org/zap" "net/http" diff --git a/pkg/attributes/UserAttributesService.go b/pkg/attributes/UserAttributesService.go index 70d1cf85f4..c68a8753c4 100644 --- a/pkg/attributes/UserAttributesService.go +++ b/pkg/attributes/UserAttributesService.go @@ -19,7 +19,7 @@ package attributes import ( "errors" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/go-pg/pg" "go.uber.org/zap" ) diff --git a/pkg/auth/user/RoleGroupService.go b/pkg/auth/user/RoleGroupService.go index 56a7bbe722..cbe69a444c 100644 --- a/pkg/auth/user/RoleGroupService.go +++ b/pkg/auth/user/RoleGroupService.go @@ -25,8 +25,8 @@ import ( "time" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" casbin2 "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" bean2 "github.com/devtron-labs/devtron/pkg/auth/user/bean" "github.com/devtron-labs/devtron/pkg/auth/user/repository" diff --git a/pkg/auth/user/UserAuthService.go b/pkg/auth/user/UserAuthService.go index dd00172da2..ee5fa2df01 100644 --- a/pkg/auth/user/UserAuthService.go +++ b/pkg/auth/user/UserAuthService.go @@ -39,8 +39,8 @@ import ( "github.com/coreos/go-oidc" "github.com/devtron-labs/devtron/api/bean" session2 "github.com/devtron-labs/devtron/client/argocdServer/session" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" "github.com/golang-jwt/jwt/v4" "github.com/gorilla/sessions" "go.uber.org/zap" diff --git a/pkg/auth/user/UserFlows_test.go b/pkg/auth/user/UserFlows_test.go index ecc5c5ce01..2a45a346ea 100644 --- a/pkg/auth/user/UserFlows_test.go +++ b/pkg/auth/user/UserFlows_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/sql" ) diff --git a/pkg/auth/user/UserService.go b/pkg/auth/user/UserService.go index 33e8d7b6f5..938d42412d 100644 --- a/pkg/auth/user/UserService.go +++ b/pkg/auth/user/UserService.go @@ -31,8 +31,8 @@ import ( "github.com/devtron-labs/authenticator/jwt" "github.com/devtron-labs/authenticator/middleware" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" casbin2 "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" bean2 "github.com/devtron-labs/devtron/pkg/auth/user/bean" "github.com/devtron-labs/devtron/pkg/auth/user/repository" diff --git a/pkg/auth/user/UserService_test.go b/pkg/auth/user/UserService_test.go index e4a7bfd86f..cd15291683 100644 --- a/pkg/auth/user/UserService_test.go +++ b/pkg/auth/user/UserService_test.go @@ -5,7 +5,7 @@ import ( "time" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" repomock2 "github.com/devtron-labs/devtron/pkg/auth/user/repository/RepositoryMocks" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/auth/user/helper/helper.go b/pkg/auth/user/helper/helper.go index 064c6724b7..4870ae4d2b 100644 --- a/pkg/auth/user/helper/helper.go +++ b/pkg/auth/user/helper/helper.go @@ -1,7 +1,7 @@ package helper import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user/bean" "golang.org/x/exp/slices" ) diff --git a/pkg/bean/app.go b/pkg/bean/app.go index 25f600d926..3f2d7f6a3c 100644 --- a/pkg/bean/app.go +++ b/pkg/bean/app.go @@ -20,11 +20,11 @@ package bean import ( "encoding/json" bean2 "github.com/devtron-labs/devtron/api/bean" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/chartRepo/repository" bean3 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" diff --git a/pkg/build/artifacts/CommonArtifactService.go b/pkg/build/artifacts/CommonArtifactService.go index 636ce434eb..7114ab55b6 100644 --- a/pkg/build/artifacts/CommonArtifactService.go +++ b/pkg/build/artifacts/CommonArtifactService.go @@ -1,7 +1,7 @@ package artifacts import ( - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/sql" "go.uber.org/zap" "time" diff --git a/pkg/bulkAction/BulkUpdateService.go b/pkg/bulkAction/BulkUpdateService.go index 60f766ff28..365abdfd12 100644 --- a/pkg/bulkAction/BulkUpdateService.go +++ b/pkg/bulkAction/BulkUpdateService.go @@ -12,13 +12,13 @@ import ( openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" client "github.com/devtron-labs/devtron/api/helm-app/service" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/bulkUpdate" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" appWorkflow2 "github.com/devtron-labs/devtron/pkg/appWorkflow" bean2 "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" diff --git a/pkg/chart/ChartService.go b/pkg/chart/ChartService.go index ee67b5b770..6caf661925 100644 --- a/pkg/chart/ChartService.go +++ b/pkg/chart/ChartService.go @@ -33,7 +33,7 @@ import ( //"github.com/devtron-labs/devtron/pkg/pipeline" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history" @@ -42,9 +42,9 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/util" repository4 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/chart/bean.go b/pkg/chart/bean.go index af905de3c8..fb9a2d9f48 100644 --- a/pkg/chart/bean.go +++ b/pkg/chart/bean.go @@ -2,7 +2,7 @@ package chart import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" ) var ReservedChartRefNamesList *[]ReservedChartList diff --git a/pkg/chart/mocks/ChartService.go b/pkg/chart/mocks/ChartService.go index b68ade434e..ef9d76145a 100644 --- a/pkg/chart/mocks/ChartService.go +++ b/pkg/chart/mocks/ChartService.go @@ -11,7 +11,7 @@ import ( mock "github.com/stretchr/testify/mock" - util "github.com/devtron-labs/devtron/internal/util" + util "github.com/devtron-labs/devtron/internals/util" ) // ChartService is an autogenerated mock type for the ChartService type diff --git a/pkg/chartRepo/ChartRepositoryService.go b/pkg/chartRepo/ChartRepositoryService.go index b722dee023..35630e0cbe 100644 --- a/pkg/chartRepo/ChartRepositoryService.go +++ b/pkg/chartRepo/ChartRepositoryService.go @@ -30,8 +30,8 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/cluster" serverEnvConfig "github.com/devtron-labs/devtron/pkg/server/config" diff --git a/pkg/chartRepo/ChartRepositoryService_test.go b/pkg/chartRepo/ChartRepositoryService_test.go index 65c8731ef7..2a36eb2d4e 100644 --- a/pkg/chartRepo/ChartRepositoryService_test.go +++ b/pkg/chartRepo/ChartRepositoryService_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "testing" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "sigs.k8s.io/yaml" diff --git a/pkg/chartRepo/bean.go b/pkg/chartRepo/bean.go index 2490fda57f..6663162c3a 100644 --- a/pkg/chartRepo/bean.go +++ b/pkg/chartRepo/bean.go @@ -1,6 +1,6 @@ package chartRepo -import "github.com/devtron-labs/devtron/internal/sql/repository" +import "github.com/devtron-labs/devtron/internals/sql/repository" const ValidationSuccessMsg = "Configurations are validated successfully" diff --git a/pkg/chartRepo/repository/ChartRepoRepository.go b/pkg/chartRepo/repository/ChartRepoRepository.go index 68d0e59a01..560d35f6e2 100644 --- a/pkg/chartRepo/repository/ChartRepoRepository.go +++ b/pkg/chartRepo/repository/ChartRepoRepository.go @@ -18,7 +18,7 @@ package chartRepoRepository import ( - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "strconv" diff --git a/pkg/chartRepo/repository/ChartRepoRepository_test.go b/pkg/chartRepo/repository/ChartRepoRepository_test.go index 1b13b3a9db..bf2f6c717f 100644 --- a/pkg/chartRepo/repository/ChartRepoRepository_test.go +++ b/pkg/chartRepo/repository/ChartRepoRepository_test.go @@ -18,7 +18,7 @@ package chartRepoRepository import ( - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/devtron-labs/devtron/pkg/sql" "github.com/stretchr/testify/assert" "testing" diff --git a/pkg/chartRepo/repository/ChartsRepository.go b/pkg/chartRepo/repository/ChartsRepository.go index 2d3524c122..a8061d906b 100644 --- a/pkg/chartRepo/repository/ChartsRepository.go +++ b/pkg/chartRepo/repository/ChartsRepository.go @@ -1,7 +1,7 @@ package chartRepoRepository import ( - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" ) diff --git a/pkg/cluster/ClusterService.go b/pkg/cluster/ClusterService.go index 45e561a59e..813dea4bb2 100644 --- a/pkg/cluster/ClusterService.go +++ b/pkg/cluster/ClusterService.go @@ -41,8 +41,8 @@ import ( "k8s.io/client-go/tools/clientcmd/api/latest" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster/repository" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" diff --git a/pkg/cluster/ClusterServiceExtended.go b/pkg/cluster/ClusterServiceExtended.go index 70f356e8fc..a7468396e0 100644 --- a/pkg/cluster/ClusterServiceExtended.go +++ b/pkg/cluster/ClusterServiceExtended.go @@ -16,8 +16,8 @@ import ( cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster" "github.com/devtron-labs/devtron/client/grafana" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/cluster/ClusterService_test.go b/pkg/cluster/ClusterService_test.go index 261412a37f..cc39f73376 100644 --- a/pkg/cluster/ClusterService_test.go +++ b/pkg/cluster/ClusterService_test.go @@ -2,7 +2,7 @@ package cluster import ( util2 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/k8s/informer" "go.uber.org/zap" diff --git a/pkg/cluster/EnvironmentService.go b/pkg/cluster/EnvironmentService.go index d6ac799b66..a9112abb91 100644 --- a/pkg/cluster/EnvironmentService.go +++ b/pkg/cluster/EnvironmentService.go @@ -27,13 +27,13 @@ import ( "time" util2 "github.com/devtron-labs/common-lib/utils/k8s" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/auth/user/bean" "github.com/devtron-labs/devtron/pkg/k8s/informer" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" "github.com/pkg/errors" diff --git a/pkg/cluster/EnvironmentService_test.go b/pkg/cluster/EnvironmentService_test.go index c8cdfb8123..fb56e046a5 100644 --- a/pkg/cluster/EnvironmentService_test.go +++ b/pkg/cluster/EnvironmentService_test.go @@ -1,8 +1,8 @@ package cluster import ( - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - mocks2 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + mocks2 "github.com/devtron-labs/devtron/internals/sql/repository/mocks" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository/mocks" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/cluster/EphemeralContainerService_test.go b/pkg/cluster/EphemeralContainerService_test.go index 46656d429b..2ebbb725f6 100644 --- a/pkg/cluster/EphemeralContainerService_test.go +++ b/pkg/cluster/EphemeralContainerService_test.go @@ -2,7 +2,7 @@ package cluster import ( "errors" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository/mocks" "github.com/go-pg/pg" diff --git a/pkg/cluster/mocks/ClusterService.go b/pkg/cluster/mocks/ClusterService.go index cb82736b9d..757e14def9 100644 --- a/pkg/cluster/mocks/ClusterService.go +++ b/pkg/cluster/mocks/ClusterService.go @@ -12,7 +12,7 @@ import ( repository "github.com/devtron-labs/devtron/pkg/cluster/repository" - util "github.com/devtron-labs/devtron/internal/util" + util "github.com/devtron-labs/devtron/internals/util" v1 "k8s.io/client-go/kubernetes/typed/core/v1" diff --git a/pkg/cluster/repository/EnvironmentRepository.go b/pkg/cluster/repository/EnvironmentRepository.go index 19b9c9c3d5..7cdb784669 100644 --- a/pkg/cluster/repository/EnvironmentRepository.go +++ b/pkg/cluster/repository/EnvironmentRepository.go @@ -19,8 +19,8 @@ package repository import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "github.com/go-pg/pg/orm" diff --git a/pkg/clusterTerminalAccess/UserTerminalAccessService.go b/pkg/clusterTerminalAccess/UserTerminalAccessService.go index 30f9968f2b..fed2cdfe15 100644 --- a/pkg/clusterTerminalAccess/UserTerminalAccessService.go +++ b/pkg/clusterTerminalAccess/UserTerminalAccessService.go @@ -8,8 +8,8 @@ import ( "github.com/caarlos0/env/v6" k8s2 "github.com/devtron-labs/common-lib/utils/k8s" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" utils1 "github.com/devtron-labs/devtron/pkg/clusterTerminalAccess/clusterTerminalUtils" "github.com/devtron-labs/devtron/pkg/k8s" "github.com/devtron-labs/devtron/pkg/k8s/capacity" diff --git a/pkg/clusterTerminalAccess/UserTerminalAccessServiceIT_test.go b/pkg/clusterTerminalAccess/UserTerminalAccessServiceIT_test.go index 10301e39be..64cbe9a81e 100644 --- a/pkg/clusterTerminalAccess/UserTerminalAccessServiceIT_test.go +++ b/pkg/clusterTerminalAccess/UserTerminalAccessServiceIT_test.go @@ -8,10 +8,10 @@ import ( "time" "github.com/devtron-labs/authenticator/client" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/util" repository4 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/clusterTerminalAccess/UserTerminalAccessService_test.go b/pkg/clusterTerminalAccess/UserTerminalAccessService_test.go index 14bf2ff8ce..e9c51fe1e2 100644 --- a/pkg/clusterTerminalAccess/UserTerminalAccessService_test.go +++ b/pkg/clusterTerminalAccess/UserTerminalAccessService_test.go @@ -4,9 +4,9 @@ import ( "context" "errors" util2 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + "github.com/devtron-labs/devtron/internals/util" mocks3 "github.com/devtron-labs/devtron/pkg/k8s/application/mocks" "github.com/devtron-labs/devtron/pkg/terminal" mocks2 "github.com/devtron-labs/devtron/pkg/terminal/mocks" diff --git a/pkg/clusterTerminalAccess/clusterTerminalUtils/utils.go b/pkg/clusterTerminalAccess/clusterTerminalUtils/utils.go index a4556065e1..f3ee5a12ed 100644 --- a/pkg/clusterTerminalAccess/clusterTerminalUtils/utils.go +++ b/pkg/clusterTerminalAccess/clusterTerminalUtils/utils.go @@ -3,7 +3,7 @@ package clusterTerminalUtils import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/yaml" ) diff --git a/pkg/commonService/CommonService.go b/pkg/commonService/CommonService.go index 4569dad013..eecf29bb70 100644 --- a/pkg/commonService/CommonService.go +++ b/pkg/commonService/CommonService.go @@ -18,11 +18,11 @@ package commonService import ( - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - helper2 "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + helper2 "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/attributes" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/delete/DeleteService.go b/pkg/delete/DeleteService.go index 4e8ab5e1f3..64f4f15b94 100644 --- a/pkg/delete/DeleteService.go +++ b/pkg/delete/DeleteService.go @@ -2,7 +2,7 @@ package delete import ( "fmt" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/chartRepo" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/pkg/delete/DeleteServiceExtended.go b/pkg/delete/DeleteServiceExtended.go index f9acac476c..602870ae88 100644 --- a/pkg/delete/DeleteServiceExtended.go +++ b/pkg/delete/DeleteServiceExtended.go @@ -2,10 +2,10 @@ package delete import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/chartRepo" diff --git a/pkg/delete/DeleteServiceFullMode.go b/pkg/delete/DeleteServiceFullMode.go index 28874d870c..4425c5ef30 100644 --- a/pkg/delete/DeleteServiceFullMode.go +++ b/pkg/delete/DeleteServiceFullMode.go @@ -2,8 +2,8 @@ package delete import ( "fmt" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/go-pg/pg" diff --git a/pkg/deployment/deployedApp/DeployedAppService.go b/pkg/deployment/deployedApp/DeployedAppService.go index 2020451be2..5447ab9676 100644 --- a/pkg/deployment/deployedApp/DeployedAppService.go +++ b/pkg/deployment/deployedApp/DeployedAppService.go @@ -6,8 +6,8 @@ import ( "fmt" util5 "github.com/devtron-labs/common-lib/utils/k8s" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/bean" "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps" diff --git a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go index fb10b283f6..529dd618f1 100644 --- a/pkg/deployment/gitOps/config/GitOpsConfigReadService.go +++ b/pkg/deployment/gitOps/config/GitOpsConfigReadService.go @@ -3,7 +3,7 @@ package config import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config/bean" "github.com/devtron-labs/devtron/util" diff --git a/pkg/deployment/gitOps/git/GitFactory.go b/pkg/deployment/gitOps/git/GitFactory.go index bc813890d2..03ea72f0d7 100644 --- a/pkg/deployment/gitOps/git/GitFactory.go +++ b/pkg/deployment/gitOps/git/GitFactory.go @@ -3,7 +3,7 @@ package git import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/adapter" "github.com/devtron-labs/devtron/util" "github.com/xanzy/go-gitlab" diff --git a/pkg/deployment/gitOps/git/GitOperationService.go b/pkg/deployment/gitOps/git/GitOperationService.go index 6d226be380..deebdf46b9 100644 --- a/pkg/deployment/gitOps/git/GitOperationService.go +++ b/pkg/deployment/gitOps/git/GitOperationService.go @@ -3,7 +3,7 @@ package git import ( "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" util2 "github.com/devtron-labs/devtron/pkg/appStore/util" commonBean "github.com/devtron-labs/devtron/pkg/deployment/gitOps/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" diff --git a/pkg/deployment/gitOps/git/GitOpsClient.go b/pkg/deployment/gitOps/git/GitOpsClient.go index e132ee7bfe..f2ec502037 100644 --- a/pkg/deployment/gitOps/git/GitOpsClient.go +++ b/pkg/deployment/gitOps/git/GitOpsClient.go @@ -2,7 +2,7 @@ package git import ( bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/deployment/gitOps/git/GitService_test.go b/pkg/deployment/gitOps/git/GitService_test.go index 0c66de4e4d..14919ca896 100644 --- a/pkg/deployment/gitOps/git/GitService_test.go +++ b/pkg/deployment/gitOps/git/GitService_test.go @@ -2,7 +2,7 @@ package git import ( "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" bean2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git/bean" "testing" ) diff --git a/pkg/deployment/gitOps/wire_gitOps.go b/pkg/deployment/gitOps/wire_gitOps.go index 9fe42f9de3..d834b10e86 100644 --- a/pkg/deployment/gitOps/wire_gitOps.go +++ b/pkg/deployment/gitOps/wire_gitOps.go @@ -1,7 +1,7 @@ package gitOps import ( - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/google/wire" diff --git a/pkg/deployment/manifest/ManifestCreationService.go b/pkg/deployment/manifest/ManifestCreationService.go index 1134d8dc7f..6f18ebec7f 100644 --- a/pkg/deployment/manifest/ManifestCreationService.go +++ b/pkg/deployment/manifest/ManifestCreationService.go @@ -9,12 +9,12 @@ import ( util5 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" bean2 "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" diff --git a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go index 1e1e81b55e..37fe46a6ed 100644 --- a/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go +++ b/pkg/deployment/manifest/deployedAppMetrics/DeployedAppMetrics.go @@ -2,7 +2,7 @@ package deployedAppMetrics import ( "context" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/bean" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" diff --git a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go index 34b71a70e5..dd2d2b33b9 100644 --- a/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go +++ b/pkg/deployment/manifest/deploymentTemplate/DeploymentTemplateService.go @@ -3,8 +3,8 @@ package deploymentTemplate import ( "context" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/util" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" bean4 "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" diff --git a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go index 9db0e2ade5..e03a3c280b 100644 --- a/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go +++ b/pkg/deployment/manifest/deploymentTemplate/chartRef/ChartRefService.go @@ -5,8 +5,8 @@ import ( "encoding/json" "errors" "fmt" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/adapter" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef/bean" diff --git a/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go index bcd5522a35..05d5e02835 100644 --- a/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go +++ b/pkg/deployment/providerConfig/DeploymentTypeOverrideService.go @@ -1,7 +1,7 @@ package providerConfig import ( - util2 "github.com/devtron-labs/devtron/internal/util" + util2 "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/util" "go.uber.org/zap" diff --git a/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go b/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go index 06e65a8fc8..76fa5f9694 100644 --- a/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go +++ b/pkg/deployment/trigger/devtronApps/PostStageTriggerService.go @@ -4,7 +4,7 @@ import ( "context" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/bean" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" diff --git a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go index 09087406d1..56d5b4a475 100644 --- a/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go +++ b/pkg/deployment/trigger/devtronApps/PreStageTriggerService.go @@ -7,10 +7,10 @@ import ( blob_storage "github.com/devtron-labs/common-lib/blob-storage" bean2 "github.com/devtron-labs/devtron/api/bean" gitSensorClient "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" bean4 "github.com/devtron-labs/devtron/pkg/bean" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/bean" diff --git a/pkg/deployment/trigger/devtronApps/TriggerService.go b/pkg/deployment/trigger/devtronApps/TriggerService.go index ae6515f28e..a9d29a8451 100644 --- a/pkg/deployment/trigger/devtronApps/TriggerService.go +++ b/pkg/deployment/trigger/devtronApps/TriggerService.go @@ -14,14 +14,14 @@ import ( bean7 "github.com/devtron-labs/devtron/client/argocdServer/bean" client "github.com/devtron-labs/devtron/client/events" gitSensorClient "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/models" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/models" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" bean4 "github.com/devtron-labs/devtron/pkg/app/bean" "github.com/devtron-labs/devtron/pkg/app/status" diff --git a/pkg/deployment/trigger/devtronApps/bean/bean.go b/pkg/deployment/trigger/devtronApps/bean/bean.go index 8fd4c283ae..60d56c9435 100644 --- a/pkg/deployment/trigger/devtronApps/bean/bean.go +++ b/pkg/deployment/trigger/devtronApps/bean/bean.go @@ -2,8 +2,8 @@ package bean import ( "context" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "time" ) diff --git a/pkg/deploymentGroup/DeploymentGroupService.go b/pkg/deploymentGroup/DeploymentGroupService.go index f5bf07574f..bce46d3e99 100644 --- a/pkg/deploymentGroup/DeploymentGroupService.go +++ b/pkg/deploymentGroup/DeploymentGroupService.go @@ -20,17 +20,17 @@ package deploymentGroup import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/eventProcessor/out" bean2 "github.com/devtron-labs/devtron/pkg/eventProcessor/out/bean" "strings" "time" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "go.uber.org/zap" diff --git a/pkg/dockerRegistry/DockerRegistryIpsConfigService.go b/pkg/dockerRegistry/DockerRegistryIpsConfigService.go index 0a5e626c48..2a301b54c8 100644 --- a/pkg/dockerRegistry/DockerRegistryIpsConfigService.go +++ b/pkg/dockerRegistry/DockerRegistryIpsConfigService.go @@ -20,9 +20,9 @@ package dockerRegistry import ( "encoding/json" "github.com/devtron-labs/common-lib/utils/k8s" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" diff --git a/pkg/eventProcessor/bean/workflowEventBean.go b/pkg/eventProcessor/bean/workflowEventBean.go index 610fb33ba9..7b9b15a6be 100644 --- a/pkg/eventProcessor/bean/workflowEventBean.go +++ b/pkg/eventProcessor/bean/workflowEventBean.go @@ -3,7 +3,7 @@ package bean import ( "github.com/aws/aws-sdk-go-v2/service/ecr/types" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/util" "time" diff --git a/pkg/eventProcessor/in/WorkflowEventProcessorService.go b/pkg/eventProcessor/in/WorkflowEventProcessorService.go index 97af5e9338..1a17aba589 100644 --- a/pkg/eventProcessor/in/WorkflowEventProcessorService.go +++ b/pkg/eventProcessor/in/WorkflowEventProcessorService.go @@ -9,8 +9,8 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" bean2 "github.com/devtron-labs/devtron/api/bean" client "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean4 "github.com/devtron-labs/devtron/pkg/auth/user/bean" "github.com/devtron-labs/devtron/pkg/deployment/deployedApp" bean6 "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/bean" diff --git a/pkg/eventProcessor/out/WorkflowEventPublishService.go b/pkg/eventProcessor/out/WorkflowEventPublishService.go index 95e27f8983..ff4ab54854 100644 --- a/pkg/eventProcessor/out/WorkflowEventPublishService.go +++ b/pkg/eventProcessor/out/WorkflowEventPublishService.go @@ -5,8 +5,8 @@ import ( "encoding/json" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" bean3 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/deployment/manifest" bean7 "github.com/devtron-labs/devtron/pkg/eventProcessor/bean" diff --git a/pkg/externalLink/ExternalLinkService.go b/pkg/externalLink/ExternalLinkService.go index fe22eac9f5..1f2383b32d 100644 --- a/pkg/externalLink/ExternalLinkService.go +++ b/pkg/externalLink/ExternalLinkService.go @@ -19,7 +19,7 @@ package externalLink import ( "fmt" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/externalLink/intergrationTests/ExternalLinks_test.go b/pkg/externalLink/intergrationTests/ExternalLinks_test.go index 896bd2fb9c..6f88b202da 100644 --- a/pkg/externalLink/intergrationTests/ExternalLinks_test.go +++ b/pkg/externalLink/intergrationTests/ExternalLinks_test.go @@ -2,7 +2,7 @@ package intergrationTests import ( "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" diff --git a/pkg/externalLink/mocks/ExternalLinkService_test.go b/pkg/externalLink/mocks/ExternalLinkService_test.go index 446527e1c4..644bbf19fa 100644 --- a/pkg/externalLink/mocks/ExternalLinkService_test.go +++ b/pkg/externalLink/mocks/ExternalLinkService_test.go @@ -2,7 +2,7 @@ package mocks import ( "fmt" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/externalLink" "github.com/stretchr/testify/assert" "testing" diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index 4e4db12471..c807ac2d37 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -8,9 +8,9 @@ import ( "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" - "github.com/devtron-labs/devtron/internal/sql/repository" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/chart" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" diff --git a/pkg/generateManifest/DeployementTemplateService_test.go b/pkg/generateManifest/DeployementTemplateService_test.go index b3254cbcc4..305b7e1b65 100644 --- a/pkg/generateManifest/DeployementTemplateService_test.go +++ b/pkg/generateManifest/DeployementTemplateService_test.go @@ -8,10 +8,10 @@ import ( "github.com/devtron-labs/devtron/api/bean" client "github.com/devtron-labs/devtron/api/helm-app/gRPC" mocks4 "github.com/devtron-labs/devtron/api/helm-app/mocks" - "github.com/devtron-labs/devtron/internal/sql/repository" - mocks3 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - "github.com/devtron-labs/devtron/internal/util" - mocks6 "github.com/devtron-labs/devtron/internal/util/mocks" + "github.com/devtron-labs/devtron/internals/sql/repository" + mocks3 "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + "github.com/devtron-labs/devtron/internals/util" + mocks6 "github.com/devtron-labs/devtron/internals/util/mocks" mocks2 "github.com/devtron-labs/devtron/pkg/app/mocks" "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/chart/mocks" diff --git a/pkg/genericNotes/GenericNoteHistoryService_test.go b/pkg/genericNotes/GenericNoteHistoryService_test.go index 96ea37ae63..8fcb3613b6 100644 --- a/pkg/genericNotes/GenericNoteHistoryService_test.go +++ b/pkg/genericNotes/GenericNoteHistoryService_test.go @@ -2,7 +2,7 @@ package genericNotes import ( "errors" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/genericNotes/repository/mocks" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" diff --git a/pkg/genericNotes/GenericNoteServiceIT_test.go b/pkg/genericNotes/GenericNoteServiceIT_test.go index b90649a453..104b13906a 100644 --- a/pkg/genericNotes/GenericNoteServiceIT_test.go +++ b/pkg/genericNotes/GenericNoteServiceIT_test.go @@ -11,7 +11,7 @@ import ( "github.com/devtron-labs/devtron/pkg/sql" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" diff --git a/pkg/genericNotes/repository/GenericNoteRepository.go b/pkg/genericNotes/repository/GenericNoteRepository.go index 6049f30e43..07778ef668 100644 --- a/pkg/genericNotes/repository/GenericNoteRepository.go +++ b/pkg/genericNotes/repository/GenericNoteRepository.go @@ -19,8 +19,8 @@ package repository import ( "fmt" - repository1 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository1 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" ) diff --git a/pkg/genericNotes/tests/GenericNoteService_test.go b/pkg/genericNotes/tests/GenericNoteService_test.go index d6a134895d..23ad293c3b 100644 --- a/pkg/genericNotes/tests/GenericNoteService_test.go +++ b/pkg/genericNotes/tests/GenericNoteService_test.go @@ -5,7 +5,7 @@ import ( "testing" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user/repository" mocks2 "github.com/devtron-labs/devtron/pkg/auth/user/repository/mocks" "github.com/devtron-labs/devtron/pkg/genericNotes" diff --git a/pkg/git/GitWebhookService.go b/pkg/git/GitWebhookService.go index 6d93460773..f4237b7b83 100644 --- a/pkg/git/GitWebhookService.go +++ b/pkg/git/GitWebhookService.go @@ -19,8 +19,8 @@ package git import ( "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline" "go.uber.org/zap" diff --git a/pkg/gitops/GitOpsConfigService.go b/pkg/gitops/GitOpsConfigService.go index 071b7638c1..f4d70139ea 100644 --- a/pkg/gitops/GitOpsConfigService.go +++ b/pkg/gitops/GitOpsConfigService.go @@ -37,8 +37,8 @@ import ( cluster3 "github.com/argoproj/argo-cd/v2/pkg/apiclient/cluster" bean2 "github.com/devtron-labs/devtron/api/bean" cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/sql" util3 "github.com/devtron-labs/devtron/pkg/util" diff --git a/pkg/k8s/K8sCommonService.go b/pkg/k8s/K8sCommonService.go index e75b5a26f3..7c6cae12b7 100644 --- a/pkg/k8s/K8sCommonService.go +++ b/pkg/k8s/K8sCommonService.go @@ -8,7 +8,7 @@ import ( k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/helm-app/service" - util2 "github.com/devtron-labs/devtron/internal/util" + util2 "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/argoApplication" "github.com/devtron-labs/devtron/pkg/cluster" bean3 "github.com/devtron-labs/devtron/pkg/k8s/application/bean" diff --git a/pkg/k8s/application/K8sApplicationServiceIT_test.go b/pkg/k8s/application/K8sApplicationServiceIT_test.go index df283811c9..f19cf39043 100644 --- a/pkg/k8s/application/K8sApplicationServiceIT_test.go +++ b/pkg/k8s/application/K8sApplicationServiceIT_test.go @@ -6,7 +6,7 @@ import ( "github.com/caarlos0/env/v6" "github.com/devtron-labs/authenticator/client" "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/cluster/repository" s "github.com/devtron-labs/devtron/pkg/k8s" diff --git a/pkg/k8s/application/k8sApplicationService.go b/pkg/k8s/application/k8sApplicationService.go index 8b9d092223..6544ff5bf5 100644 --- a/pkg/k8s/application/k8sApplicationService.go +++ b/pkg/k8s/application/k8sApplicationService.go @@ -19,7 +19,7 @@ import ( k8s2 "github.com/devtron-labs/common-lib/utils/k8s" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" yamlUtil "github.com/devtron-labs/common-lib/utils/yaml" "github.com/devtron-labs/devtron/api/connector" diff --git a/pkg/k8s/capacity/k8sCapacityService.go b/pkg/k8s/capacity/k8sCapacityService.go index 0159947112..390ea5efb5 100644 --- a/pkg/k8s/capacity/k8sCapacityService.go +++ b/pkg/k8s/capacity/k8sCapacityService.go @@ -6,7 +6,7 @@ import ( "github.com/devtron-labs/common-lib/utils" k8s2 "github.com/devtron-labs/common-lib/utils/k8s" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/devtron-labs/devtron/pkg/k8s" application2 "github.com/devtron-labs/devtron/pkg/k8s/application" diff --git a/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go b/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go index 859a5f258b..6990e3fc2b 100644 --- a/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go +++ b/pkg/kubernetesResourceAuditLogs/kubernetesResourceHistoryService.go @@ -4,7 +4,7 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/common-lib/utils/k8s" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/module/ModuleService.go b/pkg/module/ModuleService.go index 297888cfea..4c2b381b0b 100644 --- a/pkg/module/ModuleService.go +++ b/pkg/module/ModuleService.go @@ -23,7 +23,7 @@ import ( "github.com/caarlos0/env/v6" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" - "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internals/sql/repository/security" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleUtil "github.com/devtron-labs/devtron/pkg/module/util" "github.com/devtron-labs/devtron/pkg/server" diff --git a/pkg/notifier/NotificationConfigBuilder.go b/pkg/notifier/NotificationConfigBuilder.go index 27536acb0f..55c89c5a15 100644 --- a/pkg/notifier/NotificationConfigBuilder.go +++ b/pkg/notifier/NotificationConfigBuilder.go @@ -19,7 +19,7 @@ package notifier import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/util/event" "go.uber.org/zap" "time" @@ -169,7 +169,7 @@ func (impl NotificationConfigBuilderImpl) buildNotificationSetting(notificationS } func (impl NotificationConfigBuilderImpl) BuildNotificationSettingWithPipeline(teamId *int, envId *int, appId *int, pipelineId *int, pipelineType util.PipelineType, eventTypeId int, viewId int, providers []*Provider) (repository.NotificationSettings, error) { - + providersJson, err := json.Marshal(providers) if err != nil { impl.logger.Error(err) diff --git a/pkg/notifier/NotificationConfigService.go b/pkg/notifier/NotificationConfigService.go index 123caa3c09..a5a0432357 100644 --- a/pkg/notifier/NotificationConfigService.go +++ b/pkg/notifier/NotificationConfigService.go @@ -21,14 +21,14 @@ import ( "encoding/json" "time" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" repository4 "github.com/devtron-labs/devtron/pkg/auth/user/repository" repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository" repository2 "github.com/devtron-labs/devtron/pkg/team" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + util2 "github.com/devtron-labs/devtron/internals/util" util "github.com/devtron-labs/devtron/util/event" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/notifier/SESNotificationService.go b/pkg/notifier/SESNotificationService.go index 735ec6fc02..21af68950e 100644 --- a/pkg/notifier/SESNotificationService.go +++ b/pkg/notifier/SESNotificationService.go @@ -19,8 +19,8 @@ package notifier import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" util2 "github.com/devtron-labs/devtron/util/event" diff --git a/pkg/notifier/SMTPNotificationService.go b/pkg/notifier/SMTPNotificationService.go index 9642675965..e68d11b231 100644 --- a/pkg/notifier/SMTPNotificationService.go +++ b/pkg/notifier/SMTPNotificationService.go @@ -2,8 +2,8 @@ package notifier import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" util2 "github.com/devtron-labs/devtron/util/event" diff --git a/pkg/notifier/SlackNotificationService.go b/pkg/notifier/SlackNotificationService.go index 8439def0cf..9649f2f2f1 100644 --- a/pkg/notifier/SlackNotificationService.go +++ b/pkg/notifier/SlackNotificationService.go @@ -23,8 +23,8 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" diff --git a/pkg/notifier/WebhookNotificationService.go b/pkg/notifier/WebhookNotificationService.go index 71c598fb69..cd2aa581e2 100644 --- a/pkg/notifier/WebhookNotificationService.go +++ b/pkg/notifier/WebhookNotificationService.go @@ -4,8 +4,8 @@ import ( "fmt" "time" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/team" diff --git a/pkg/notifier/WebhookNotificationService_test.go b/pkg/notifier/WebhookNotificationService_test.go index df5be8c272..169de584ea 100644 --- a/pkg/notifier/WebhookNotificationService_test.go +++ b/pkg/notifier/WebhookNotificationService_test.go @@ -4,9 +4,9 @@ import ( "fmt" "testing" - "github.com/devtron-labs/devtron/internal/sql/repository" - mocks2 "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - util2 "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + mocks2 "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + util2 "github.com/devtron-labs/devtron/internals/util" mocks3 "github.com/devtron-labs/devtron/pkg/auth/user/repository/mocks" "github.com/devtron-labs/devtron/pkg/team/mocks" "github.com/stretchr/testify/mock" diff --git a/pkg/pipeline/AppArtifactManager.go b/pkg/pipeline/AppArtifactManager.go index 994143bfe4..2ea9492773 100644 --- a/pkg/pipeline/AppArtifactManager.go +++ b/pkg/pipeline/AppArtifactManager.go @@ -23,9 +23,9 @@ import ( "strings" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - dockerArtifactStoreRegistry "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + dockerArtifactStoreRegistry "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" bean2 "github.com/devtron-labs/devtron/pkg/bean" repository2 "github.com/devtron-labs/devtron/pkg/pipeline/repository" diff --git a/pkg/pipeline/AppDeploymentTypeChangeManager.go b/pkg/pipeline/AppDeploymentTypeChangeManager.go index eebe03270e..7d24f696b9 100644 --- a/pkg/pipeline/AppDeploymentTypeChangeManager.go +++ b/pkg/pipeline/AppDeploymentTypeChangeManager.go @@ -23,10 +23,10 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/devtron-labs/devtron/api/helm-app/service" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/bean" chartService "github.com/devtron-labs/devtron/pkg/chart" diff --git a/pkg/pipeline/ArgoWorkflowExecutor_test.go b/pkg/pipeline/ArgoWorkflowExecutor_test.go index fccbfb65ad..bd54491291 100644 --- a/pkg/pipeline/ArgoWorkflowExecutor_test.go +++ b/pkg/pipeline/ArgoWorkflowExecutor_test.go @@ -7,7 +7,7 @@ import ( "github.com/argoproj/argo-workflows/v3/workflow/common" blob_storage "github.com/devtron-labs/common-lib/blob-storage" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/types" diff --git a/pkg/pipeline/BuildPipelineConfigService.go b/pkg/pipeline/BuildPipelineConfigService.go index def3c1f8aa..ef0ef29866 100644 --- a/pkg/pipeline/BuildPipelineConfigService.go +++ b/pkg/pipeline/BuildPipelineConfigService.go @@ -22,12 +22,12 @@ import ( "fmt" "github.com/caarlos0/env" "github.com/devtron-labs/common-lib/utils" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bean" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" diff --git a/pkg/pipeline/BuildPipelineSwitchService.go b/pkg/pipeline/BuildPipelineSwitchService.go index 1eb0f3d3fd..0d78e035a2 100644 --- a/pkg/pipeline/BuildPipelineSwitchService.go +++ b/pkg/pipeline/BuildPipelineSwitchService.go @@ -1,8 +1,8 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" bean3 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" diff --git a/pkg/pipeline/CdHandler.go b/pkg/pipeline/CdHandler.go index 856100c032..dc42d46ddb 100644 --- a/pkg/pipeline/CdHandler.go +++ b/pkg/pipeline/CdHandler.go @@ -31,9 +31,9 @@ import ( blob_storage "github.com/devtron-labs/common-lib/blob-storage" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" diff --git a/pkg/pipeline/CiBuildConfigService.go b/pkg/pipeline/CiBuildConfigService.go index 4d7862d69e..ec55574afb 100644 --- a/pkg/pipeline/CiBuildConfigService.go +++ b/pkg/pipeline/CiBuildConfigService.go @@ -2,7 +2,7 @@ package pipeline import ( "errors" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "go.uber.org/zap" "time" diff --git a/pkg/pipeline/CiBuildConfigService_test.go b/pkg/pipeline/CiBuildConfigService_test.go index e27a6ba09d..7359a56d59 100644 --- a/pkg/pipeline/CiBuildConfigService_test.go +++ b/pkg/pipeline/CiBuildConfigService_test.go @@ -2,8 +2,8 @@ package pipeline import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/stretchr/testify/assert" "testing" diff --git a/pkg/pipeline/CiCdPipelineOrchestrator.go b/pkg/pipeline/CiCdPipelineOrchestrator.go index 710dbe0562..177e58a027 100644 --- a/pkg/pipeline/CiCdPipelineOrchestrator.go +++ b/pkg/pipeline/CiCdPipelineOrchestrator.go @@ -35,9 +35,9 @@ import ( util3 "github.com/devtron-labs/common-lib/utils/k8s" bean4 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/gitSensor" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" bean3 "github.com/devtron-labs/devtron/pkg/auth/user/bean" @@ -52,11 +52,11 @@ import ( "github.com/devtron-labs/devtron/pkg/sql" util2 "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/bean" diff --git a/pkg/pipeline/CiCdPipelineOrchestrator_test.go b/pkg/pipeline/CiCdPipelineOrchestrator_test.go index d88c893003..d9e8d6d3f5 100644 --- a/pkg/pipeline/CiCdPipelineOrchestrator_test.go +++ b/pkg/pipeline/CiCdPipelineOrchestrator_test.go @@ -6,14 +6,14 @@ import ( "testing" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/auth/user" diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 0222e888e1..ac3787229b 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -35,7 +35,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/cluster" repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -50,9 +50,9 @@ import ( "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" client "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" util2 "github.com/devtron-labs/devtron/util/event" "github.com/go-pg/pg" diff --git a/pkg/pipeline/CiHandlerIT_test.go b/pkg/pipeline/CiHandlerIT_test.go index 0382bfbe63..9d28110208 100644 --- a/pkg/pipeline/CiHandlerIT_test.go +++ b/pkg/pipeline/CiHandlerIT_test.go @@ -1,8 +1,8 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/sql" "github.com/stretchr/testify/assert" "testing" diff --git a/pkg/pipeline/CiMaterialConfigService.go b/pkg/pipeline/CiMaterialConfigService.go index 1b1e7331c2..b5109a434a 100644 --- a/pkg/pipeline/CiMaterialConfigService.go +++ b/pkg/pipeline/CiMaterialConfigService.go @@ -19,7 +19,7 @@ package pipeline import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history" "github.com/go-pg/pg" diff --git a/pkg/pipeline/CiService.go b/pkg/pipeline/CiService.go index 45144bd1c5..b81b5d7498 100644 --- a/pkg/pipeline/CiService.go +++ b/pkg/pipeline/CiService.go @@ -28,10 +28,10 @@ import ( "strings" "time" - repository5 "github.com/devtron-labs/devtron/internal/sql/repository" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository5 "github.com/devtron-labs/devtron/internals/sql/repository" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/auth/user" repository1 "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -50,9 +50,9 @@ import ( "github.com/devtron-labs/common-lib/blob-storage" client "github.com/devtron-labs/devtron/client/events" - "github.com/devtron-labs/devtron/internal/middleware" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/middleware" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" util2 "github.com/devtron-labs/devtron/util/event" "go.uber.org/zap" diff --git a/pkg/pipeline/CiTemplateService.go b/pkg/pipeline/CiTemplateService.go index 29f9e5d4b7..986c777fc3 100644 --- a/pkg/pipeline/CiTemplateService.go +++ b/pkg/pipeline/CiTemplateService.go @@ -1,7 +1,7 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/pipeline/CiTemplateService_test.go b/pkg/pipeline/CiTemplateService_test.go index 5632c07715..6a2908a7d5 100644 --- a/pkg/pipeline/CiTemplateService_test.go +++ b/pkg/pipeline/CiTemplateService_test.go @@ -3,9 +3,9 @@ package pipeline import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/bean" pipelineMocks "github.com/devtron-labs/devtron/pkg/pipeline/mocks" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/ConfigMapService.go b/pkg/pipeline/ConfigMapService.go index d291531a0a..c19dcfafcd 100644 --- a/pkg/pipeline/ConfigMapService.go +++ b/pkg/pipeline/ConfigMapService.go @@ -21,9 +21,9 @@ import ( "encoding/json" "errors" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/util" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/commonService" diff --git a/pkg/pipeline/ConfigMapService_test.go b/pkg/pipeline/ConfigMapService_test.go index e46a225201..42da120ad7 100644 --- a/pkg/pipeline/ConfigMapService_test.go +++ b/pkg/pipeline/ConfigMapService_test.go @@ -2,10 +2,10 @@ package pipeline import ( "fmt" - mocks4 "github.com/devtron-labs/devtron/internal/sql/repository/app/mocks" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - mocks2 "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig/mocks" - "github.com/devtron-labs/devtron/internal/util" + mocks4 "github.com/devtron-labs/devtron/internals/sql/repository/app/mocks" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + mocks2 "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig/mocks" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/chartRepo/repository/mocks" "github.com/devtron-labs/devtron/pkg/cluster/repository" mocks6 "github.com/devtron-labs/devtron/pkg/cluster/repository/mocks" diff --git a/pkg/pipeline/CustomTagService.go b/pkg/pipeline/CustomTagService.go index 43ad00f3dd..263109f91e 100644 --- a/pkg/pipeline/CustomTagService.go +++ b/pkg/pipeline/CustomTagService.go @@ -3,7 +3,7 @@ package pipeline import ( "fmt" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/pipeline/DeploymentConfigService.go b/pkg/pipeline/DeploymentConfigService.go index f12c90c9e0..f404a0f6e1 100644 --- a/pkg/pipeline/DeploymentConfigService.go +++ b/pkg/pipeline/DeploymentConfigService.go @@ -3,8 +3,8 @@ package pipeline import ( "context" "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" diff --git a/pkg/pipeline/DeploymentPipelineConfigService.go b/pkg/pipeline/DeploymentPipelineConfigService.go index 54bed48156..ef73269e67 100644 --- a/pkg/pipeline/DeploymentPipelineConfigService.go +++ b/pkg/pipeline/DeploymentPipelineConfigService.go @@ -28,14 +28,14 @@ import ( client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" diff --git a/pkg/pipeline/DevtronAppCMCSService.go b/pkg/pipeline/DevtronAppCMCSService.go index 2a210817e2..3d7335dcc1 100644 --- a/pkg/pipeline/DevtronAppCMCSService.go +++ b/pkg/pipeline/DevtronAppCMCSService.go @@ -19,7 +19,7 @@ package pipeline import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/app" "go.uber.org/zap" ) diff --git a/pkg/pipeline/DevtronAppConfigService.go b/pkg/pipeline/DevtronAppConfigService.go index 1f5debb406..98d156aab6 100644 --- a/pkg/pipeline/DevtronAppConfigService.go +++ b/pkg/pipeline/DevtronAppConfigService.go @@ -18,9 +18,9 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/resourceGroup" "github.com/devtron-labs/devtron/util/rbac" diff --git a/pkg/pipeline/DockerRegistryConfig.go b/pkg/pipeline/DockerRegistryConfig.go index e327c62d3c..91af445b5e 100644 --- a/pkg/pipeline/DockerRegistryConfig.go +++ b/pkg/pipeline/DockerRegistryConfig.go @@ -30,9 +30,9 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/util" "go.uber.org/zap" ) diff --git a/pkg/pipeline/DockerRegistryConfig_test.go b/pkg/pipeline/DockerRegistryConfig_test.go index 2a5e20e107..9e18e9f95d 100644 --- a/pkg/pipeline/DockerRegistryConfig_test.go +++ b/pkg/pipeline/DockerRegistryConfig_test.go @@ -5,14 +5,14 @@ import ( "fmt" client "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/mocks" - repository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + repository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/dockerRegistry" "github.com/devtron-labs/devtron/pkg/pipeline/types" "log" "testing" "github.com/caarlos0/env" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "github.com/stretchr/testify/assert" ) diff --git a/pkg/pipeline/GitHostConfig.go b/pkg/pipeline/GitHostConfig.go index b535598862..eb94e936ac 100644 --- a/pkg/pipeline/GitHostConfig.go +++ b/pkg/pipeline/GitHostConfig.go @@ -18,9 +18,9 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/attributes" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/GitRegistryConfig.go b/pkg/pipeline/GitRegistryConfig.go index 5fa9c132e7..41b7a7579a 100644 --- a/pkg/pipeline/GitRegistryConfig.go +++ b/pkg/pipeline/GitRegistryConfig.go @@ -20,9 +20,9 @@ package pipeline import ( "context" "github.com/devtron-labs/devtron/client/gitSensor" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" "github.com/juju/errors" diff --git a/pkg/pipeline/GitopsOrHelmOption_test.go b/pkg/pipeline/GitopsOrHelmOption_test.go index fac5c7c9c5..4184924dce 100644 --- a/pkg/pipeline/GitopsOrHelmOption_test.go +++ b/pkg/pipeline/GitopsOrHelmOption_test.go @@ -1,8 +1,8 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig/mocks" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" util2 "github.com/devtron-labs/devtron/util" "github.com/stretchr/testify/assert" diff --git a/pkg/pipeline/GlobalCMCSService.go b/pkg/pipeline/GlobalCMCSService.go index 71e7032c82..909c0f963c 100644 --- a/pkg/pipeline/GlobalCMCSService.go +++ b/pkg/pipeline/GlobalCMCSService.go @@ -3,7 +3,7 @@ package pipeline import ( "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/pipeline/GlobalCmcsService_test.go b/pkg/pipeline/GlobalCmcsService_test.go index b2e493f8cf..311f78e1c7 100644 --- a/pkg/pipeline/GlobalCmcsService_test.go +++ b/pkg/pipeline/GlobalCmcsService_test.go @@ -2,7 +2,7 @@ package pipeline import ( "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/stretchr/testify/assert" diff --git a/pkg/pipeline/ImageTaggingService.go b/pkg/pipeline/ImageTaggingService.go index 1462474fca..bc02a25a3f 100644 --- a/pkg/pipeline/ImageTaggingService.go +++ b/pkg/pipeline/ImageTaggingService.go @@ -21,8 +21,8 @@ import ( "encoding/json" "errors" "github.com/caarlos0/env" - repository "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" repository2 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/go-pg/pg" diff --git a/pkg/pipeline/ImageTaggingService_test.go b/pkg/pipeline/ImageTaggingService_test.go index 19f969fcdd..fa168e7d06 100644 --- a/pkg/pipeline/ImageTaggingService_test.go +++ b/pkg/pipeline/ImageTaggingService_test.go @@ -3,11 +3,11 @@ package pipeline import ( "errors" "fmt" - repository "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging/mocks" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - mocks2 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/mocks" - "github.com/devtron-labs/devtron/internal/util" + repository "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging/mocks" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + mocks2 "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig/mocks" + "github.com/devtron-labs/devtron/internals/util" repository1 "github.com/devtron-labs/devtron/pkg/cluster/repository" mocks3 "github.com/devtron-labs/devtron/pkg/cluster/repository/mocks" "github.com/devtron-labs/devtron/pkg/pipeline/types" diff --git a/pkg/pipeline/PipelineBuilder.go b/pkg/pipeline/PipelineBuilder.go index d47d08411f..7f8609ff6e 100644 --- a/pkg/pipeline/PipelineBuilder.go +++ b/pkg/pipeline/PipelineBuilder.go @@ -26,9 +26,9 @@ import ( "github.com/caarlos0/env" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "go.uber.org/zap" diff --git a/pkg/pipeline/PipelineBuilder_test.go b/pkg/pipeline/PipelineBuilder_test.go index b35f2c2ce3..8aaded9ec7 100644 --- a/pkg/pipeline/PipelineBuilder_test.go +++ b/pkg/pipeline/PipelineBuilder_test.go @@ -1,9 +1,9 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/mocks" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/sql" "github.com/stretchr/testify/assert" diff --git a/pkg/pipeline/PipelineStageService.go b/pkg/pipeline/PipelineStageService.go index e492b90691..d0445848c1 100644 --- a/pkg/pipeline/PipelineStageService.go +++ b/pkg/pipeline/PipelineStageService.go @@ -3,7 +3,7 @@ package pipeline import ( "encoding/json" "errors" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/repository" repository2 "github.com/devtron-labs/devtron/pkg/plugin/repository" diff --git a/pkg/pipeline/PipelineStageServiceIT_test.go b/pkg/pipeline/PipelineStageServiceIT_test.go index f6e8d803c5..2e3fb626fa 100644 --- a/pkg/pipeline/PipelineStageServiceIT_test.go +++ b/pkg/pipeline/PipelineStageServiceIT_test.go @@ -4,8 +4,8 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/common-lib/utils" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean2 "github.com/devtron-labs/devtron/pkg/bean" repository3 "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/pipeline/bean" diff --git a/pkg/pipeline/PropertiesConfig.go b/pkg/pipeline/PropertiesConfig.go index 40adfb2f7b..56c86c6793 100644 --- a/pkg/pipeline/PropertiesConfig.go +++ b/pkg/pipeline/PropertiesConfig.go @@ -33,8 +33,8 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline/history" "github.com/devtron-labs/devtron/pkg/sql" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" "github.com/go-pg/pg" "github.com/juju/errors" "go.uber.org/zap" diff --git a/pkg/pipeline/StageServiceUtil.go b/pkg/pipeline/StageServiceUtil.go index 39be12c9a0..7facec77ba 100644 --- a/pkg/pipeline/StageServiceUtil.go +++ b/pkg/pipeline/StageServiceUtil.go @@ -2,7 +2,7 @@ package pipeline import ( "errors" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean2 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/bean" repository2 "github.com/devtron-labs/devtron/pkg/pipeline/repository" diff --git a/pkg/pipeline/SystemWorkflowExecutor_test.go b/pkg/pipeline/SystemWorkflowExecutor_test.go index 1d5a22c7a0..90e36e6e37 100644 --- a/pkg/pipeline/SystemWorkflowExecutor_test.go +++ b/pkg/pipeline/SystemWorkflowExecutor_test.go @@ -6,7 +6,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/types" diff --git a/pkg/pipeline/WebhookEventDataConfig.go b/pkg/pipeline/WebhookEventDataConfig.go index 3b0679e404..2d3a89ea23 100644 --- a/pkg/pipeline/WebhookEventDataConfig.go +++ b/pkg/pipeline/WebhookEventDataConfig.go @@ -18,7 +18,7 @@ package pipeline import ( - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "go.uber.org/zap" "time" ) diff --git a/pkg/pipeline/WebhookService.go b/pkg/pipeline/WebhookService.go index 28ee023f48..e59e25afa1 100644 --- a/pkg/pipeline/WebhookService.go +++ b/pkg/pipeline/WebhookService.go @@ -24,8 +24,8 @@ import ( "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" "github.com/aws/aws-sdk-go-v2/service/ecr/types" pubsub "github.com/devtron-labs/common-lib/pubsub-lib" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" types2 "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/workflow/cd" diff --git a/pkg/pipeline/WorkflowService.go b/pkg/pipeline/WorkflowService.go index a2cd7228d5..20ab1edb56 100644 --- a/pkg/pipeline/WorkflowService.go +++ b/pkg/pipeline/WorkflowService.go @@ -25,7 +25,7 @@ import ( "github.com/argoproj/argo-workflows/v3/workflow/util" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/infraConfig" diff --git a/pkg/pipeline/WorkflowServiceIT_test.go b/pkg/pipeline/WorkflowServiceIT_test.go index c3d189350f..9ede38021c 100644 --- a/pkg/pipeline/WorkflowServiceIT_test.go +++ b/pkg/pipeline/WorkflowServiceIT_test.go @@ -5,11 +5,11 @@ import ( "github.com/devtron-labs/authenticator/client" blob_storage "github.com/devtron-labs/common-lib/blob-storage" "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/cluster" diff --git a/pkg/pipeline/WorkflowService_test.go b/pkg/pipeline/WorkflowService_test.go index 218226f764..7029eee76f 100644 --- a/pkg/pipeline/WorkflowService_test.go +++ b/pkg/pipeline/WorkflowService_test.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" bean3 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/stretchr/testify/assert" v12 "k8s.io/api/core/v1" diff --git a/pkg/pipeline/bean/CiBuildConfig.go b/pkg/pipeline/bean/CiBuildConfig.go index f15a0ae26d..ae7bd31055 100644 --- a/pkg/pipeline/bean/CiBuildConfig.go +++ b/pkg/pipeline/bean/CiBuildConfig.go @@ -2,7 +2,7 @@ package bean import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/sql" "time" ) diff --git a/pkg/pipeline/bean/CiTemplateBean.go b/pkg/pipeline/bean/CiTemplateBean.go index d49e4b2634..4104c19fc8 100644 --- a/pkg/pipeline/bean/CiTemplateBean.go +++ b/pkg/pipeline/bean/CiTemplateBean.go @@ -1,6 +1,6 @@ package bean -import "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" +import "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" type CiTemplateBean struct { CiTemplate *pipelineConfig.CiTemplate diff --git a/pkg/pipeline/bean/EnvironmentProperties.go b/pkg/pipeline/bean/EnvironmentProperties.go index d7e3c7ab58..f3d58c7974 100644 --- a/pkg/pipeline/bean/EnvironmentProperties.go +++ b/pkg/pipeline/bean/EnvironmentProperties.go @@ -2,7 +2,7 @@ package bean import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/models" + "github.com/devtron-labs/devtron/internals/sql/models" ) type EnvironmentProperties struct { diff --git a/pkg/pipeline/bean/GlobalCMCSDto.go b/pkg/pipeline/bean/GlobalCMCSDto.go index cce097f9ee..bfcca1428b 100644 --- a/pkg/pipeline/bean/GlobalCMCSDto.go +++ b/pkg/pipeline/bean/GlobalCMCSDto.go @@ -3,7 +3,7 @@ package bean import ( "encoding/json" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" ) type GlobalCMCSDto struct { diff --git a/pkg/pipeline/bean/pipelineStage.go b/pkg/pipeline/bean/pipelineStage.go index f2a1ae2d66..eb468d729d 100644 --- a/pkg/pipeline/bean/pipelineStage.go +++ b/pkg/pipeline/bean/pipelineStage.go @@ -1,7 +1,7 @@ package bean import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/repository" repository2 "github.com/devtron-labs/devtron/pkg/plugin/repository" ) diff --git a/pkg/pipeline/bean/workFlowRequestBean.go b/pkg/pipeline/bean/workFlowRequestBean.go index 644239de64..326e5371f7 100644 --- a/pkg/pipeline/bean/workFlowRequestBean.go +++ b/pkg/pipeline/bean/workFlowRequestBean.go @@ -1,8 +1,8 @@ package bean import ( - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" ) type VariableType string diff --git a/pkg/pipeline/executors/WorkflowUtils.go b/pkg/pipeline/executors/WorkflowUtils.go index e44afa4bca..cb493d6e4d 100644 --- a/pkg/pipeline/executors/WorkflowUtils.go +++ b/pkg/pipeline/executors/WorkflowUtils.go @@ -6,7 +6,7 @@ import ( "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" v1alpha12 "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/typed/workflow/v1alpha1" bean2 "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/util" diff --git a/pkg/pipeline/history/CiPipelineHistoryService.go b/pkg/pipeline/history/CiPipelineHistoryService.go index db069b665c..bec9dfadf2 100644 --- a/pkg/pipeline/history/CiPipelineHistoryService.go +++ b/pkg/pipeline/history/CiPipelineHistoryService.go @@ -2,7 +2,7 @@ package history import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/history/CiPipelineHistoryService_test.go b/pkg/pipeline/history/CiPipelineHistoryService_test.go index 7f533750b1..918add67b7 100644 --- a/pkg/pipeline/history/CiPipelineHistoryService_test.go +++ b/pkg/pipeline/history/CiPipelineHistoryService_test.go @@ -2,9 +2,9 @@ package history import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - mocks2 "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/mocks" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + mocks2 "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig/mocks" + "github.com/devtron-labs/devtron/internals/util" bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository/mocks" diff --git a/pkg/pipeline/history/ConfigMapHistoryService.go b/pkg/pipeline/history/ConfigMapHistoryService.go index b24fa2a0bb..8c15993be4 100644 --- a/pkg/pipeline/history/ConfigMapHistoryService.go +++ b/pkg/pipeline/history/ConfigMapHistoryService.go @@ -6,8 +6,8 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" diff --git a/pkg/pipeline/history/DeployedConfigurationHistoryService.go b/pkg/pipeline/history/DeployedConfigurationHistoryService.go index 4a582f1e3d..a3732dd484 100644 --- a/pkg/pipeline/history/DeployedConfigurationHistoryService.go +++ b/pkg/pipeline/history/DeployedConfigurationHistoryService.go @@ -4,15 +4,15 @@ import ( "context" "errors" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" "github.com/devtron-labs/devtron/pkg/variables" repository5 "github.com/devtron-labs/devtron/pkg/variables/repository" util4 "github.com/devtron-labs/devtron/util" "time" "github.com/devtron-labs/devtron/api/bean" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/go-pg/pg" diff --git a/pkg/pipeline/history/DeploymentTemplateHistoryService.go b/pkg/pipeline/history/DeploymentTemplateHistoryService.go index 8871f9cd98..2f174b219b 100644 --- a/pkg/pipeline/history/DeploymentTemplateHistoryService.go +++ b/pkg/pipeline/history/DeploymentTemplateHistoryService.go @@ -6,8 +6,8 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/chartRef" "time" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" diff --git a/pkg/pipeline/history/GitMaterialHistoryService.go b/pkg/pipeline/history/GitMaterialHistoryService.go index e2a19cfad4..ddd6c3c846 100644 --- a/pkg/pipeline/history/GitMaterialHistoryService.go +++ b/pkg/pipeline/history/GitMaterialHistoryService.go @@ -1,7 +1,7 @@ package history import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/sql" "go.uber.org/zap" diff --git a/pkg/pipeline/history/GitMaterialHistoryService_test.go b/pkg/pipeline/history/GitMaterialHistoryService_test.go index d0e1fd247b..622bad1efc 100644 --- a/pkg/pipeline/history/GitMaterialHistoryService_test.go +++ b/pkg/pipeline/history/GitMaterialHistoryService_test.go @@ -1,8 +1,8 @@ package history import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository/mocks" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/history/PipelineStrategyHistoryService.go b/pkg/pipeline/history/PipelineStrategyHistoryService.go index 6b8654470f..3226ed2a39 100644 --- a/pkg/pipeline/history/PipelineStrategyHistoryService.go +++ b/pkg/pipeline/history/PipelineStrategyHistoryService.go @@ -3,8 +3,8 @@ package history import ( "time" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/history/PrePostCdScriptHistoryService.go b/pkg/pipeline/history/PrePostCdScriptHistoryService.go index d1186e5031..0fa41770be 100644 --- a/pkg/pipeline/history/PrePostCdScriptHistoryService.go +++ b/pkg/pipeline/history/PrePostCdScriptHistoryService.go @@ -2,8 +2,8 @@ package history import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/history/PrePostCiScriptHistoryService.go b/pkg/pipeline/history/PrePostCiScriptHistoryService.go index 35cb965a4b..e00b14116c 100644 --- a/pkg/pipeline/history/PrePostCiScriptHistoryService.go +++ b/pkg/pipeline/history/PrePostCiScriptHistoryService.go @@ -1,7 +1,7 @@ package history import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/pipeline/history/bean.go b/pkg/pipeline/history/bean.go index 893144ccdf..fd4aec74f7 100644 --- a/pkg/pipeline/history/bean.go +++ b/pkg/pipeline/history/bean.go @@ -1,7 +1,7 @@ package history import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "time" ) diff --git a/pkg/pipeline/history/ciTemplateHistoryService_test.go b/pkg/pipeline/history/ciTemplateHistoryService_test.go index 80e4a23ca9..ea23ce821c 100644 --- a/pkg/pipeline/history/ciTemplateHistoryService_test.go +++ b/pkg/pipeline/history/ciTemplateHistoryService_test.go @@ -1,8 +1,8 @@ package history import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository/mocks" diff --git a/pkg/pipeline/history/mocks/ConfigMapHistoryService.go b/pkg/pipeline/history/mocks/ConfigMapHistoryService.go index 1ed6150ba6..d562c53f42 100644 --- a/pkg/pipeline/history/mocks/ConfigMapHistoryService.go +++ b/pkg/pipeline/history/mocks/ConfigMapHistoryService.go @@ -3,13 +3,13 @@ package mocks import ( - chartConfig "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + chartConfig "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" "github.com/devtron-labs/devtron/pkg/bean" history "github.com/devtron-labs/devtron/pkg/pipeline/history" mock "github.com/stretchr/testify/mock" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" repository "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" diff --git a/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go b/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go index c56435a245..e7f5ed4a64 100644 --- a/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go +++ b/pkg/pipeline/history/repository/PipelineStrategyHistoryRepository.go @@ -1,7 +1,7 @@ package repository import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/chartRepo/repository" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" diff --git a/pkg/pipeline/history/repository/PrePostCdScriptHistoryRepository.go b/pkg/pipeline/history/repository/PrePostCdScriptHistoryRepository.go index 4dd6c46123..b80ce0d97b 100644 --- a/pkg/pipeline/history/repository/PrePostCdScriptHistoryRepository.go +++ b/pkg/pipeline/history/repository/PrePostCdScriptHistoryRepository.go @@ -1,7 +1,7 @@ package repository import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/pipeline/history/repository/ciTemplateHistoryRepository.go b/pkg/pipeline/history/repository/ciTemplateHistoryRepository.go index aafc0aed9a..895725d285 100644 --- a/pkg/pipeline/history/repository/ciTemplateHistoryRepository.go +++ b/pkg/pipeline/history/repository/ciTemplateHistoryRepository.go @@ -1,8 +1,8 @@ package repository import ( - "github.com/devtron-labs/devtron/internal/sql/repository/app" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/pipeline/mock_pipeline/PipelineBuilder.go b/pkg/pipeline/mock_pipeline/PipelineBuilder.go index dd2acc9732..262111377b 100644 --- a/pkg/pipeline/mock_pipeline/PipelineBuilder.go +++ b/pkg/pipeline/mock_pipeline/PipelineBuilder.go @@ -10,8 +10,8 @@ import ( reflect "reflect" bean "github.com/devtron-labs/devtron/api/bean" - helper "github.com/devtron-labs/devtron/internal/sql/repository/helper" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + helper "github.com/devtron-labs/devtron/internals/sql/repository/helper" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean0 "github.com/devtron-labs/devtron/pkg/bean" pipeline "github.com/devtron-labs/devtron/pkg/pipeline" appGroup "github.com/devtron-labs/devtron/pkg/resourceGroup" diff --git a/pkg/pipeline/pipelineStageVariableParser.go b/pkg/pipeline/pipelineStageVariableParser.go index b938e384ce..a78f8be2d6 100644 --- a/pkg/pipeline/pipelineStageVariableParser.go +++ b/pkg/pipeline/pipelineStageVariableParser.go @@ -3,8 +3,8 @@ package pipeline import ( "errors" "fmt" - dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/util" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/pipeline/bean" "github.com/devtron-labs/devtron/pkg/plugin" "github.com/go-pg/pg" diff --git a/pkg/pipeline/types/CiCdConfig.go b/pkg/pipeline/types/CiCdConfig.go index 934a82a682..87d90f27f3 100644 --- a/pkg/pipeline/types/CiCdConfig.go +++ b/pkg/pipeline/types/CiCdConfig.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/caarlos0/env" blob_storage "github.com/devtron-labs/common-lib/blob-storage" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/pipeline/bean" v12 "k8s.io/api/core/v1" "k8s.io/client-go/rest" diff --git a/pkg/pipeline/types/DockerRegistry.go b/pkg/pipeline/types/DockerRegistry.go index 33ae9cb0be..deef4f6632 100644 --- a/pkg/pipeline/types/DockerRegistry.go +++ b/pkg/pipeline/types/DockerRegistry.go @@ -1,7 +1,7 @@ package types import ( - "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" ) type DockerArtifactStoreBean struct { diff --git a/pkg/pipeline/types/Git.go b/pkg/pipeline/types/Git.go index 4c4ee084f0..07494e6cb5 100644 --- a/pkg/pipeline/types/Git.go +++ b/pkg/pipeline/types/Git.go @@ -1,6 +1,6 @@ package types -import "github.com/devtron-labs/devtron/internal/sql/repository" +import "github.com/devtron-labs/devtron/internals/sql/repository" type GitRegistry struct { Id int `json:"id,omitempty" validate:"number"` diff --git a/pkg/pipeline/types/ImageTagging.go b/pkg/pipeline/types/ImageTagging.go index b868c1e0f1..cfe129e60a 100644 --- a/pkg/pipeline/types/ImageTagging.go +++ b/pkg/pipeline/types/ImageTagging.go @@ -1,6 +1,6 @@ package types -import "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" +import "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" type ImageTaggingResponseDTO struct { ImageReleaseTags []*repository.ImageTag `json:"imageReleaseTags"` diff --git a/pkg/pipeline/types/Workflow.go b/pkg/pipeline/types/Workflow.go index 3d8713a056..4e87aa7711 100644 --- a/pkg/pipeline/types/Workflow.go +++ b/pkg/pipeline/types/Workflow.go @@ -23,9 +23,9 @@ import ( "github.com/argoproj/argo-workflows/v3/workflow/common" "github.com/devtron-labs/common-lib/blob-storage" bean3 "github.com/devtron-labs/devtron/api/bean" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - repository3 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + repository3 "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean2 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/infraConfig" diff --git a/pkg/resourceGroup/ResourceGroupService.go b/pkg/resourceGroup/ResourceGroupService.go index aeb9dfbda3..a2ca30dc75 100644 --- a/pkg/resourceGroup/ResourceGroupService.go +++ b/pkg/resourceGroup/ResourceGroupService.go @@ -22,9 +22,9 @@ import ( "strings" "time" - appStatusRepo "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" - "github.com/devtron-labs/devtron/internal/util" + appStatusRepo "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/resourceGroup" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/devtronResource" "github.com/devtron-labs/devtron/pkg/devtronResource/bean" diff --git a/pkg/security/ImageScanService.go b/pkg/security/ImageScanService.go index 402034a157..262088baf3 100644 --- a/pkg/security/ImageScanService.go +++ b/pkg/security/ImageScanService.go @@ -21,14 +21,14 @@ import ( "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "time" - repository1 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository1 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/auth/user" repository2 "github.com/devtron-labs/devtron/pkg/team" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/security/policyService.go b/pkg/security/policyService.go index 0aa06c90a8..39eb41af72 100644 --- a/pkg/security/policyService.go +++ b/pkg/security/policyService.go @@ -21,8 +21,8 @@ import ( "bytes" "encoding/json" "fmt" - repository1 "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + repository1 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" "net/http" @@ -30,10 +30,10 @@ import ( "time" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/cluster" "github.com/go-pg/pg" "go.uber.org/zap" diff --git a/pkg/security/policyService_test.go b/pkg/security/policyService_test.go index 5df1311b7e..d58b00fc93 100644 --- a/pkg/security/policyService_test.go +++ b/pkg/security/policyService_test.go @@ -1,7 +1,7 @@ package security import ( - "github.com/devtron-labs/devtron/internal/sql/repository/security" + "github.com/devtron-labs/devtron/internals/sql/repository/security" "testing" ) diff --git a/pkg/sql/connection.go b/pkg/sql/connection.go index 31911c8293..3af094e3bf 100644 --- a/pkg/sql/connection.go +++ b/pkg/sql/connection.go @@ -18,7 +18,7 @@ package sql import ( - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" "go.uber.org/zap" "reflect" "time" diff --git a/pkg/team/TeamService.go b/pkg/team/TeamService.go index eff3ea31f9..ff7cd26e67 100644 --- a/pkg/team/TeamService.go +++ b/pkg/team/TeamService.go @@ -22,8 +22,8 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/internal/constants" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/constants" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/auth/user" "github.com/devtron-labs/devtron/pkg/auth/user/bean" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/variables/ScopedVariableCMCSManager.go b/pkg/variables/ScopedVariableCMCSManager.go index 42507efaf0..8a87364a6e 100644 --- a/pkg/variables/ScopedVariableCMCSManager.go +++ b/pkg/variables/ScopedVariableCMCSManager.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" bean2 "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/resourceQualifiers" diff --git a/pkg/variables/parsers/VariableTemplateParser_test.go b/pkg/variables/parsers/VariableTemplateParser_test.go index fa3ebf142f..2564814d62 100644 --- a/pkg/variables/parsers/VariableTemplateParser_test.go +++ b/pkg/variables/parsers/VariableTemplateParser_test.go @@ -1,7 +1,7 @@ package parsers import ( - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/variables/models" "github.com/stretchr/testify/assert" "testing" diff --git a/pkg/workflow/cd/CdWorkflowCommonService.go b/pkg/workflow/cd/CdWorkflowCommonService.go index 65a91d236d..347b6565fe 100644 --- a/pkg/workflow/cd/CdWorkflowCommonService.go +++ b/pkg/workflow/cd/CdWorkflowCommonService.go @@ -8,8 +8,8 @@ import ( "github.com/devtron-labs/common-lib/pubsub-lib/model" "github.com/devtron-labs/common-lib/utils/k8s/health" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app/status" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/workflow/cd/CdWorkflowRunnerService.go b/pkg/workflow/cd/CdWorkflowRunnerService.go index 68a64cbd6a..4282c27b0c 100644 --- a/pkg/workflow/cd/CdWorkflowRunnerService.go +++ b/pkg/workflow/cd/CdWorkflowRunnerService.go @@ -1,7 +1,7 @@ package cd import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/workflow/cd/adapter" "github.com/devtron-labs/devtron/pkg/workflow/cd/bean" "go.uber.org/zap" diff --git a/pkg/workflow/cd/CdWorkflowService.go b/pkg/workflow/cd/CdWorkflowService.go index 592ab55f6b..16c2c6380e 100644 --- a/pkg/workflow/cd/CdWorkflowService.go +++ b/pkg/workflow/cd/CdWorkflowService.go @@ -1,7 +1,7 @@ package cd import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/workflow/cd/adapter" "github.com/devtron-labs/devtron/pkg/workflow/cd/bean" "go.uber.org/zap" diff --git a/pkg/workflow/cd/adapter/adapter.go b/pkg/workflow/cd/adapter/adapter.go index 7ba4b5b76d..b5346ef18e 100644 --- a/pkg/workflow/cd/adapter/adapter.go +++ b/pkg/workflow/cd/adapter/adapter.go @@ -1,7 +1,7 @@ package adapter import ( - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/sql" "github.com/devtron-labs/devtron/pkg/workflow/cd/bean" "time" diff --git a/pkg/workflow/cd/bean/bean.go b/pkg/workflow/cd/bean/bean.go index f0413f843d..cc14c39b4d 100644 --- a/pkg/workflow/cd/bean/bean.go +++ b/pkg/workflow/cd/bean/bean.go @@ -2,7 +2,7 @@ package bean import ( "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "time" ) diff --git a/pkg/workflow/dag/WorkflowDagExecutor.go b/pkg/workflow/dag/WorkflowDagExecutor.go index ccf9a53a45..2569e95900 100644 --- a/pkg/workflow/dag/WorkflowDagExecutor.go +++ b/pkg/workflow/dag/WorkflowDagExecutor.go @@ -54,12 +54,12 @@ import ( pubsub "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/api/bean" - "github.com/devtron-labs/devtron/internal/sql/models" - "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/models" + "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/util/rbac" "github.com/go-pg/pg" diff --git a/pkg/workflow/dag/bean/bean.go b/pkg/workflow/dag/bean/bean.go index 4e4af68cdb..2c6a9038b4 100644 --- a/pkg/workflow/dag/bean/bean.go +++ b/pkg/workflow/dag/bean/bean.go @@ -2,7 +2,7 @@ package bean import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository" ) type CiArtifactWebhookRequest struct { diff --git a/pkg/workflow/status/WorkflowStatusService.go b/pkg/workflow/status/WorkflowStatusService.go index e121e83bd8..91112b0387 100644 --- a/pkg/workflow/status/WorkflowStatusService.go +++ b/pkg/workflow/status/WorkflowStatusService.go @@ -10,9 +10,9 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/client/argocdServer/application" client2 "github.com/devtron-labs/devtron/client/events" - appRepository "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + appRepository "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" app_status "github.com/devtron-labs/devtron/pkg/appStatus" diff --git a/tests/e2e/BasicTestConf.go b/tests/e2e/BasicTestConf.go index dacee350ae..c05aaf72a8 100644 --- a/tests/e2e/BasicTestConf.go +++ b/tests/e2e/BasicTestConf.go @@ -1,4 +1,3 @@ - /* * Copyright (c) 2020 Devtron Labs * @@ -18,117 +17,117 @@ package e2e import ( - "github.com/go-resty/resty/v2" - "encoding/json" - "net/http" - "github.com/devtron-labs/devtron/internal/util" - "io/ioutil" - "os" - "fmt" + "encoding/json" + "fmt" + "github.com/devtron-labs/devtron/internals/util" + "github.com/go-resty/resty/v2" + "io/ioutil" + "net/http" + "os" ) type LogInResult struct { - Token string `json:"token"` + Token string `json:"token"` } type LogInResponse struct { - Code int `json:"code"` - Status string `json:"status"` - Result LogInResult `json:"result"` + Code int `json:"code"` + Status string `json:"status"` + Result LogInResult `json:"result"` } type EnvironmentConf struct { - TestEnv string `json.testEnv` - EnvList []Environment `json:"environment"` + TestEnv string `json.testEnv` + EnvList []Environment `json:"environment"` } type Environment struct { - EnvironmentName string `json:"envName"` - BaseServerUrl string `json:baseServerUrl` - LogInUserName string `json:"loginUserName"` - LogInUserPwd string `json:loginUserPwd` + EnvironmentName string `json:"envName"` + BaseServerUrl string `json:baseServerUrl` + LogInUserName string `json:"loginUserName"` + LogInUserPwd string `json:loginUserPwd` } -//Give resty client along with some basic settings like cookie etc +// Give resty client along with some basic settings like cookie etc func getRestyClient(setCookie bool) *resty.Client { - baseServerUrl, _, _ := getBaseServerDetails() - client := resty.New() - client.SetBaseURL(baseServerUrl) - if(setCookie) { - client.SetCookie(&http.Cookie{Name:"argocd.token", - Value: getAuthToken(), - Path: "/", - Domain: baseServerUrl}) - } - return client + baseServerUrl, _, _ := getBaseServerDetails() + client := resty.New() + client.SetBaseURL(baseServerUrl) + if setCookie { + client.SetCookie(&http.Cookie{Name: "argocd.token", + Value: getAuthToken(), + Path: "/", + Domain: baseServerUrl}) + } + return client } -//this function will read testEnvironmentConfig.json file and get baseServerUrl, username and pwd depending on environment +// this function will read testEnvironmentConfig.json file and get baseServerUrl, username and pwd depending on environment func getBaseServerDetails() (string, string, string) { - var envToTest, baseServerUrl, loginUserName, loginUserPwd string - - //STEP 1 : Open the file - testDataJsonFile, err := os.Open("../testdata/testEnvironmentConfig.json") - if (nil != err) { - util.GetLogger().Errorw("Unable to open the file. Error occurred !!", "err", err) - } - util.GetLogger().Infow("Opened testEnvironmentConfig.json file successfully !") - - defer testDataJsonFile.Close() - - // STEP 2 : Now get required values depending on environment requested. - byteValue, _ := ioutil.ReadAll(testDataJsonFile) - var envConf EnvironmentConf - json.Unmarshal([]byte(byteValue), &envConf) - - envToTest = envConf.TestEnv - - for i := 0; i < len(envConf.EnvList); i++ { - if(envToTest == envConf.EnvList[i].EnvironmentName) { - baseServerUrl = envConf.EnvList[i].BaseServerUrl - loginUserName = envConf.EnvList[i].LogInUserName - loginUserPwd = envConf.EnvList[i].LogInUserPwd - } - } - util.GetLogger().Infow("BaseServerUrl: ", "URL:", baseServerUrl) - return baseServerUrl, loginUserName, loginUserPwd + var envToTest, baseServerUrl, loginUserName, loginUserPwd string + + //STEP 1 : Open the file + testDataJsonFile, err := os.Open("../testdata/testEnvironmentConfig.json") + if nil != err { + util.GetLogger().Errorw("Unable to open the file. Error occurred !!", "err", err) + } + util.GetLogger().Infow("Opened testEnvironmentConfig.json file successfully !") + + defer testDataJsonFile.Close() + + // STEP 2 : Now get required values depending on environment requested. + byteValue, _ := ioutil.ReadAll(testDataJsonFile) + var envConf EnvironmentConf + json.Unmarshal([]byte(byteValue), &envConf) + + envToTest = envConf.TestEnv + + for i := 0; i < len(envConf.EnvList); i++ { + if envToTest == envConf.EnvList[i].EnvironmentName { + baseServerUrl = envConf.EnvList[i].BaseServerUrl + loginUserName = envConf.EnvList[i].LogInUserName + loginUserPwd = envConf.EnvList[i].LogInUserPwd + } + } + util.GetLogger().Infow("BaseServerUrl: ", "URL:", baseServerUrl) + return baseServerUrl, loginUserName, loginUserPwd } -//make the api call to the requested url based on http method requested -func makeApiCall(apiUrl string, method string, body string, setCookie bool) (*resty.Response, error) { - var resp *resty.Response - var err error - switch method { - case "GET": - return getRestyClient(setCookie).R().Get(apiUrl) - case "POST": - return getRestyClient(setCookie).R().SetBody(body).Post(apiUrl) - } - return resp, err +// make the api call to the requested url based on http method requested +func makeApiCall(apiUrl string, method string, body string, setCookie bool) (*resty.Response, error) { + var resp *resty.Response + var err error + switch method { + case "GET": + return getRestyClient(setCookie).R().Get(apiUrl) + case "POST": + return getRestyClient(setCookie).R().SetBody(body).Post(apiUrl) + } + return resp, err } -//Log the error and return boolean value indicating whether error occurred or not +// Log the error and return boolean value indicating whether error occurred or not func handleError(err error, testName string) bool { - if(nil != err) { - util.GetLogger().Errorw("Error occurred while invoking api for test:" +testName, "err", err) - return true - } - return false + if nil != err { + util.GetLogger().Errorw("Error occurred while invoking api for test:"+testName, "err", err) + return true + } + return false } -//support function to return auth token after log in -//TODO : if token is valid, don't call api again, error handling in invoking functions +// support function to return auth token after log in +// TODO : if token is valid, don't call api again, error handling in invoking functions func getAuthToken() string { - _, loginUserName, loginUserPwd := getBaseServerDetails() - jsonString := fmt.Sprintf(`{"username": "%s", "password": "%s"}`,loginUserName,loginUserPwd) - fmt.Println("jsonString : ", jsonString) - resp, err := makeApiCall("/orchestrator/api/v1/session", http.MethodPost, jsonString, false) - if(handleError(err, "getAuthToken")) { - return "" - } - var logInResponse LogInResponse - json.Unmarshal([]byte(resp.Body()), &logInResponse) - util.GetLogger().Infow("Getting Auth token : ", "AuthToken:", logInResponse.Result.Token) - return logInResponse.Result.Token -} \ No newline at end of file + _, loginUserName, loginUserPwd := getBaseServerDetails() + jsonString := fmt.Sprintf(`{"username": "%s", "password": "%s"}`, loginUserName, loginUserPwd) + fmt.Println("jsonString : ", jsonString) + resp, err := makeApiCall("/orchestrator/api/v1/session", http.MethodPost, jsonString, false) + if handleError(err, "getAuthToken") { + return "" + } + var logInResponse LogInResponse + json.Unmarshal([]byte(resp.Body()), &logInResponse) + util.GetLogger().Infow("Getting Auth token : ", "AuthToken:", logInResponse.Result.Token) + return logInResponse.Result.Token +} diff --git a/tests/e2e/CheckList_test.go b/tests/e2e/CheckList_test.go index 6d351928e6..2478c272ca 100644 --- a/tests/e2e/CheckList_test.go +++ b/tests/e2e/CheckList_test.go @@ -1,4 +1,3 @@ - /* * Copyright (c) 2020 Devtron Labs * @@ -18,50 +17,50 @@ package e2e import ( - //"fmt" - //"github.com/go-resty/resty/v2" - "testing" - "encoding/json" - "net/http" - "github.com/stretchr/testify/assert" - "github.com/devtron-labs/devtron/internal/util" + //"fmt" + //"github.com/go-resty/resty/v2" + "encoding/json" + "github.com/devtron-labs/devtron/internals/util" + "github.com/stretchr/testify/assert" + "net/http" + "testing" ) -//TODO : Ask if we should reuse struct from other package or create new. What's better? +// TODO : Ask if we should reuse struct from other package or create new. What's better? type AppCheckList struct { - GitOps int `json:"gitOps"` - Project int `json:"project"` - Git int `json:"git"` - Environment int `json:"environment"` - Docker int `json:"docker"` - HostUrl int `json:"hostUrl"` + GitOps int `json:"gitOps"` + Project int `json:"project"` + Git int `json:"git"` + Environment int `json:"environment"` + Docker int `json:"docker"` + HostUrl int `json:"hostUrl"` } type ChartCheckList struct { - GitOps int `json:"gitOps"` - Project int `json:"project"` - Environment int `json:"environment"` + GitOps int `json:"gitOps"` + Project int `json:"project"` + Environment int `json:"environment"` } type CheckListResult struct { - AppCheckList AppCheckList `json:"appChecklist"` - ChartCheckList ChartCheckList `json:"chartChecklist"` - IsAppCreated bool `json:"isAppCreated"` + AppCheckList AppCheckList `json:"appChecklist"` + ChartCheckList ChartCheckList `json:"chartChecklist"` + IsAppCreated bool `json:"isAppCreated"` } type CheckListResponse struct { - Code int `json:"code"` - Status string `json:"status"` - Result CheckListResult `json:"result"` + Code int `json:"code"` + Status string `json:"status"` + Result CheckListResult `json:"result"` } func TestCheckList(t *testing.T) { - resp, err := makeApiCall("/orchestrator/global/checklist", http.MethodGet, "", true) - if(handleError(err, "TestCheckList")) { - return - } - assert.Equal(t, 200, resp.StatusCode()) - var checkListResponse CheckListResponse - json.Unmarshal([]byte(resp.Body()), &checkListResponse) - util.GetLogger().Infow("Printing response from test TestCheckList : ", "CheckListResponse object:", checkListResponse) -} \ No newline at end of file + resp, err := makeApiCall("/orchestrator/global/checklist", http.MethodGet, "", true) + if handleError(err, "TestCheckList") { + return + } + assert.Equal(t, 200, resp.StatusCode()) + var checkListResponse CheckListResponse + json.Unmarshal([]byte(resp.Body()), &checkListResponse) + util.GetLogger().Infow("Printing response from test TestCheckList : ", "CheckListResponse object:", checkListResponse) +} diff --git a/tests/pipeline/ChartService_test.go b/tests/pipeline/ChartService_test.go index 8fa0b7134d..12f944ed9b 100644 --- a/tests/pipeline/ChartService_test.go +++ b/tests/pipeline/ChartService_test.go @@ -4,8 +4,8 @@ import ( "encoding/csv" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/sql/repository/bulkUpdate" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/bulkAction" "github.com/devtron-labs/devtron/pkg/chart" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/util/helper.go b/util/helper.go index 1c03e5c2cc..392eef7339 100644 --- a/util/helper.go +++ b/util/helper.go @@ -23,7 +23,7 @@ import ( "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/service/ecr/types" - "github.com/devtron-labs/devtron/internal/middleware" + "github.com/devtron-labs/devtron/internals/middleware" "github.com/juju/errors" "io" "io/ioutil" diff --git a/util/mocks/rbac/EnforcerUtil.go b/util/mocks/rbac/EnforcerUtil.go index ac5d5f0402..6d968bfab1 100644 --- a/util/mocks/rbac/EnforcerUtil.go +++ b/util/mocks/rbac/EnforcerUtil.go @@ -8,7 +8,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" reflect "reflect" - pipelineConfig "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + pipelineConfig "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" bean "github.com/devtron-labs/devtron/pkg/bean" gomock "github.com/golang/mock/gomock" ) diff --git a/util/rbac/EnforcerUtil.go b/util/rbac/EnforcerUtil.go index e935352a82..3f83fbfaf9 100644 --- a/util/rbac/EnforcerUtil.go +++ b/util/rbac/EnforcerUtil.go @@ -22,12 +22,12 @@ import ( "strings" "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/pkg/bean" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/team" diff --git a/util/rbac/EnforcerUtilHelm.go b/util/rbac/EnforcerUtilHelm.go index 7084732fcc..8a4d7a1295 100644 --- a/util/rbac/EnforcerUtilHelm.go +++ b/util/rbac/EnforcerUtilHelm.go @@ -2,7 +2,7 @@ package rbac import ( "fmt" - "github.com/devtron-labs/devtron/internal/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/app" repository2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/devtron-labs/devtron/pkg/team" diff --git a/util/response/response.go b/util/response/response.go index 4ae98c4ed6..97f089b3e8 100644 --- a/util/response/response.go +++ b/util/response/response.go @@ -19,7 +19,7 @@ package response import ( "encoding/json" - "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/internals/util" "net/http" ) diff --git a/wire_gen.go b/wire_gen.go index c50c2b64bd..57685ef368 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -77,19 +77,19 @@ import ( "github.com/devtron-labs/devtron/client/lens" "github.com/devtron-labs/devtron/client/proxy" "github.com/devtron-labs/devtron/client/telemetry" - repository2 "github.com/devtron-labs/devtron/internal/sql/repository" - "github.com/devtron-labs/devtron/internal/sql/repository/app" - "github.com/devtron-labs/devtron/internal/sql/repository/appStatus" - "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" - "github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate" - "github.com/devtron-labs/devtron/internal/sql/repository/chartConfig" - repository5 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository12 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" - "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" - "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" - "github.com/devtron-labs/devtron/internal/sql/repository/security" - "github.com/devtron-labs/devtron/internal/util" + repository2 "github.com/devtron-labs/devtron/internals/sql/repository" + "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + "github.com/devtron-labs/devtron/internals/sql/repository/appWorkflow" + "github.com/devtron-labs/devtron/internals/sql/repository/bulkUpdate" + "github.com/devtron-labs/devtron/internals/sql/repository/chartConfig" + repository5 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/helper" + repository12 "github.com/devtron-labs/devtron/internals/sql/repository/imageTagging" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internals/sql/repository/resourceGroup" + "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/internals/util" "github.com/devtron-labs/devtron/pkg/apiToken" app2 "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/app/status" From af26996cac57723bdd4dbcf5eef1c6f72814dbdf Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 12:51:33 +0530 Subject: [PATCH 66/83] test --- commonWireset/commonWireset.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonWireset/commonWireset.go b/commonWireset/commonWireset.go index 677c889d2f..ca907975a9 100644 --- a/commonWireset/commonWireset.go +++ b/commonWireset/commonWireset.go @@ -18,7 +18,7 @@ import ( "github.com/devtron-labs/devtron/api/connector" "github.com/devtron-labs/devtron/api/dashboardEvent" "github.com/devtron-labs/devtron/api/deployment" - "github.com/devtron-labs/devtron/api/externalLink" + externalLink "github.com/devtron-labs/devtron/api/externalLink" client "github.com/devtron-labs/devtron/api/helm-app" "github.com/devtron-labs/devtron/api/infraConfig" "github.com/devtron-labs/devtron/api/k8s" From 035825bb2400d925cd27359237e12f3d29e207cc Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 16:50:05 +0530 Subject: [PATCH 67/83] code made common --- api/helm-app/bean/bean.go | 1 + .../service/AppStoreDeploymentDBService.go | 8 ++++++++ .../installedApp/service/AppStoreDeploymentService.go | 10 ++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/helm-app/bean/bean.go b/api/helm-app/bean/bean.go index f1222946e5..7b8daff9b5 100644 --- a/api/helm-app/bean/bean.go +++ b/api/helm-app/bean/bean.go @@ -79,4 +79,5 @@ type InstalledAppInfo struct { TeamId int `json:"teamId"` TeamName string `json:"teamName"` DeploymentType string `json:"deploymentType"` + HelmPackageName string `json:"helmPackageName"` } diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index d54b60b9bf..d759c433ab 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -146,6 +146,12 @@ func (impl *AppStoreDeploymentDBServiceImpl) AppStoreDeployOperationDB(installAp installAppVersionRequest.Id = installedAppVersions.Id // Stage 4: ends + // populate HelmPackageName; It's used in case of virtual deployments + installAppVersionRequest.HelmPackageName = adapter.GetGeneratedHelmPackageName( + installAppVersionRequest.AppName, + installAppVersionRequest.Environment.Environment, + installedApp.UpdatedOn) + // Stage 5: save installed_app_version_history model helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ InstallAppVersionHistoryId: 0, @@ -435,6 +441,7 @@ func (impl *AppStoreDeploymentDBServiceImpl) createAppForAppStore(createRequest if activeApp != nil && activeApp.Id > 0 { impl.logger.Infow(" app already exists", "name", createRequest.AppName) err = &util.ApiError{ + HttpStatusCode: http.StatusBadRequest, Code: constants.AppAlreadyExists.Code, InternalMessage: "app already exists", UserMessage: fmt.Sprintf("app already exists with name %s", createRequest.AppName), @@ -476,6 +483,7 @@ func (impl *AppStoreDeploymentDBServiceImpl) validateAndGetOverrideDeploymentApp if isOCIRepo || getAppInstallationMode(installAppVersionRequest.AppOfferingMode) == globalUtil.SERVER_MODE_HYPERION { overrideDeploymentType = util.PIPELINE_DEPLOYMENT_TYPE_HELM } + overrideDeploymentType, err = impl.deploymentTypeOverrideService.ValidateAndOverrideDeploymentAppType(overrideDeploymentType, isGitOpsConfigured, installAppVersionRequest.EnvironmentId) if err != nil { impl.logger.Errorw("validation error for the used deployment type", "appName", installAppVersionRequest.AppName, "err", err) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 47c91d39c1..14164f4066 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -491,6 +491,10 @@ func (impl *AppStoreDeploymentServiceImpl) GetDeploymentHistory(ctx context.Cont ClusterId: installedApp.ClusterId, EnvironmentId: installedApp.EnvironmentId, DeploymentType: installedApp.DeploymentAppType, + HelmPackageName: adapter.GetGeneratedHelmPackageName( + installedApp.AppName, + installedApp.Environment.Environment, + installedApp.UpdatedOn), } } @@ -601,7 +605,6 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex return nil, err } adapter.UpdateAdditionalEnvDetails(installAppVersionRequest, environment) - helmInstallConfigDTO := appStoreBean.HelmReleaseStatusConfig{ InstallAppVersionHistoryId: 0, Message: "Install initiated", @@ -706,8 +709,11 @@ func (impl *AppStoreDeploymentServiceImpl) UpdateInstalledApp(ctx context.Contex impl.logger.Errorw("error while committing transaction to db", "error", err) return nil, err } - if util.IsManifestDownload(installAppVersionRequest.DeploymentAppType) { + installAppVersionRequest.HelmPackageName = adapter.GetGeneratedHelmPackageName( + installAppVersionRequest.AppName, + installAppVersionRequest.Environment.Environment, + installedApp.UpdatedOn) err = impl.appStoreDeploymentDBService.UpdateInstalledAppVersionHistoryStatus(installAppVersionRequest.InstalledAppVersionHistoryId, pipelineConfig.WorkflowSucceeded) if err != nil { impl.logger.Errorw("error on creating history for chart deployment", "error", err) From 02badc2974c192a986c497d1b7d32cf3b7d123fa Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 18:52:59 +0530 Subject: [PATCH 68/83] code refactored --- .../service/AppStoreDeploymentService.go | 128 ++++++++++-------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 14164f4066..133147c0df 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -39,6 +39,7 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" bean2 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" "github.com/devtron-labs/devtron/pkg/cluster" + "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" util2 "github.com/devtron-labs/devtron/util" "github.com/go-pg/pg" @@ -61,6 +62,7 @@ type AppStoreDeploymentService interface { InstallAppByHelm(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ctx context.Context) (*appStoreBean.InstallAppVersionDTO, error) UpdatePreviousDeploymentStatusForAppStore(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, triggeredAt time.Time, err error) error MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId int) error + SoftDeleteApp(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, model *repository.InstalledApps, tx *pg.Tx, ctx context.Context, environment *bean.EnvironmentBean) error } type AppStoreDeploymentServiceImpl struct { @@ -251,78 +253,86 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex return nil, err } } else { - //soft delete app - app.Active = false - app.UpdatedBy = installAppVersionRequest.UserId - app.UpdatedOn = time.Now() - err = impl.appRepository.UpdateWithTxn(app, tx) + err := impl.SoftDeleteApp(app, installAppVersionRequest, model, tx, ctx, environment) if err != nil { - impl.logger.Errorw("error in update entity ", "entity", app) return nil, err } + } + err = tx.Commit() + if err != nil { + impl.logger.Errorw("error in commit db transaction on delete", "err", err) + return nil, err + } + installAppVersionRequest.InstalledAppDeleteResponse.DeleteInitiated = true + return installAppVersionRequest, nil +} - // soft delete install app - model.Active = false - model.UpdatedBy = installAppVersionRequest.UserId - model.UpdatedOn = time.Now() - _, err = impl.installedAppRepository.UpdateInstalledApp(model, tx) - if err != nil { - impl.logger.Errorw("error while creating install app", "error", err) - return nil, err - } - models, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installAppVersionRequest.InstalledAppId) - if err != nil { - impl.logger.Errorw("error while fetching install app versions", "error", err) - return nil, err - } +func (impl *AppStoreDeploymentServiceImpl) SoftDeleteApp(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, model *repository.InstalledApps, tx *pg.Tx, ctx context.Context, environment *bean.EnvironmentBean) error { + //soft delete app + app.Active = false + app.UpdatedBy = installAppVersionRequest.UserId + app.UpdatedOn = time.Now() + err := impl.appRepository.UpdateWithTxn(app, tx) + if err != nil { + impl.logger.Errorw("error in update entity ", "entity", app) + return err + } - // soft delete install app versions - for _, item := range models { - item.Active = false - item.UpdatedBy = installAppVersionRequest.UserId - item.UpdatedOn = time.Now() - _, err = impl.installedAppRepository.UpdateInstalledAppVersion(item, tx) - if err != nil { - impl.logger.Errorw("error while fetching from db", "error", err) - return nil, err - } - } + // soft delete install app + model.Active = false + model.UpdatedBy = installAppVersionRequest.UserId + model.UpdatedOn = time.Now() + _, err = impl.installedAppRepository.UpdateInstalledApp(model, tx) + if err != nil { + impl.logger.Errorw("error while creating install app", "error", err) + return err + } + models, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppId(installAppVersionRequest.InstalledAppId) + if err != nil { + impl.logger.Errorw("error while fetching install app versions", "error", err) + return err + } - // soft delete chart-group deployment - chartGroupDeployment, err := impl.chartGroupDeploymentRepository.FindByInstalledAppId(model.Id) - if err != nil && err != pg.ErrNoRows { - impl.logger.Errorw("error while fetching chart group deployment", "error", err) - return nil, err - } - if chartGroupDeployment.Id != 0 { - chartGroupDeployment.Deleted = true - _, err = impl.chartGroupDeploymentRepository.Update(chartGroupDeployment, tx) - if err != nil { - impl.logger.Errorw("error while updating chart group deployment", "error", err) - return nil, err - } + // soft delete install app versions + for _, item := range models { + item.Active = false + item.UpdatedBy = installAppVersionRequest.UserId + item.UpdatedOn = time.Now() + _, err = impl.installedAppRepository.UpdateInstalledAppVersion(item, tx) + if err != nil { + impl.logger.Errorw("error while fetching from db", "error", err) + return err } + } - if util2.IsBaseStack() || util2.IsHelmApp(app.AppOfferingMode) || util.IsHelmApp(model.DeploymentAppType) { - // there might be a case if helm release gets uninstalled from helm cli. - //in this case on deleting the app from API, it should not give error as it should get deleted from db, otherwise due to delete error, db does not get clean - // so in helm, we need to check first if the release exists or not, if exists then only delete - err = impl.eaModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) - } else { - err = impl.fullModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) - } + // soft delete chart-group deployment + chartGroupDeployment, err := impl.chartGroupDeploymentRepository.FindByInstalledAppId(model.Id) + if err != nil && err != pg.ErrNoRows { + impl.logger.Errorw("error while fetching chart group deployment", "error", err) + return err + } + if chartGroupDeployment.Id != 0 { + chartGroupDeployment.Deleted = true + _, err = impl.chartGroupDeploymentRepository.Update(chartGroupDeployment, tx) if err != nil { - impl.logger.Errorw("error on delete installed app", "err", err) - return nil, err + impl.logger.Errorw("error while updating chart group deployment", "error", err) + return err } } - err = tx.Commit() + + if util2.IsBaseStack() || util2.IsHelmApp(app.AppOfferingMode) || util.IsHelmApp(model.DeploymentAppType) { + // there might be a case if helm release gets uninstalled from helm cli. + //in this case on deleting the app from API, it should not give error as it should get deleted from db, otherwise due to delete error, db does not get clean + // so in helm, we need to check first if the release exists or not, if exists then only delete + err = impl.eaModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) + } else { + err = impl.fullModeDeploymentService.DeleteInstalledApp(ctx, app.AppName, environment.Environment, installAppVersionRequest, model, tx) + } if err != nil { - impl.logger.Errorw("error in commit db transaction on delete", "err", err) - return nil, err + impl.logger.Errorw("error on delete installed app", "err", err) + return err } - installAppVersionRequest.InstalledAppDeleteResponse.DeleteInitiated = true - return installAppVersionRequest, nil + return nil } func (impl *AppStoreDeploymentServiceImpl) LinkHelmApplicationToChartStore(ctx context.Context, request *openapi.UpdateReleaseWithChartLinkingRequest, From ae4e528a25b9af3876c6670650319b340cd20b0f Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Tue, 27 Feb 2024 19:19:19 +0530 Subject: [PATCH 69/83] code refactored --- .../installedApp/service/AppStoreDeploymentDBService.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index d759c433ab..1e44918562 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -49,6 +49,7 @@ type AppStoreDeploymentDBService interface { MarkInstalledAppVersionHistorySucceeded(versionHistoryId int, deploymentAppType string) error // UpdateInstalledAppVersionHistoryStatus will update the Status in the repository.InstalledAppVersionHistory UpdateInstalledAppVersionHistoryStatus(versionHistoryId int, status string) error + GetEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*clutserBean.EnvironmentBean, error) } type AppStoreDeploymentDBServiceImpl struct { @@ -89,7 +90,7 @@ func NewAppStoreDeploymentDBServiceImpl(logger *zap.SugaredLogger, } func (impl *AppStoreDeploymentDBServiceImpl) AppStoreDeployOperationDB(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) { - environment, err := impl.getEnvironmentForInstallAppRequest(installAppVersionRequest) + environment, err := impl.GetEnvironmentForInstallAppRequest(installAppVersionRequest) if err != nil { impl.logger.Errorw("error in getting environment for install helm chart", "envId", installAppVersionRequest.EnvironmentId, "err", err) return nil, err @@ -492,7 +493,7 @@ func (impl *AppStoreDeploymentDBServiceImpl) validateAndGetOverrideDeploymentApp return overrideDeploymentType, nil } -func (impl *AppStoreDeploymentDBServiceImpl) getEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*clutserBean.EnvironmentBean, error) { +func (impl *AppStoreDeploymentDBServiceImpl) GetEnvironmentForInstallAppRequest(installAppVersionRequest *appStoreBean.InstallAppVersionDTO) (*clutserBean.EnvironmentBean, error) { // create env if env not exists for clusterId and namespace for hyperion mode if globalUtil.IsHelmApp(getAppInstallationMode(installAppVersionRequest.AppOfferingMode)) { From 767e89097b0f4bb47d669fae4efa98fac7e16302 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Wed, 28 Feb 2024 14:32:22 +0530 Subject: [PATCH 70/83] wiring changed --- Wire.go | 3 +++ api/appStore/deployment/wire_appStoreDeployment.go | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Wire.go b/Wire.go index f6e291a2b0..5f9092bae6 100644 --- a/Wire.go +++ b/Wire.go @@ -25,6 +25,7 @@ import ( pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/commonWireset" "github.com/devtron-labs/devtron/internals/util" + appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/sql" "github.com/google/wire" ) @@ -43,6 +44,8 @@ func InitializeApp() (*App, error) { cloudProviderIdentifier.NewProviderIdentifierServiceImpl, wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)), commonWireset.CommonWireSet, + appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, + wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), ) return &App{}, nil } diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 57cce85f84..62186e5ba6 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -5,7 +5,6 @@ import ( "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/google/wire" ) @@ -13,8 +12,6 @@ var AppStoreDeploymentWireSet = wire.NewSet( //util.GetDeploymentServiceTypeConfig, repository.NewClusterInstalledAppsRepositoryImpl, wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), - appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, - wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), EAMode.NewEAModeDeploymentServiceImpl, wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), service.NewAppStoreDeploymentServiceImpl, From 02dda7271e854ee59a09e768f6193c4428baadfa Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Wed, 28 Feb 2024 15:44:26 +0530 Subject: [PATCH 71/83] wiring changed --- Wire.go | 3 +++ api/appStore/deployment/wire_appStoreDeployment.go | 2 -- cmd/external-app/wire.go | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Wire.go b/Wire.go index 5f9092bae6..3337d9768a 100644 --- a/Wire.go +++ b/Wire.go @@ -25,6 +25,7 @@ import ( pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/commonWireset" "github.com/devtron-labs/devtron/internals/util" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/sql" "github.com/google/wire" @@ -46,6 +47,8 @@ func InitializeApp() (*App, error) { commonWireset.CommonWireSet, appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), + EAMode.NewEAModeDeploymentServiceImpl, + wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), ) return &App{}, nil } diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 62186e5ba6..141667e048 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -12,8 +12,6 @@ var AppStoreDeploymentWireSet = wire.NewSet( //util.GetDeploymentServiceTypeConfig, repository.NewClusterInstalledAppsRepositoryImpl, wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), - EAMode.NewEAModeDeploymentServiceImpl, - wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), service.NewAppStoreDeploymentDBServiceImpl, diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index e3a75179c7..8581c85ff5 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -157,6 +157,9 @@ func InitializeApp() (*App, error) { wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), // needed for enforcer util ends + EAMode.NewEAModeDeploymentServiceImpl, + wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), + // binding gitops to helm (for hyperion) wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), From ceb637839112d8e38ae4f8d858048bbf794793c1 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 11:52:18 +0530 Subject: [PATCH 72/83] common wire set added for external app --- cmd/external-app/commonWireset.go | 216 ++++++++++++++++++++++++++++++ cmd/external-app/wire.go | 204 +--------------------------- 2 files changed, 217 insertions(+), 203 deletions(-) create mode 100644 cmd/external-app/commonWireset.go diff --git a/cmd/external-app/commonWireset.go b/cmd/external-app/commonWireset.go new file mode 100644 index 0000000000..bfacb26675 --- /dev/null +++ b/cmd/external-app/commonWireset.go @@ -0,0 +1,216 @@ +package main + +import ( + "github.com/devtron-labs/authenticator/middleware" + cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" + util4 "github.com/devtron-labs/common-lib/utils/k8s" + "github.com/devtron-labs/devtron/api/apiToken" + "github.com/devtron-labs/devtron/api/appStore/chartProvider" + appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" + appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover" + appStoreValues "github.com/devtron-labs/devtron/api/appStore/values" + "github.com/devtron-labs/devtron/api/argoApplication" + "github.com/devtron-labs/devtron/api/auth/sso" + "github.com/devtron-labs/devtron/api/auth/user" + "github.com/devtron-labs/devtron/api/chartRepo" + "github.com/devtron-labs/devtron/api/cluster" + "github.com/devtron-labs/devtron/api/connector" + "github.com/devtron-labs/devtron/api/dashboardEvent" + "github.com/devtron-labs/devtron/api/externalLink" + client "github.com/devtron-labs/devtron/api/helm-app" + "github.com/devtron-labs/devtron/api/k8s" + "github.com/devtron-labs/devtron/api/module" + "github.com/devtron-labs/devtron/api/restHandler" + "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" + appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" + "github.com/devtron-labs/devtron/api/router" + app3 "github.com/devtron-labs/devtron/api/router/app" + appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" + "github.com/devtron-labs/devtron/api/router/app/appList" + "github.com/devtron-labs/devtron/api/server" + "github.com/devtron-labs/devtron/api/team" + "github.com/devtron-labs/devtron/api/terminal" + webhookHelm "github.com/devtron-labs/devtron/api/webhook/helm" + "github.com/devtron-labs/devtron/client/argocdServer/session" + "github.com/devtron-labs/devtron/client/dashboard" + "github.com/devtron-labs/devtron/client/telemetry" + "github.com/devtron-labs/devtron/internals/sql/repository" + app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" + "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" + dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" + "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" + security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" + "github.com/devtron-labs/devtron/pkg/app" + repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" + "github.com/devtron-labs/devtron/pkg/attributes" + delete2 "github.com/devtron-labs/devtron/pkg/delete" + "github.com/devtron-labs/devtron/pkg/deployment/gitOps" + "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" + "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" + repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + "github.com/devtron-labs/devtron/pkg/pipeline" + "github.com/devtron-labs/devtron/pkg/sql" + util2 "github.com/devtron-labs/devtron/pkg/util" + util3 "github.com/devtron-labs/devtron/util" + "github.com/devtron-labs/devtron/util/argo" + "github.com/devtron-labs/devtron/util/cron" + "github.com/devtron-labs/devtron/util/rbac" + "github.com/google/wire" +) + +var CommonWireSet = wire.NewSet( + user.SelfRegistrationWireSet, + + sql.PgSqlWireSet, + user.UserWireSet, + sso.SsoConfigWireSet, + AuthWireSet, + util4.NewK8sUtil, + externalLink.ExternalLinkWireSet, + team.TeamsWireSet, + cluster.ClusterWireSetEa, + dashboard.DashboardWireSet, + client.HelmAppWireSet, + k8s.K8sApplicationWireSet, + chartRepo.ChartRepositoryWireSet, + appStoreDiscover.AppStoreDiscoverWireSet, + chartProvider.AppStoreChartProviderWireSet, + appStoreValues.AppStoreValuesWireSet, + util3.GetEnvironmentVariables, + appStoreDeployment.AppStoreDeploymentWireSet, + server.ServerWireSet, + module.ModuleWireSet, + apiToken.ApiTokenWireSet, + webhookHelm.WebhookHelmWireSet, + terminal.TerminalWireSet, + gitOps.GitOpsEAWireSet, + providerConfig.DeploymentProviderConfigWireSet, + argoApplication.ArgoApplicationWireSet, + //NewApp, + //NewMuxRouter, + //util.NewHttpClient, + //util.NewSugardLogger, + //util.IntValidator, + util2.GetACDAuthConfig, + telemetry.NewPosthogClient, + delete2.NewDeleteServiceImpl, + + pipelineConfig.NewMaterialRepositoryImpl, + wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), + // appStatus + appStatus.NewAppStatusRepositoryImpl, + wire.Bind(new(appStatus.AppStatusRepository), new(*appStatus.AppStatusRepositoryImpl)), + // appStatus ends + rbac.NewEnforcerUtilImpl, + wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), + + appInfo2.NewAppInfoRouterImpl, + wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), + appInfo.NewAppInfoRestHandlerImpl, + wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), + + appList.NewAppFilteringRouterImpl, + wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), + appList2.NewAppFilteringRestHandlerImpl, + wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), + + app3.NewAppRouterEAModeImpl, + wire.Bind(new(app3.AppRouterEAMode), new(*app3.AppRouterEAModeImpl)), + + app.NewAppCrudOperationServiceImpl, + wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), + pipelineConfig.NewAppLabelRepositoryImpl, + wire.Bind(new(pipelineConfig.AppLabelRepository), new(*pipelineConfig.AppLabelRepositoryImpl)), + // acd session client bind with authenticator login + wire.Bind(new(session.ServiceClient), new(*middleware.LoginService)), + connector.NewPumpImpl, + wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), + cloudProviderIdentifier.NewProviderIdentifierServiceImpl, + wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)), + + telemetry.NewTelemetryEventClientImpl, + wire.Bind(new(telemetry.TelemetryEventClient), new(*telemetry.TelemetryEventClientImpl)), + + wire.Bind(new(delete2.DeleteService), new(*delete2.DeleteServiceImpl)), + + // needed for enforcer util + pipelineConfig.NewPipelineRepositoryImpl, + wire.Bind(new(pipelineConfig.PipelineRepository), new(*pipelineConfig.PipelineRepositoryImpl)), + app2.NewAppRepositoryImpl, + wire.Bind(new(app2.AppRepository), new(*app2.AppRepositoryImpl)), + router.NewAttributesRouterImpl, + wire.Bind(new(router.AttributesRouter), new(*router.AttributesRouterImpl)), + restHandler.NewAttributesRestHandlerImpl, + wire.Bind(new(restHandler.AttributesRestHandler), new(*restHandler.AttributesRestHandlerImpl)), + attributes.NewAttributesServiceImpl, + wire.Bind(new(attributes.AttributesService), new(*attributes.AttributesServiceImpl)), + repository.NewAttributesRepositoryImpl, + wire.Bind(new(repository.AttributesRepository), new(*repository.AttributesRepositoryImpl)), + pipelineConfig.NewCiPipelineRepositoryImpl, + wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), + // needed for enforcer util ends + + EAMode.NewEAModeDeploymentServiceImpl, + wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), + + // binding gitops to helm (for hyperion) + wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), + + router.NewTelemetryRouterImpl, + wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), + restHandler.NewTelemetryRestHandlerImpl, + wire.Bind(new(restHandler.TelemetryRestHandler), new(*restHandler.TelemetryRestHandlerImpl)), + + //needed for sending events + dashboardEvent.NewDashboardTelemetryRestHandlerImpl, + wire.Bind(new(dashboardEvent.DashboardTelemetryRestHandler), new(*dashboardEvent.DashboardTelemetryRestHandlerImpl)), + dashboardEvent.NewDashboardTelemetryRouterImpl, + wire.Bind(new(dashboardEvent.DashboardTelemetryRouter), + new(*dashboardEvent.DashboardTelemetryRouterImpl)), + + //binding argoUserService to helm via dummy implementation(HelmUserServiceImpl) + argo.NewHelmUserServiceImpl, + wire.Bind(new(argo.ArgoUserService), new(*argo.HelmUserServiceImpl)), + + router.NewUserAttributesRouterImpl, + wire.Bind(new(router.UserAttributesRouter), new(*router.UserAttributesRouterImpl)), + restHandler.NewUserAttributesRestHandlerImpl, + wire.Bind(new(restHandler.UserAttributesRestHandler), new(*restHandler.UserAttributesRestHandlerImpl)), + attributes.NewUserAttributesServiceImpl, + wire.Bind(new(attributes.UserAttributesService), new(*attributes.UserAttributesServiceImpl)), + repository.NewUserAttributesRepositoryImpl, + wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)), + + repository2.NewK8sResourceHistoryRepositoryImpl, + wire.Bind(new(repository2.K8sResourceHistoryRepository), new(*repository2.K8sResourceHistoryRepositoryImpl)), + + kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl, + wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)), + + security2.NewScanToolMetadataRepositoryImpl, + wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), + + // start: docker registry wire set injection + router.NewDockerRegRouterImpl, + wire.Bind(new(router.DockerRegRouter), new(*router.DockerRegRouterImpl)), + restHandler.NewDockerRegRestHandlerImpl, + wire.Bind(new(restHandler.DockerRegRestHandler), new(*restHandler.DockerRegRestHandlerImpl)), + pipeline.NewDockerRegistryConfigImpl, + wire.Bind(new(pipeline.DockerRegistryConfig), new(*pipeline.DockerRegistryConfigImpl)), + dockerRegistryRepository.NewDockerArtifactStoreRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.DockerArtifactStoreRepository), new(*dockerRegistryRepository.DockerArtifactStoreRepositoryImpl)), + dockerRegistryRepository.NewDockerRegistryIpsConfigRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.DockerRegistryIpsConfigRepository), new(*dockerRegistryRepository.DockerRegistryIpsConfigRepositoryImpl)), + dockerRegistryRepository.NewOCIRegistryConfigRepositoryImpl, + wire.Bind(new(dockerRegistryRepository.OCIRegistryConfigRepository), new(*dockerRegistryRepository.OCIRegistryConfigRepositoryImpl)), + + // chart group repository layer wire injection started + repository4.NewChartGroupDeploymentRepositoryImpl, + wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)), + // chart group repository layer wire injection ended + + // end: docker registry wire set injection + cron.NewCronLoggerImpl, +) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 8581c85ff5..85de92c816 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -4,220 +4,18 @@ package main import ( - "github.com/devtron-labs/authenticator/middleware" - cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" - util4 "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/api/apiToken" - chartProvider "github.com/devtron-labs/devtron/api/appStore/chartProvider" - appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment" - appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover" - appStoreValues "github.com/devtron-labs/devtron/api/appStore/values" - "github.com/devtron-labs/devtron/api/argoApplication" - "github.com/devtron-labs/devtron/api/auth/sso" - "github.com/devtron-labs/devtron/api/auth/user" - chartRepo "github.com/devtron-labs/devtron/api/chartRepo" - "github.com/devtron-labs/devtron/api/cluster" - "github.com/devtron-labs/devtron/api/connector" - "github.com/devtron-labs/devtron/api/dashboardEvent" - "github.com/devtron-labs/devtron/api/externalLink" - client "github.com/devtron-labs/devtron/api/helm-app" - "github.com/devtron-labs/devtron/api/k8s" - "github.com/devtron-labs/devtron/api/module" - "github.com/devtron-labs/devtron/api/restHandler" - "github.com/devtron-labs/devtron/api/restHandler/app/appInfo" - appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList" - "github.com/devtron-labs/devtron/api/router" - app3 "github.com/devtron-labs/devtron/api/router/app" - appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo" - "github.com/devtron-labs/devtron/api/router/app/appList" - "github.com/devtron-labs/devtron/api/server" - "github.com/devtron-labs/devtron/api/team" - "github.com/devtron-labs/devtron/api/terminal" - webhookHelm "github.com/devtron-labs/devtron/api/webhook/helm" - "github.com/devtron-labs/devtron/client/argocdServer/session" - "github.com/devtron-labs/devtron/client/dashboard" - "github.com/devtron-labs/devtron/client/telemetry" - "github.com/devtron-labs/devtron/internals/sql/repository" - app2 "github.com/devtron-labs/devtron/internals/sql/repository/app" - "github.com/devtron-labs/devtron/internals/sql/repository/appStatus" - dockerRegistryRepository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" - "github.com/devtron-labs/devtron/internals/sql/repository/pipelineConfig" - security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/internals/util" - "github.com/devtron-labs/devtron/pkg/app" - repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" - "github.com/devtron-labs/devtron/pkg/attributes" - delete2 "github.com/devtron-labs/devtron/pkg/delete" - "github.com/devtron-labs/devtron/pkg/deployment/gitOps" - "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" - "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository2 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" - "github.com/devtron-labs/devtron/pkg/pipeline" - "github.com/devtron-labs/devtron/pkg/sql" - util2 "github.com/devtron-labs/devtron/pkg/util" - util3 "github.com/devtron-labs/devtron/util" - "github.com/devtron-labs/devtron/util/argo" - "github.com/devtron-labs/devtron/util/cron" - "github.com/devtron-labs/devtron/util/rbac" "github.com/google/wire" ) func InitializeApp() (*App, error) { wire.Build( - user.SelfRegistrationWireSet, - - sql.PgSqlWireSet, - user.UserWireSet, - sso.SsoConfigWireSet, - AuthWireSet, - util4.NewK8sUtil, - externalLink.ExternalLinkWireSet, - team.TeamsWireSet, - cluster.ClusterWireSetEa, - dashboard.DashboardWireSet, - client.HelmAppWireSet, - k8s.K8sApplicationWireSet, - chartRepo.ChartRepositoryWireSet, - appStoreDiscover.AppStoreDiscoverWireSet, - chartProvider.AppStoreChartProviderWireSet, - appStoreValues.AppStoreValuesWireSet, - util3.GetEnvironmentVariables, - appStoreDeployment.AppStoreDeploymentWireSet, - server.ServerWireSet, - module.ModuleWireSet, - apiToken.ApiTokenWireSet, - webhookHelm.WebhookHelmWireSet, - terminal.TerminalWireSet, - gitOps.GitOpsEAWireSet, - providerConfig.DeploymentProviderConfigWireSet, - argoApplication.ArgoApplicationWireSet, + CommonWireSet, NewApp, NewMuxRouter, util.NewHttpClient, util.NewSugardLogger, util.IntValidator, - util2.GetACDAuthConfig, - telemetry.NewPosthogClient, - delete2.NewDeleteServiceImpl, - - pipelineConfig.NewMaterialRepositoryImpl, - wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)), - // appStatus - appStatus.NewAppStatusRepositoryImpl, - wire.Bind(new(appStatus.AppStatusRepository), new(*appStatus.AppStatusRepositoryImpl)), - // appStatus ends - rbac.NewEnforcerUtilImpl, - wire.Bind(new(rbac.EnforcerUtil), new(*rbac.EnforcerUtilImpl)), - - appInfo2.NewAppInfoRouterImpl, - wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)), - appInfo.NewAppInfoRestHandlerImpl, - wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)), - - appList.NewAppFilteringRouterImpl, - wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)), - appList2.NewAppFilteringRestHandlerImpl, - wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)), - - app3.NewAppRouterEAModeImpl, - wire.Bind(new(app3.AppRouterEAMode), new(*app3.AppRouterEAModeImpl)), - - app.NewAppCrudOperationServiceImpl, - wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)), - pipelineConfig.NewAppLabelRepositoryImpl, - wire.Bind(new(pipelineConfig.AppLabelRepository), new(*pipelineConfig.AppLabelRepositoryImpl)), - // acd session client bind with authenticator login - wire.Bind(new(session.ServiceClient), new(*middleware.LoginService)), - connector.NewPumpImpl, - wire.Bind(new(connector.Pump), new(*connector.PumpImpl)), - cloudProviderIdentifier.NewProviderIdentifierServiceImpl, - wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)), - - telemetry.NewTelemetryEventClientImpl, - wire.Bind(new(telemetry.TelemetryEventClient), new(*telemetry.TelemetryEventClientImpl)), - - wire.Bind(new(delete2.DeleteService), new(*delete2.DeleteServiceImpl)), - - // needed for enforcer util - pipelineConfig.NewPipelineRepositoryImpl, - wire.Bind(new(pipelineConfig.PipelineRepository), new(*pipelineConfig.PipelineRepositoryImpl)), - app2.NewAppRepositoryImpl, - wire.Bind(new(app2.AppRepository), new(*app2.AppRepositoryImpl)), - router.NewAttributesRouterImpl, - wire.Bind(new(router.AttributesRouter), new(*router.AttributesRouterImpl)), - restHandler.NewAttributesRestHandlerImpl, - wire.Bind(new(restHandler.AttributesRestHandler), new(*restHandler.AttributesRestHandlerImpl)), - attributes.NewAttributesServiceImpl, - wire.Bind(new(attributes.AttributesService), new(*attributes.AttributesServiceImpl)), - repository.NewAttributesRepositoryImpl, - wire.Bind(new(repository.AttributesRepository), new(*repository.AttributesRepositoryImpl)), - pipelineConfig.NewCiPipelineRepositoryImpl, - wire.Bind(new(pipelineConfig.CiPipelineRepository), new(*pipelineConfig.CiPipelineRepositoryImpl)), - // needed for enforcer util ends - - EAMode.NewEAModeDeploymentServiceImpl, - wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), - - // binding gitops to helm (for hyperion) - wire.Bind(new(deployment.FullModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), - - router.NewTelemetryRouterImpl, - wire.Bind(new(router.TelemetryRouter), new(*router.TelemetryRouterImpl)), - restHandler.NewTelemetryRestHandlerImpl, - wire.Bind(new(restHandler.TelemetryRestHandler), new(*restHandler.TelemetryRestHandlerImpl)), - - //needed for sending events - dashboardEvent.NewDashboardTelemetryRestHandlerImpl, - wire.Bind(new(dashboardEvent.DashboardTelemetryRestHandler), new(*dashboardEvent.DashboardTelemetryRestHandlerImpl)), - dashboardEvent.NewDashboardTelemetryRouterImpl, - wire.Bind(new(dashboardEvent.DashboardTelemetryRouter), - new(*dashboardEvent.DashboardTelemetryRouterImpl)), - - //binding argoUserService to helm via dummy implementation(HelmUserServiceImpl) - argo.NewHelmUserServiceImpl, - wire.Bind(new(argo.ArgoUserService), new(*argo.HelmUserServiceImpl)), - - router.NewUserAttributesRouterImpl, - wire.Bind(new(router.UserAttributesRouter), new(*router.UserAttributesRouterImpl)), - restHandler.NewUserAttributesRestHandlerImpl, - wire.Bind(new(restHandler.UserAttributesRestHandler), new(*restHandler.UserAttributesRestHandlerImpl)), - attributes.NewUserAttributesServiceImpl, - wire.Bind(new(attributes.UserAttributesService), new(*attributes.UserAttributesServiceImpl)), - repository.NewUserAttributesRepositoryImpl, - wire.Bind(new(repository.UserAttributesRepository), new(*repository.UserAttributesRepositoryImpl)), - - repository2.NewK8sResourceHistoryRepositoryImpl, - wire.Bind(new(repository2.K8sResourceHistoryRepository), new(*repository2.K8sResourceHistoryRepositoryImpl)), - - kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl, - wire.Bind(new(kubernetesResourceAuditLogs.K8sResourceHistoryService), new(*kubernetesResourceAuditLogs.K8sResourceHistoryServiceImpl)), - - security2.NewScanToolMetadataRepositoryImpl, - wire.Bind(new(security2.ScanToolMetadataRepository), new(*security2.ScanToolMetadataRepositoryImpl)), - - // start: docker registry wire set injection - router.NewDockerRegRouterImpl, - wire.Bind(new(router.DockerRegRouter), new(*router.DockerRegRouterImpl)), - restHandler.NewDockerRegRestHandlerImpl, - wire.Bind(new(restHandler.DockerRegRestHandler), new(*restHandler.DockerRegRestHandlerImpl)), - pipeline.NewDockerRegistryConfigImpl, - wire.Bind(new(pipeline.DockerRegistryConfig), new(*pipeline.DockerRegistryConfigImpl)), - dockerRegistryRepository.NewDockerArtifactStoreRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.DockerArtifactStoreRepository), new(*dockerRegistryRepository.DockerArtifactStoreRepositoryImpl)), - dockerRegistryRepository.NewDockerRegistryIpsConfigRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.DockerRegistryIpsConfigRepository), new(*dockerRegistryRepository.DockerRegistryIpsConfigRepositoryImpl)), - dockerRegistryRepository.NewOCIRegistryConfigRepositoryImpl, - wire.Bind(new(dockerRegistryRepository.OCIRegistryConfigRepository), new(*dockerRegistryRepository.OCIRegistryConfigRepositoryImpl)), - - // chart group repository layer wire injection started - repository4.NewChartGroupDeploymentRepositoryImpl, - wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)), - // chart group repository layer wire injection ended - - // end: docker registry wire set injection - cron.NewCronLoggerImpl, ) return &App{}, nil } From 4560846cdbe013caa378c5de593270e3abc0632c Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 12:01:14 +0530 Subject: [PATCH 73/83] common wire set added for external app --- cmd/external-app/{ => commonWireset}/authWire.go | 2 +- cmd/external-app/{ => commonWireset}/commonWireset.go | 2 +- cmd/external-app/wire.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) rename cmd/external-app/{ => commonWireset}/authWire.go (95%) rename cmd/external-app/{ => commonWireset}/commonWireset.go (99%) diff --git a/cmd/external-app/authWire.go b/cmd/external-app/commonWireset/authWire.go similarity index 95% rename from cmd/external-app/authWire.go rename to cmd/external-app/commonWireset/authWire.go index c5bf9c7f7b..e36358cdb1 100644 --- a/cmd/external-app/authWire.go +++ b/cmd/external-app/commonWireset/authWire.go @@ -1,4 +1,4 @@ -package main +package commonWireset import ( "github.com/devtron-labs/authenticator/client" diff --git a/cmd/external-app/commonWireset.go b/cmd/external-app/commonWireset/commonWireset.go similarity index 99% rename from cmd/external-app/commonWireset.go rename to cmd/external-app/commonWireset/commonWireset.go index bfacb26675..8ca0cdec6f 100644 --- a/cmd/external-app/commonWireset.go +++ b/cmd/external-app/commonWireset/commonWireset.go @@ -1,4 +1,4 @@ -package main +package commonWireset import ( "github.com/devtron-labs/authenticator/middleware" diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 85de92c816..6c7296a005 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -4,13 +4,14 @@ package main import ( + "github.com/devtron-labs/devtron/cmd/external-app/commonWireset" "github.com/devtron-labs/devtron/internals/util" "github.com/google/wire" ) func InitializeApp() (*App, error) { wire.Build( - CommonWireSet, + commonWireset.CommonWireSet, NewApp, NewMuxRouter, util.NewHttpClient, From c547e1f58a12f0f80a8efc1050ca254b5fa0338f Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 13:15:53 +0530 Subject: [PATCH 74/83] common wire set added for external app --- api/appStore/deployment/wire_appStoreDeployment.go | 4 ++-- cmd/external-app/commonWireset/commonWireset.go | 3 +++ commonWireset/commonWireset.go | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 141667e048..705bc3f906 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -14,8 +14,8 @@ var AppStoreDeploymentWireSet = wire.NewSet( wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), - service.NewAppStoreDeploymentDBServiceImpl, - wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), + //service.NewAppStoreDeploymentDBServiceImpl, + //wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), NewAppStoreDeploymentRestHandlerImpl, wire.Bind(new(AppStoreDeploymentRestHandler), new(*AppStoreDeploymentRestHandlerImpl)), NewAppStoreDeploymentRouterImpl, diff --git a/cmd/external-app/commonWireset/commonWireset.go b/cmd/external-app/commonWireset/commonWireset.go index 8ca0cdec6f..7c720fec45 100644 --- a/cmd/external-app/commonWireset/commonWireset.go +++ b/cmd/external-app/commonWireset/commonWireset.go @@ -42,6 +42,7 @@ import ( security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/app" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/attributes" @@ -80,6 +81,8 @@ var CommonWireSet = wire.NewSet( appStoreValues.AppStoreValuesWireSet, util3.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), server.ServerWireSet, module.ModuleWireSet, apiToken.ApiTokenWireSet, diff --git a/commonWireset/commonWireset.go b/commonWireset/commonWireset.go index ca907975a9..d968b11e75 100644 --- a/commonWireset/commonWireset.go +++ b/commonWireset/commonWireset.go @@ -85,6 +85,7 @@ import ( "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange" @@ -157,6 +158,8 @@ var CommonWireSet = wire.NewSet( appStoreValues.AppStoreValuesWireSet, util2.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), server.ServerWireSet, module.ModuleWireSet, apiToken.ApiTokenWireSet, From 6e1522210e3e999b28433bb92ea72003f4d3d16f Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 13:20:09 +0530 Subject: [PATCH 75/83] common wire set added for external app --- Wire.go | 3 +++ cmd/external-app/commonWireset/commonWireset.go | 3 --- cmd/external-app/wire.go | 3 +++ commonWireset/commonWireset.go | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Wire.go b/Wire.go index 3337d9768a..12bd17cc14 100644 --- a/Wire.go +++ b/Wire.go @@ -25,6 +25,7 @@ import ( pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" "github.com/devtron-labs/devtron/commonWireset" "github.com/devtron-labs/devtron/internals/util" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/sql" @@ -49,6 +50,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), EAMode.NewEAModeDeploymentServiceImpl, wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), ) return &App{}, nil } diff --git a/cmd/external-app/commonWireset/commonWireset.go b/cmd/external-app/commonWireset/commonWireset.go index 7c720fec45..8ca0cdec6f 100644 --- a/cmd/external-app/commonWireset/commonWireset.go +++ b/cmd/external-app/commonWireset/commonWireset.go @@ -42,7 +42,6 @@ import ( security2 "github.com/devtron-labs/devtron/internals/sql/repository/security" "github.com/devtron-labs/devtron/pkg/app" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/attributes" @@ -81,8 +80,6 @@ var CommonWireSet = wire.NewSet( appStoreValues.AppStoreValuesWireSet, util3.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, - service.NewAppStoreDeploymentDBServiceImpl, - wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), server.ServerWireSet, module.ModuleWireSet, apiToken.ApiTokenWireSet, diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index 6c7296a005..cc35ebf6d0 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -6,6 +6,7 @@ package main import ( "github.com/devtron-labs/devtron/cmd/external-app/commonWireset" "github.com/devtron-labs/devtron/internals/util" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/google/wire" ) @@ -17,6 +18,8 @@ func InitializeApp() (*App, error) { util.NewHttpClient, util.NewSugardLogger, util.IntValidator, + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), ) return &App{}, nil } diff --git a/commonWireset/commonWireset.go b/commonWireset/commonWireset.go index d968b11e75..ca907975a9 100644 --- a/commonWireset/commonWireset.go +++ b/commonWireset/commonWireset.go @@ -85,7 +85,6 @@ import ( "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/chartGroup" repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" deployment3 "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deployment" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange" @@ -158,8 +157,6 @@ var CommonWireSet = wire.NewSet( appStoreValues.AppStoreValuesWireSet, util2.GetEnvironmentVariables, appStoreDeployment.AppStoreDeploymentWireSet, - service.NewAppStoreDeploymentDBServiceImpl, - wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), server.ServerWireSet, module.ModuleWireSet, apiToken.ApiTokenWireSet, From 46ff51df47c8d3a71e98eade95d0e0e2350b7573 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 13:29:03 +0530 Subject: [PATCH 76/83] common wire set added for external app --- Wire.go | 2 ++ api/appStore/deployment/wire_appStoreDeployment.go | 5 ++--- cmd/external-app/wire.go | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Wire.go b/Wire.go index 12bd17cc14..1c7ce7d336 100644 --- a/Wire.go +++ b/Wire.go @@ -52,6 +52,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), service.NewAppStoreDeploymentDBServiceImpl, wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), + service.NewAppStoreDeploymentServiceImpl, + wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), ) return &App{}, nil } diff --git a/api/appStore/deployment/wire_appStoreDeployment.go b/api/appStore/deployment/wire_appStoreDeployment.go index 705bc3f906..65a50e50b5 100644 --- a/api/appStore/deployment/wire_appStoreDeployment.go +++ b/api/appStore/deployment/wire_appStoreDeployment.go @@ -3,7 +3,6 @@ package appStoreDeployment import ( "github.com/devtron-labs/devtron/client/argocdServer" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" "github.com/google/wire" ) @@ -12,8 +11,8 @@ var AppStoreDeploymentWireSet = wire.NewSet( //util.GetDeploymentServiceTypeConfig, repository.NewClusterInstalledAppsRepositoryImpl, wire.Bind(new(repository.ClusterInstalledAppsRepository), new(*repository.ClusterInstalledAppsRepositoryImpl)), - service.NewAppStoreDeploymentServiceImpl, - wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), + //service.NewAppStoreDeploymentServiceImpl, + //wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), //service.NewAppStoreDeploymentDBServiceImpl, //wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), NewAppStoreDeploymentRestHandlerImpl, diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index cc35ebf6d0..f77334aca6 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -20,6 +20,8 @@ func InitializeApp() (*App, error) { util.IntValidator, service.NewAppStoreDeploymentDBServiceImpl, wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), + service.NewAppStoreDeploymentServiceImpl, + wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), ) return &App{}, nil } From b21d7f5b72c6d9a5108d50a467b927096f5852c8 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 20:28:40 +0530 Subject: [PATCH 77/83] code review changes --- Wire.go | 4 ++++ .../service/AppStoreDeploymentDBService.go | 8 ++++++- .../service/AppStoreDeploymentService.go | 5 ++++- .../installedApp/service/AppStoreValidator.go | 21 +++++++++++++++++++ .../service/SoftDeletePostProcessor.go | 20 ++++++++++++++++++ wire_gen.go | 6 ++++-- 6 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 pkg/appStore/installedApp/service/AppStoreValidator.go create mode 100644 pkg/appStore/installedApp/service/SoftDeletePostProcessor.go diff --git a/Wire.go b/Wire.go index 1c7ce7d336..b5427373d9 100644 --- a/Wire.go +++ b/Wire.go @@ -54,6 +54,10 @@ func InitializeApp() (*App, error) { wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), + service.NewSoftDeletePostProcessorImpl, + wire.Bind(new(service.SoftDeletePostProcessor), new(*service.SoftDeletePostProcessorImpl)), + service.NewAppAppStoreValidatorImpl, + wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), ) return &App{}, nil } diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go index 1e44918562..76f59f3751 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentDBService.go @@ -63,6 +63,7 @@ type AppStoreDeploymentDBServiceImpl struct { deploymentTypeConfig *globalUtil.DeploymentServiceTypeConfig gitOpsConfigReadService config.GitOpsConfigReadService deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService + AppStoreValidator AppStoreValidator } func NewAppStoreDeploymentDBServiceImpl(logger *zap.SugaredLogger, @@ -74,7 +75,7 @@ func NewAppStoreDeploymentDBServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, envVariables *globalUtil.EnvironmentVariables, gitOpsConfigReadService config.GitOpsConfigReadService, - deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService) *AppStoreDeploymentDBServiceImpl { + deploymentTypeOverrideService providerConfig.DeploymentTypeOverrideService, AppStoreValidator AppStoreValidator) *AppStoreDeploymentDBServiceImpl { return &AppStoreDeploymentDBServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -86,6 +87,7 @@ func NewAppStoreDeploymentDBServiceImpl(logger *zap.SugaredLogger, deploymentTypeConfig: envVariables.DeploymentServiceTypeConfig, gitOpsConfigReadService: gitOpsConfigReadService, deploymentTypeOverrideService: deploymentTypeOverrideService, + AppStoreValidator: AppStoreValidator, } } @@ -95,6 +97,10 @@ func (impl *AppStoreDeploymentDBServiceImpl) AppStoreDeployOperationDB(installAp impl.logger.Errorw("error in getting environment for install helm chart", "envId", installAppVersionRequest.EnvironmentId, "err", err) return nil, err } + err = impl.AppStoreValidator.Validate(installAppVersionRequest, environment) + if err != nil { + return nil, err + } // setting additional env data required in appStoreBean.InstallAppVersionDTO adapter.UpdateAdditionalEnvDetails(installAppVersionRequest, environment) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 133147c0df..8d966a3a17 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -81,6 +81,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *util2.DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService + SoftDeletePostProcessor SoftDeletePostProcessor } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, @@ -97,7 +98,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, envVariables *util2.EnvironmentVariables, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService) *AppStoreDeploymentServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, SoftDeletePostProcessor SoftDeletePostProcessor) *AppStoreDeploymentServiceImpl { return &AppStoreDeploymentServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -114,6 +115,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, deploymentTypeConfig: envVariables.DeploymentServiceTypeConfig, aCDConfig: aCDConfig, gitOpsConfigReadService: gitOpsConfigReadService, + SoftDeletePostProcessor: SoftDeletePostProcessor, } } @@ -258,6 +260,7 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex return nil, err } } + impl.SoftDeletePostProcessor.SoftDeletePostProcessor(app, installAppVersionRequest) err = tx.Commit() if err != nil { impl.logger.Errorw("error in commit db transaction on delete", "err", err) diff --git a/pkg/appStore/installedApp/service/AppStoreValidator.go b/pkg/appStore/installedApp/service/AppStoreValidator.go new file mode 100644 index 0000000000..7c20be8c31 --- /dev/null +++ b/pkg/appStore/installedApp/service/AppStoreValidator.go @@ -0,0 +1,21 @@ +package service + +import ( + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" + bean2 "github.com/devtron-labs/devtron/pkg/cluster/repository/bean" +) + +type AppStoreValidator interface { + Validate(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *bean2.EnvironmentBean) error +} + +type AppStoreValidatorImpl struct { +} + +func NewAppAppStoreValidatorImpl() *AppStoreValidatorImpl { + return &AppStoreValidatorImpl{} +} + +func (impl *AppStoreValidatorImpl) Validate(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, environment *bean2.EnvironmentBean) error { + return nil +} diff --git a/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go b/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go new file mode 100644 index 0000000000..5cbab32e1c --- /dev/null +++ b/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go @@ -0,0 +1,20 @@ +package service + +import ( + "github.com/devtron-labs/devtron/internals/sql/repository/app" + appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" +) + +type SoftDeletePostProcessor interface { + SoftDeletePostProcessor(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) +} + +type SoftDeletePostProcessorImpl struct { +} + +func NewSoftDeletePostProcessorImpl() *SoftDeletePostProcessorImpl { + return &SoftDeletePostProcessorImpl{} +} + +func (impl *SoftDeletePostProcessorImpl) SoftDeletePostProcessor(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) { +} diff --git a/wire_gen.go b/wire_gen.go index 57685ef368..35abe102cf 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -632,12 +632,14 @@ func InitializeApp() (*App, error) { return nil, err } installedAppDBServiceImpl := EAMode.NewInstalledAppDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appRepositoryImpl, userServiceImpl, environmentServiceImpl, installedAppVersionHistoryRepositoryImpl) - appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImplExtended, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) + appStoreValidatorImpl := service2.NewAppAppStoreValidatorImpl() + appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImplExtended, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl, appStoreValidatorImpl) chartGroupDeploymentRepositoryImpl := repository15.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl) + softDeletePostProcessorImpl := service2.NewSoftDeletePostProcessorImpl() + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, softDeletePostProcessorImpl) applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, gitOpsConfigReadServiceImpl, cdWorkflowCommonServiceImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) From e97e7161e36c828145e2bb723da05f91ac2d26eb Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 20:30:38 +0530 Subject: [PATCH 78/83] code review changes --- Wire.go | 4 ++-- .../service/AppStoreDeploymentService.go | 6 +++--- .../installedApp/service/SoftDeletePostProcessor.go | 12 ++++++------ wire_gen.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Wire.go b/Wire.go index b5427373d9..fceb59fb7c 100644 --- a/Wire.go +++ b/Wire.go @@ -54,8 +54,8 @@ func InitializeApp() (*App, error) { wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), - service.NewSoftDeletePostProcessorImpl, - wire.Bind(new(service.SoftDeletePostProcessor), new(*service.SoftDeletePostProcessorImpl)), + service.NewDeletePostProcessorImpl, + wire.Bind(new(service.DeletePostProcessor), new(*service.DeletePostProcessorImpl)), service.NewAppAppStoreValidatorImpl, wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), ) diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index 8d966a3a17..ff4a3c907b 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -81,7 +81,7 @@ type AppStoreDeploymentServiceImpl struct { deploymentTypeConfig *util2.DeploymentServiceTypeConfig aCDConfig *argocdServer.ACDConfig gitOpsConfigReadService config.GitOpsConfigReadService - SoftDeletePostProcessor SoftDeletePostProcessor + SoftDeletePostProcessor DeletePostProcessor } func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, @@ -98,7 +98,7 @@ func NewAppStoreDeploymentServiceImpl(logger *zap.SugaredLogger, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, envVariables *util2.EnvironmentVariables, aCDConfig *argocdServer.ACDConfig, - gitOpsConfigReadService config.GitOpsConfigReadService, SoftDeletePostProcessor SoftDeletePostProcessor) *AppStoreDeploymentServiceImpl { + gitOpsConfigReadService config.GitOpsConfigReadService, SoftDeletePostProcessor DeletePostProcessor) *AppStoreDeploymentServiceImpl { return &AppStoreDeploymentServiceImpl{ logger: logger, installedAppRepository: installedAppRepository, @@ -260,7 +260,7 @@ func (impl *AppStoreDeploymentServiceImpl) DeleteInstalledApp(ctx context.Contex return nil, err } } - impl.SoftDeletePostProcessor.SoftDeletePostProcessor(app, installAppVersionRequest) + impl.SoftDeletePostProcessor.Process(app, installAppVersionRequest) err = tx.Commit() if err != nil { impl.logger.Errorw("error in commit db transaction on delete", "err", err) diff --git a/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go b/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go index 5cbab32e1c..171ce72774 100644 --- a/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go +++ b/pkg/appStore/installedApp/service/SoftDeletePostProcessor.go @@ -5,16 +5,16 @@ import ( appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" ) -type SoftDeletePostProcessor interface { - SoftDeletePostProcessor(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) +type DeletePostProcessor interface { + Process(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) } -type SoftDeletePostProcessorImpl struct { +type DeletePostProcessorImpl struct { } -func NewSoftDeletePostProcessorImpl() *SoftDeletePostProcessorImpl { - return &SoftDeletePostProcessorImpl{} +func NewDeletePostProcessorImpl() *DeletePostProcessorImpl { + return &DeletePostProcessorImpl{} } -func (impl *SoftDeletePostProcessorImpl) SoftDeletePostProcessor(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) { +func (impl *DeletePostProcessorImpl) Process(app *app.App, installAppVersionRequest *appStoreBean.InstallAppVersionDTO) { } diff --git a/wire_gen.go b/wire_gen.go index 35abe102cf..111802ae6d 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -638,7 +638,7 @@ func InitializeApp() (*App, error) { eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - softDeletePostProcessorImpl := service2.NewSoftDeletePostProcessorImpl() + softDeletePostProcessorImpl := service2.NewDeletePostProcessorImpl() appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, softDeletePostProcessorImpl) applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, gitOpsConfigReadServiceImpl, cdWorkflowCommonServiceImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) From 1a57caf5defc2ad4a10d5f75b6757ad2764108ec Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Thu, 29 Feb 2024 20:56:59 +0530 Subject: [PATCH 79/83] code review changes --- cmd/external-app/wire.go | 4 ++++ cmd/external-app/wire_gen.go | 6 ++++-- wire_gen.go | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index f77334aca6..aedccfa123 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -22,6 +22,10 @@ func InitializeApp() (*App, error) { wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), service.NewAppStoreDeploymentServiceImpl, wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), + service.NewDeletePostProcessorImpl, + wire.Bind(new(service.DeletePostProcessor), new(*service.DeletePostProcessorImpl)), + service.NewAppAppStoreValidatorImpl, + wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), ) return &App{}, nil } diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index e31b1d6301..c8d9d026c5 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -246,14 +246,16 @@ func InitializeApp() (*App, error) { gitOpsConfigReadServiceImpl := config.NewGitOpsConfigReadServiceImpl(sugaredLogger, gitOpsConfigRepositoryImpl, userServiceImpl, environmentVariables) attributesServiceImpl := attributes.NewAttributesServiceImpl(sugaredLogger, attributesRepositoryImpl) deploymentTypeOverrideServiceImpl := providerConfig.NewDeploymentTypeOverrideServiceImpl(sugaredLogger, environmentVariables, attributesServiceImpl) - appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl) + appStoreValidatorImpl := service2.NewAppAppStoreValidatorImpl() + appStoreDeploymentDBServiceImpl := service2.NewAppStoreDeploymentDBServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, environmentServiceImpl, clusterServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, gitOpsConfigReadServiceImpl, deploymentTypeOverrideServiceImpl, appStoreValidatorImpl) chartGroupDeploymentRepositoryImpl := repository7.NewChartGroupDeploymentRepositoryImpl(db, sugaredLogger) eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) acdConfig, err := argocdServer.GetACDDeploymentConfig() if err != nil { return nil, err } - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl) + deletePostProcessorImpl := service2.NewDeletePostProcessorImpl() + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, eaModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deletePostProcessorImpl) helmAppRestHandlerImpl := client2.NewHelmAppRestHandlerImpl(sugaredLogger, helmAppServiceImpl, enforcerImpl, clusterServiceImpl, enforcerUtilHelmImpl, appStoreDeploymentServiceImpl, installedAppDBServiceImpl, userServiceImpl, attributesServiceImpl, serverEnvConfigServerEnvConfig) helmAppRouterImpl := client2.NewHelmAppRouterImpl(helmAppRestHandlerImpl) argoApplicationServiceImpl := argoApplication.NewArgoApplicationServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, helmUserServiceImpl, helmAppServiceImpl) diff --git a/wire_gen.go b/wire_gen.go index 111802ae6d..c336292642 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -638,8 +638,8 @@ func InitializeApp() (*App, error) { eaModeDeploymentServiceImpl := EAMode.NewEAModeDeploymentServiceImpl(sugaredLogger, helmAppServiceImpl, appStoreApplicationVersionRepositoryImpl, helmAppClientImpl, installedAppRepositoryImpl, ociRegistryConfigRepositoryImpl) appStoreDeploymentCommonServiceImpl := appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl(sugaredLogger, appStoreApplicationVersionRepositoryImpl, chartTemplateServiceImpl) fullModeDeploymentServiceImpl := deployment.NewFullModeDeploymentServiceImpl(sugaredLogger, applicationServiceClientImpl, argoK8sClientImpl, acdAuthConfig, chartGroupDeploymentRepositoryImpl, installedAppRepositoryImpl, installedAppVersionHistoryRepositoryImpl, argoUserServiceImpl, appStoreDeploymentCommonServiceImpl, helmAppServiceImpl, appStatusServiceImpl, pipelineStatusTimelineServiceImpl, userServiceImpl, pipelineStatusTimelineRepositoryImpl, appStoreApplicationVersionRepositoryImpl, argoClientWrapperServiceImpl, acdConfig, gitOperationServiceImpl, gitOpsConfigReadServiceImpl, environmentRepositoryImpl) - softDeletePostProcessorImpl := service2.NewDeletePostProcessorImpl() - appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, softDeletePostProcessorImpl) + deletePostProcessorImpl := service2.NewDeletePostProcessorImpl() + appStoreDeploymentServiceImpl := service2.NewAppStoreDeploymentServiceImpl(sugaredLogger, installedAppRepositoryImpl, installedAppDBServiceImpl, appStoreDeploymentDBServiceImpl, chartGroupDeploymentRepositoryImpl, appStoreApplicationVersionRepositoryImpl, appRepositoryImpl, eaModeDeploymentServiceImpl, fullModeDeploymentServiceImpl, environmentServiceImpl, helmAppServiceImpl, installedAppVersionHistoryRepositoryImpl, environmentVariables, acdConfig, gitOpsConfigReadServiceImpl, deletePostProcessorImpl) applicationStatusHandlerImpl := pubsub.NewApplicationStatusHandlerImpl(sugaredLogger, pubSubClientServiceImpl, appServiceImpl, workflowDagExecutorImpl, installedAppDBExtendedServiceImpl, appStoreDeploymentServiceImpl, pipelineBuilderImpl, pipelineRepositoryImpl, installedAppRepositoryImpl, gitOpsConfigReadServiceImpl, cdWorkflowCommonServiceImpl) roleGroupServiceImpl := user.NewRoleGroupServiceImpl(userAuthRepositoryImpl, sugaredLogger, userRepositoryImpl, roleGroupRepositoryImpl, userCommonServiceImpl) userRestHandlerImpl := user2.NewUserRestHandlerImpl(userServiceImpl, validate, sugaredLogger, enforcerImpl, roleGroupServiceImpl, userCommonServiceImpl) From cc18f25b3cd3684fb7eb321a3a4e98ba25e56535 Mon Sep 17 00:00:00 2001 From: Ash-exp Date: Fri, 1 Mar 2024 12:25:36 +0530 Subject: [PATCH 80/83] updated env var parsing --- util/GlobalConfig.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/GlobalConfig.go b/util/GlobalConfig.go index 95688e0f00..f60429d701 100644 --- a/util/GlobalConfig.go +++ b/util/GlobalConfig.go @@ -28,7 +28,11 @@ type DevtronSecretConfig struct { } func GetEnvironmentVariables() (*EnvironmentVariables, error) { - cfg := &EnvironmentVariables{} + cfg := &EnvironmentVariables{ + GlobalEnvVariables: &GlobalEnvVariables{}, + DevtronSecretConfig: &DevtronSecretConfig{}, + DeploymentServiceTypeConfig: &DeploymentServiceTypeConfig{}, + } err := env.Parse(cfg) if err != nil { return nil, err From be8601f0d35cb6ec1e1e2e7d077ab824537b2739 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Fri, 1 Mar 2024 12:40:02 +0530 Subject: [PATCH 81/83] code review changes - wire set made for app store --- Wire.go | 17 ++--------------- api/appStore/appStoreWireSet.go | 27 +++++++++++++++++++++++++++ cmd/external-app/wire.go | 11 ++--------- 3 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 api/appStore/appStoreWireSet.go diff --git a/Wire.go b/Wire.go index fceb59fb7c..f2ae394a03 100644 --- a/Wire.go +++ b/Wire.go @@ -23,11 +23,9 @@ package main import ( cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" pubsub1 "github.com/devtron-labs/common-lib/pubsub-lib" + "github.com/devtron-labs/devtron/api/appStore" "github.com/devtron-labs/devtron/commonWireset" "github.com/devtron-labs/devtron/internals/util" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" - appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" "github.com/devtron-labs/devtron/pkg/sql" "github.com/google/wire" ) @@ -46,18 +44,7 @@ func InitializeApp() (*App, error) { cloudProviderIdentifier.NewProviderIdentifierServiceImpl, wire.Bind(new(cloudProviderIdentifier.ProviderIdentifierService), new(*cloudProviderIdentifier.ProviderIdentifierServiceImpl)), commonWireset.CommonWireSet, - appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, - wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), - EAMode.NewEAModeDeploymentServiceImpl, - wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), - service.NewAppStoreDeploymentDBServiceImpl, - wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), - service.NewAppStoreDeploymentServiceImpl, - wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), - service.NewDeletePostProcessorImpl, - wire.Bind(new(service.DeletePostProcessor), new(*service.DeletePostProcessorImpl)), - service.NewAppAppStoreValidatorImpl, - wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), + appStore.AppStoreCommonWireSet, ) return &App{}, nil } diff --git a/api/appStore/appStoreWireSet.go b/api/appStore/appStoreWireSet.go new file mode 100644 index 0000000000..3248eef156 --- /dev/null +++ b/api/appStore/appStoreWireSet.go @@ -0,0 +1,27 @@ +package appStore + +import ( + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" + "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode" + appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" + "github.com/google/wire" +) + +var AppStoreCommonWireSetEA = wire.NewSet( + service.NewAppStoreDeploymentDBServiceImpl, + wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), + service.NewAppStoreDeploymentServiceImpl, + wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), + service.NewDeletePostProcessorImpl, + wire.Bind(new(service.DeletePostProcessor), new(*service.DeletePostProcessorImpl)), + service.NewAppAppStoreValidatorImpl, + wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), +) + +var AppStoreCommonWireSet = wire.NewSet( + AppStoreCommonWireSetEA, + appStoreDeploymentCommon.NewAppStoreDeploymentCommonServiceImpl, + wire.Bind(new(appStoreDeploymentCommon.AppStoreDeploymentCommonService), new(*appStoreDeploymentCommon.AppStoreDeploymentCommonServiceImpl)), + EAMode.NewEAModeDeploymentServiceImpl, + wire.Bind(new(EAMode.EAModeDeploymentService), new(*EAMode.EAModeDeploymentServiceImpl)), +) diff --git a/cmd/external-app/wire.go b/cmd/external-app/wire.go index aedccfa123..30c17eda42 100644 --- a/cmd/external-app/wire.go +++ b/cmd/external-app/wire.go @@ -4,9 +4,9 @@ package main import ( + "github.com/devtron-labs/devtron/api/appStore" "github.com/devtron-labs/devtron/cmd/external-app/commonWireset" "github.com/devtron-labs/devtron/internals/util" - "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service" "github.com/google/wire" ) @@ -18,14 +18,7 @@ func InitializeApp() (*App, error) { util.NewHttpClient, util.NewSugardLogger, util.IntValidator, - service.NewAppStoreDeploymentDBServiceImpl, - wire.Bind(new(service.AppStoreDeploymentDBService), new(*service.AppStoreDeploymentDBServiceImpl)), - service.NewAppStoreDeploymentServiceImpl, - wire.Bind(new(service.AppStoreDeploymentService), new(*service.AppStoreDeploymentServiceImpl)), - service.NewDeletePostProcessorImpl, - wire.Bind(new(service.DeletePostProcessor), new(*service.DeletePostProcessorImpl)), - service.NewAppAppStoreValidatorImpl, - wire.Bind(new(service.AppStoreValidator), new(*service.AppStoreValidatorImpl)), + appStore.AppStoreCommonWireSetEA, ) return &App{}, nil } From ea9f24d7af1b42c400dc96abfb04e6c9c13c90d9 Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Fri, 1 Mar 2024 16:02:08 +0530 Subject: [PATCH 82/83] gRPC refactored --- api/helm-app/bean/bean.go | 14 +- api/helm-app/gRPC/applicationClient.go | 87 +- api/helm-app/gRPC/{ => client}/applist.pb.go | 2022 ++++++++++------- api/helm-app/gRPC/{ => client}/applist.proto | 21 + .../gRPC/{ => client}/applist_grpc.pb.go | 151 +- api/helm-app/mocks/HelmAppClient.go | 218 +- api/helm-app/mocks/HelmAppService.go | 2 +- api/helm-app/service/HelmAppService.go | 117 +- .../app/appList/AppListingRestHandler.go | 3 +- client/telemetry/TelemetryEventClient.go | 5 +- .../service/AppStoreDeploymentService.go | 2 +- .../service/EAMode/EAModeDeploymentService.go | 33 +- .../deployment/FullModeDeploymentService.go | 16 +- .../service/FullMode/resource/NotesService.go | 8 +- .../FullMode/resource/ResourceTreeService.go | 7 +- pkg/argoApplication/ArgoApplicationService.go | 12 +- pkg/argoApplication/bean/bean.go | 6 +- .../trigger/devtronApps/TriggerService.go | 15 +- .../DeployementTemplateService.go | 9 +- .../DeployementTemplateService_test.go | 2 +- pkg/k8s/application/k8sApplicationService.go | 4 +- pkg/module/ModuleCronService.go | 22 +- pkg/module/ModuleService.go | 4 +- pkg/pipeline/DockerRegistryConfig.go | 2 +- pkg/pipeline/DockerRegistryConfig_test.go | 2 +- pkg/server/ServerService.go | 4 +- pkg/webhook/helm/WebhookHelmService.go | 2 +- 27 files changed, 1572 insertions(+), 1218 deletions(-) rename api/helm-app/gRPC/{ => client}/applist.pb.go (56%) rename api/helm-app/gRPC/{ => client}/applist.proto (93%) rename api/helm-app/gRPC/{ => client}/applist_grpc.pb.go (81%) diff --git a/api/helm-app/bean/bean.go b/api/helm-app/bean/bean.go index 7b8daff9b5..e79d0fcb1a 100644 --- a/api/helm-app/bean/bean.go +++ b/api/helm-app/bean/bean.go @@ -1,7 +1,7 @@ package bean import ( - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/pkg/appStore/bean" ) @@ -23,7 +23,7 @@ type UpdateApplicationRequestDto struct { } type UpdateApplicationWithChartInfoRequestDto struct { - *gRPC.InstallReleaseRequest + *client.InstallReleaseRequest SourceAppType SourceAppType `json:"-"` } @@ -52,17 +52,17 @@ func ConvertToInstalledAppInfo(installedApp *appStoreBean.InstallAppVersionDTO) type AppDetailAndInstalledAppInfo struct { InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - AppDetail *gRPC.AppDetail `json:"appDetail"` + AppDetail *client.AppDetail `json:"appDetail"` } type ReleaseAndInstalledAppInfo struct { - InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - ReleaseInfo *gRPC.ReleaseInfo `json:"releaseInfo"` + InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` + ReleaseInfo *client.ReleaseInfo `json:"releaseInfo"` } type DeploymentHistoryAndInstalledAppInfo struct { - InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` - DeploymentHistory []*gRPC.HelmAppDeploymentDetail `json:"deploymentHistory"` + InstalledAppInfo *InstalledAppInfo `json:"installedAppInfo"` + DeploymentHistory []*client.HelmAppDeploymentDetail `json:"deploymentHistory"` } type InstalledAppInfo struct { diff --git a/api/helm-app/gRPC/applicationClient.go b/api/helm-app/gRPC/applicationClient.go index ce9ae8f62b..3ac982b90e 100644 --- a/api/helm-app/gRPC/applicationClient.go +++ b/api/helm-app/gRPC/applicationClient.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "github.com/caarlos0/env" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" "go.uber.org/zap" "google.golang.org/grpc" @@ -11,32 +12,32 @@ import ( ) type HelmAppClient interface { - ListApplication(ctx context.Context, req *AppListRequest) (ApplicationService_ListApplicationsClient, error) - GetAppDetail(ctx context.Context, in *AppDetailRequest) (*AppDetail, error) - GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest) (*ResourceTreeResponse, error) - GetAppStatus(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) - Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) - UnHibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) - GetDeploymentHistory(ctx context.Context, in *AppDetailRequest) (*HelmAppDeploymentHistory, error) - GetValuesYaml(ctx context.Context, in *AppDetailRequest) (*ReleaseInfo, error) - GetDesiredManifest(ctx context.Context, in *ObjectRequest) (*DesiredManifestResponse, error) - DeleteApplication(ctx context.Context, in *ReleaseIdentifier) (*UninstallReleaseResponse, error) - UpdateApplication(ctx context.Context, in *UpgradeReleaseRequest) (*UpgradeReleaseResponse, error) - GetDeploymentDetail(ctx context.Context, in *DeploymentDetailRequest) (*DeploymentDetailResponse, error) - InstallRelease(ctx context.Context, in *InstallReleaseRequest) (*InstallReleaseResponse, error) - UpdateApplicationWithChartInfo(ctx context.Context, in *InstallReleaseRequest) (*UpgradeReleaseResponse, error) - IsReleaseInstalled(ctx context.Context, in *ReleaseIdentifier) (*BooleanResponse, error) - RollbackRelease(ctx context.Context, in *RollbackReleaseRequest) (*BooleanResponse, error) - TemplateChart(ctx context.Context, in *InstallReleaseRequest) (*TemplateChartResponse, error) - InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest) (*HelmInstallCustomResponse, error) - GetNotes(ctx context.Context, request *InstallReleaseRequest) (*ChartNotesResponse, error) - ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *RegistryCredential) (*OCIRegistryResponse, error) + ListApplication(ctx context.Context, req *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error) + GetAppDetail(ctx context.Context, in *client.AppDetailRequest) (*client.AppDetail, error) + GetResourceTreeForExternalResources(ctx context.Context, in *client.ExternalResourceTreeRequest) (*client.ResourceTreeResponse, error) + GetAppStatus(ctx context.Context, in *client.AppDetailRequest) (*client.AppStatus, error) + Hibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) + UnHibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) + GetDeploymentHistory(ctx context.Context, in *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error) + GetValuesYaml(ctx context.Context, in *client.AppDetailRequest) (*client.ReleaseInfo, error) + GetDesiredManifest(ctx context.Context, in *client.ObjectRequest) (*client.DesiredManifestResponse, error) + DeleteApplication(ctx context.Context, in *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error) + UpdateApplication(ctx context.Context, in *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error) + GetDeploymentDetail(ctx context.Context, in *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error) + InstallRelease(ctx context.Context, in *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) + UpdateApplicationWithChartInfo(ctx context.Context, in *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error) + IsReleaseInstalled(ctx context.Context, in *client.ReleaseIdentifier) (*client.BooleanResponse, error) + RollbackRelease(ctx context.Context, in *client.RollbackReleaseRequest) (*client.BooleanResponse, error) + TemplateChart(ctx context.Context, in *client.InstallReleaseRequest) (*client.TemplateChartResponse, error) + InstallReleaseWithCustomChart(ctx context.Context, in *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error) + GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (*client.ChartNotesResponse, error) + ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *client.RegistryCredential) (*client.OCIRegistryResponse, error) } type HelmAppClientImpl struct { logger *zap.SugaredLogger helmClientConfig *HelmClientConfig - applicationServiceClient ApplicationServiceClient + applicationServiceClient client.ApplicationServiceClient } func NewHelmAppClientImpl(logger *zap.SugaredLogger, helmClientConfig *HelmClientConfig) *HelmAppClientImpl { @@ -56,13 +57,13 @@ func GetConfig() (*HelmClientConfig, error) { return cfg, err } -func (impl *HelmAppClientImpl) getApplicationClient() (ApplicationServiceClient, error) { +func (impl *HelmAppClientImpl) getApplicationClient() (client.ApplicationServiceClient, error) { if impl.applicationServiceClient == nil { connection, err := impl.getConnection() if err != nil { return nil, err } - impl.applicationServiceClient = NewApplicationServiceClient(connection) + impl.applicationServiceClient = client.NewApplicationServiceClient(connection) } return impl.applicationServiceClient, nil } @@ -88,7 +89,7 @@ func (impl *HelmAppClientImpl) getConnection() (*grpc.ClientConn, error) { return conn, err } -func (impl *HelmAppClientImpl) ListApplication(ctx context.Context, req *AppListRequest) (ApplicationService_ListApplicationsClient, error) { +func (impl *HelmAppClientImpl) ListApplication(ctx context.Context, req *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -102,7 +103,7 @@ func (impl *HelmAppClientImpl) ListApplication(ctx context.Context, req *AppList /// GetAppDetail(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppDetail, error) -func (impl *HelmAppClientImpl) GetAppDetail(ctx context.Context, in *AppDetailRequest) (*AppDetail, error) { +func (impl *HelmAppClientImpl) GetAppDetail(ctx context.Context, in *client.AppDetailRequest) (*client.AppDetail, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -114,7 +115,7 @@ func (impl *HelmAppClientImpl) GetAppDetail(ctx context.Context, in *AppDetailRe return detail, nil } -func (impl *HelmAppClientImpl) GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest) (*ResourceTreeResponse, error) { +func (impl *HelmAppClientImpl) GetResourceTreeForExternalResources(ctx context.Context, in *client.ExternalResourceTreeRequest) (*client.ResourceTreeResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -126,7 +127,7 @@ func (impl *HelmAppClientImpl) GetResourceTreeForExternalResources(ctx context.C return detail, nil } -func (impl *HelmAppClientImpl) GetAppStatus(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) { +func (impl *HelmAppClientImpl) GetAppStatus(ctx context.Context, in *client.AppDetailRequest) (*client.AppStatus, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -138,7 +139,7 @@ func (impl *HelmAppClientImpl) GetAppStatus(ctx context.Context, in *AppDetailRe return appStatus, nil } -func (impl *HelmAppClientImpl) Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) { +func (impl *HelmAppClientImpl) Hibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -150,7 +151,7 @@ func (impl *HelmAppClientImpl) Hibernate(ctx context.Context, in *HibernateReque return detail, nil } -func (impl *HelmAppClientImpl) UnHibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) { +func (impl *HelmAppClientImpl) UnHibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -162,7 +163,7 @@ func (impl *HelmAppClientImpl) UnHibernate(ctx context.Context, in *HibernateReq return detail, nil } -func (impl *HelmAppClientImpl) GetDeploymentHistory(ctx context.Context, in *AppDetailRequest) (*HelmAppDeploymentHistory, error) { +func (impl *HelmAppClientImpl) GetDeploymentHistory(ctx context.Context, in *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -174,7 +175,7 @@ func (impl *HelmAppClientImpl) GetDeploymentHistory(ctx context.Context, in *App return history, nil } -func (impl *HelmAppClientImpl) GetValuesYaml(ctx context.Context, in *AppDetailRequest) (*ReleaseInfo, error) { +func (impl *HelmAppClientImpl) GetValuesYaml(ctx context.Context, in *client.AppDetailRequest) (*client.ReleaseInfo, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -186,7 +187,7 @@ func (impl *HelmAppClientImpl) GetValuesYaml(ctx context.Context, in *AppDetailR return values, nil } -func (impl *HelmAppClientImpl) GetDesiredManifest(ctx context.Context, in *ObjectRequest) (*DesiredManifestResponse, error) { +func (impl *HelmAppClientImpl) GetDesiredManifest(ctx context.Context, in *client.ObjectRequest) (*client.DesiredManifestResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -198,7 +199,7 @@ func (impl *HelmAppClientImpl) GetDesiredManifest(ctx context.Context, in *Objec return manifest, nil } -func (impl *HelmAppClientImpl) DeleteApplication(ctx context.Context, in *ReleaseIdentifier) (*UninstallReleaseResponse, error) { +func (impl *HelmAppClientImpl) DeleteApplication(ctx context.Context, in *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -210,7 +211,7 @@ func (impl *HelmAppClientImpl) DeleteApplication(ctx context.Context, in *Releas return manifest, nil } -func (impl *HelmAppClientImpl) UpdateApplication(ctx context.Context, in *UpgradeReleaseRequest) (*UpgradeReleaseResponse, error) { +func (impl *HelmAppClientImpl) UpdateApplication(ctx context.Context, in *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -222,7 +223,7 @@ func (impl *HelmAppClientImpl) UpdateApplication(ctx context.Context, in *Upgrad return manifest, nil } -func (impl *HelmAppClientImpl) GetDeploymentDetail(ctx context.Context, in *DeploymentDetailRequest) (*DeploymentDetailResponse, error) { +func (impl *HelmAppClientImpl) GetDeploymentDetail(ctx context.Context, in *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -234,7 +235,7 @@ func (impl *HelmAppClientImpl) GetDeploymentDetail(ctx context.Context, in *Depl return deploymentDetail, nil } -func (impl *HelmAppClientImpl) InstallRelease(ctx context.Context, in *InstallReleaseRequest) (*InstallReleaseResponse, error) { +func (impl *HelmAppClientImpl) InstallRelease(ctx context.Context, in *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -246,7 +247,7 @@ func (impl *HelmAppClientImpl) InstallRelease(ctx context.Context, in *InstallRe return installReleaseResponse, nil } -func (impl *HelmAppClientImpl) UpdateApplicationWithChartInfo(ctx context.Context, in *InstallReleaseRequest) (*UpgradeReleaseResponse, error) { +func (impl *HelmAppClientImpl) UpdateApplicationWithChartInfo(ctx context.Context, in *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -258,7 +259,7 @@ func (impl *HelmAppClientImpl) UpdateApplicationWithChartInfo(ctx context.Contex return updateReleaseResponse, nil } -func (impl *HelmAppClientImpl) IsReleaseInstalled(ctx context.Context, in *ReleaseIdentifier) (*BooleanResponse, error) { +func (impl *HelmAppClientImpl) IsReleaseInstalled(ctx context.Context, in *client.ReleaseIdentifier) (*client.BooleanResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -270,7 +271,7 @@ func (impl *HelmAppClientImpl) IsReleaseInstalled(ctx context.Context, in *Relea return response, nil } -func (impl *HelmAppClientImpl) RollbackRelease(ctx context.Context, in *RollbackReleaseRequest) (*BooleanResponse, error) { +func (impl *HelmAppClientImpl) RollbackRelease(ctx context.Context, in *client.RollbackReleaseRequest) (*client.BooleanResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -282,7 +283,7 @@ func (impl *HelmAppClientImpl) RollbackRelease(ctx context.Context, in *Rollback return response, nil } -func (impl *HelmAppClientImpl) TemplateChart(ctx context.Context, in *InstallReleaseRequest) (*TemplateChartResponse, error) { +func (impl *HelmAppClientImpl) TemplateChart(ctx context.Context, in *client.InstallReleaseRequest) (*client.TemplateChartResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -294,7 +295,7 @@ func (impl *HelmAppClientImpl) TemplateChart(ctx context.Context, in *InstallRel return response, nil } -func (impl *HelmAppClientImpl) InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest) (*HelmInstallCustomResponse, error) { +func (impl *HelmAppClientImpl) InstallReleaseWithCustomChart(ctx context.Context, in *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -306,7 +307,7 @@ func (impl *HelmAppClientImpl) InstallReleaseWithCustomChart(ctx context.Context return response, nil } -func (impl *HelmAppClientImpl) GetNotes(ctx context.Context, in *InstallReleaseRequest) (*ChartNotesResponse, error) { +func (impl *HelmAppClientImpl) GetNotes(ctx context.Context, in *client.InstallReleaseRequest) (*client.ChartNotesResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err @@ -320,7 +321,7 @@ func (impl *HelmAppClientImpl) GetNotes(ctx context.Context, in *InstallReleaseR } -func (impl *HelmAppClientImpl) ValidateOCIRegistry(ctx context.Context, in *RegistryCredential) (*OCIRegistryResponse, error) { +func (impl *HelmAppClientImpl) ValidateOCIRegistry(ctx context.Context, in *client.RegistryCredential) (*client.OCIRegistryResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { return nil, err diff --git a/api/helm-app/gRPC/applist.pb.go b/api/helm-app/gRPC/client/applist.pb.go similarity index 56% rename from api/helm-app/gRPC/applist.pb.go rename to api/helm-app/gRPC/client/applist.pb.go index 508317a95d..a720b5c841 100644 --- a/api/helm-app/gRPC/applist.pb.go +++ b/api/helm-app/gRPC/client/applist.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc v3.9.1 -// source: api/helm-app/gRPC/applist.proto +// source: api/helm-app/gRPC/client/applist.proto -package gRPC +package client import ( timestamp "github.com/golang/protobuf/ptypes/timestamp" @@ -26,20 +26,26 @@ type ClusterConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApiServerUrl string `protobuf:"bytes,1,opt,name=apiServerUrl,proto3" json:"apiServerUrl,omitempty"` - Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` - ClusterId int32 `protobuf:"varint,3,opt,name=clusterId,proto3" json:"clusterId,omitempty"` - ClusterName string `protobuf:"bytes,4,opt,name=clusterName,proto3" json:"clusterName,omitempty"` - InsecureSkipTLSVerify bool `protobuf:"varint,5,opt,name=insecureSkipTLSVerify,proto3" json:"insecureSkipTLSVerify,omitempty"` - KeyData string `protobuf:"bytes,6,opt,name=keyData,proto3" json:"keyData,omitempty"` - CertData string `protobuf:"bytes,7,opt,name=certData,proto3" json:"certData,omitempty"` - CaData string `protobuf:"bytes,8,opt,name=caData,proto3" json:"caData,omitempty"` + ApiServerUrl string `protobuf:"bytes,1,opt,name=apiServerUrl,proto3" json:"apiServerUrl,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + ClusterId int32 `protobuf:"varint,3,opt,name=clusterId,proto3" json:"clusterId,omitempty"` + ClusterName string `protobuf:"bytes,4,opt,name=clusterName,proto3" json:"clusterName,omitempty"` + InsecureSkipTLSVerify bool `protobuf:"varint,5,opt,name=insecureSkipTLSVerify,proto3" json:"insecureSkipTLSVerify,omitempty"` + KeyData string `protobuf:"bytes,6,opt,name=keyData,proto3" json:"keyData,omitempty"` + CertData string `protobuf:"bytes,7,opt,name=certData,proto3" json:"certData,omitempty"` + CaData string `protobuf:"bytes,8,opt,name=caData,proto3" json:"caData,omitempty"` + ProxyUrl string `protobuf:"bytes,9,opt,name=proxyUrl,proto3" json:"proxyUrl,omitempty"` + ToConnectWithSSHTunnel bool `protobuf:"varint,10,opt,name=toConnectWithSSHTunnel,proto3" json:"toConnectWithSSHTunnel,omitempty"` + SshTunnelUser string `protobuf:"bytes,11,opt,name=sshTunnelUser,proto3" json:"sshTunnelUser,omitempty"` + SshTunnelPassword string `protobuf:"bytes,12,opt,name=sshTunnelPassword,proto3" json:"sshTunnelPassword,omitempty"` + SshTunnelAuthKey string `protobuf:"bytes,13,opt,name=sshTunnelAuthKey,proto3" json:"sshTunnelAuthKey,omitempty"` + SshTunnelServerAddress string `protobuf:"bytes,14,opt,name=sshTunnelServerAddress,proto3" json:"sshTunnelServerAddress,omitempty"` } func (x *ClusterConfig) Reset() { *x = ClusterConfig{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[0] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -52,7 +58,7 @@ func (x *ClusterConfig) String() string { func (*ClusterConfig) ProtoMessage() {} func (x *ClusterConfig) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[0] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -65,7 +71,7 @@ func (x *ClusterConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use ClusterConfig.ProtoReflect.Descriptor instead. func (*ClusterConfig) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{0} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{0} } func (x *ClusterConfig) GetApiServerUrl() string { @@ -124,6 +130,48 @@ func (x *ClusterConfig) GetCaData() string { return "" } +func (x *ClusterConfig) GetProxyUrl() string { + if x != nil { + return x.ProxyUrl + } + return "" +} + +func (x *ClusterConfig) GetToConnectWithSSHTunnel() bool { + if x != nil { + return x.ToConnectWithSSHTunnel + } + return false +} + +func (x *ClusterConfig) GetSshTunnelUser() string { + if x != nil { + return x.SshTunnelUser + } + return "" +} + +func (x *ClusterConfig) GetSshTunnelPassword() string { + if x != nil { + return x.SshTunnelPassword + } + return "" +} + +func (x *ClusterConfig) GetSshTunnelAuthKey() string { + if x != nil { + return x.SshTunnelAuthKey + } + return "" +} + +func (x *ClusterConfig) GetSshTunnelServerAddress() string { + if x != nil { + return x.SshTunnelServerAddress + } + return "" +} + type AppListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -135,7 +183,7 @@ type AppListRequest struct { func (x *AppListRequest) Reset() { *x = AppListRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[1] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -148,7 +196,7 @@ func (x *AppListRequest) String() string { func (*AppListRequest) ProtoMessage() {} func (x *AppListRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[1] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -161,7 +209,7 @@ func (x *AppListRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AppListRequest.ProtoReflect.Descriptor instead. func (*AppListRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{1} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{1} } func (x *AppListRequest) GetClusters() []*ClusterConfig { @@ -183,7 +231,7 @@ type ExternalResourceTreeRequest struct { func (x *ExternalResourceTreeRequest) Reset() { *x = ExternalResourceTreeRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[2] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +244,7 @@ func (x *ExternalResourceTreeRequest) String() string { func (*ExternalResourceTreeRequest) ProtoMessage() {} func (x *ExternalResourceTreeRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[2] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +257,7 @@ func (x *ExternalResourceTreeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ExternalResourceTreeRequest.ProtoReflect.Descriptor instead. func (*ExternalResourceTreeRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{2} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{2} } func (x *ExternalResourceTreeRequest) GetClusterConfig() *ClusterConfig { @@ -241,7 +289,7 @@ type ExternalResourceDetail struct { func (x *ExternalResourceDetail) Reset() { *x = ExternalResourceDetail{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[3] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -254,7 +302,7 @@ func (x *ExternalResourceDetail) String() string { func (*ExternalResourceDetail) ProtoMessage() {} func (x *ExternalResourceDetail) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[3] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -267,7 +315,7 @@ func (x *ExternalResourceDetail) ProtoReflect() protoreflect.Message { // Deprecated: Use ExternalResourceDetail.ProtoReflect.Descriptor instead. func (*ExternalResourceDetail) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{3} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{3} } func (x *ExternalResourceDetail) GetGroup() string { @@ -319,7 +367,7 @@ type DeployedAppList struct { func (x *DeployedAppList) Reset() { *x = DeployedAppList{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[4] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -332,7 +380,7 @@ func (x *DeployedAppList) String() string { func (*DeployedAppList) ProtoMessage() {} func (x *DeployedAppList) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[4] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -345,7 +393,7 @@ func (x *DeployedAppList) ProtoReflect() protoreflect.Message { // Deprecated: Use DeployedAppList.ProtoReflect.Descriptor instead. func (*DeployedAppList) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{4} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{4} } func (x *DeployedAppList) GetDeployedAppDetail() []*DeployedAppDetail { @@ -393,7 +441,7 @@ type DeployedAppDetail struct { func (x *DeployedAppDetail) Reset() { *x = DeployedAppDetail{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[5] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -406,7 +454,7 @@ func (x *DeployedAppDetail) String() string { func (*DeployedAppDetail) ProtoMessage() {} func (x *DeployedAppDetail) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[5] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -419,7 +467,7 @@ func (x *DeployedAppDetail) ProtoReflect() protoreflect.Message { // Deprecated: Use DeployedAppDetail.ProtoReflect.Descriptor instead. func (*DeployedAppDetail) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{5} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{5} } func (x *DeployedAppDetail) GetAppId() string { @@ -484,7 +532,7 @@ type EnvironmentDetails struct { func (x *EnvironmentDetails) Reset() { *x = EnvironmentDetails{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[6] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -497,7 +545,7 @@ func (x *EnvironmentDetails) String() string { func (*EnvironmentDetails) ProtoMessage() {} func (x *EnvironmentDetails) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[6] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -510,7 +558,7 @@ func (x *EnvironmentDetails) ProtoReflect() protoreflect.Message { // Deprecated: Use EnvironmentDetails.ProtoReflect.Descriptor instead. func (*EnvironmentDetails) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{6} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{6} } func (x *EnvironmentDetails) GetClusterName() string { @@ -549,7 +597,7 @@ type AppDetailRequest struct { func (x *AppDetailRequest) Reset() { *x = AppDetailRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[7] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -562,7 +610,7 @@ func (x *AppDetailRequest) String() string { func (*AppDetailRequest) ProtoMessage() {} func (x *AppDetailRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[7] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -575,7 +623,7 @@ func (x *AppDetailRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AppDetailRequest.ProtoReflect.Descriptor instead. func (*AppDetailRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{7} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{7} } func (x *AppDetailRequest) GetClusterConfig() *ClusterConfig { @@ -623,7 +671,7 @@ type AppDetail struct { func (x *AppDetail) Reset() { *x = AppDetail{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[8] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -636,7 +684,7 @@ func (x *AppDetail) String() string { func (*AppDetail) ProtoMessage() {} func (x *AppDetail) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[8] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -649,7 +697,7 @@ func (x *AppDetail) ProtoReflect() protoreflect.Message { // Deprecated: Use AppDetail.ProtoReflect.Descriptor instead. func (*AppDetail) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{8} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{8} } func (x *AppDetail) GetApplicationStatus() string { @@ -715,7 +763,7 @@ type AppStatus struct { func (x *AppStatus) Reset() { *x = AppStatus{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[9] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -728,7 +776,7 @@ func (x *AppStatus) String() string { func (*AppStatus) ProtoMessage() {} func (x *AppStatus) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[9] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -741,7 +789,7 @@ func (x *AppStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use AppStatus.ProtoReflect.Descriptor instead. func (*AppStatus) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{9} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{9} } func (x *AppStatus) GetApplicationStatus() string { @@ -785,7 +833,7 @@ type ReleaseStatus struct { func (x *ReleaseStatus) Reset() { *x = ReleaseStatus{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[10] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -798,7 +846,7 @@ func (x *ReleaseStatus) String() string { func (*ReleaseStatus) ProtoMessage() {} func (x *ReleaseStatus) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[10] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -811,7 +859,7 @@ func (x *ReleaseStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use ReleaseStatus.ProtoReflect.Descriptor instead. func (*ReleaseStatus) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{10} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{10} } func (x *ReleaseStatus) GetStatus() string { @@ -852,7 +900,7 @@ type ChartMetadata struct { func (x *ChartMetadata) Reset() { *x = ChartMetadata{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[11] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -865,7 +913,7 @@ func (x *ChartMetadata) String() string { func (*ChartMetadata) ProtoMessage() {} func (x *ChartMetadata) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[11] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -878,7 +926,7 @@ func (x *ChartMetadata) ProtoReflect() protoreflect.Message { // Deprecated: Use ChartMetadata.ProtoReflect.Descriptor instead. func (*ChartMetadata) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{11} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{11} } func (x *ChartMetadata) GetChartName() string { @@ -935,7 +983,7 @@ type ResourceTreeResponse struct { func (x *ResourceTreeResponse) Reset() { *x = ResourceTreeResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[12] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -948,7 +996,7 @@ func (x *ResourceTreeResponse) String() string { func (*ResourceTreeResponse) ProtoMessage() {} func (x *ResourceTreeResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[12] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -961,7 +1009,7 @@ func (x *ResourceTreeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceTreeResponse.ProtoReflect.Descriptor instead. func (*ResourceTreeResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{12} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{12} } func (x *ResourceTreeResponse) GetNodes() []*ResourceNode { @@ -1005,7 +1053,7 @@ type ResourceNode struct { func (x *ResourceNode) Reset() { *x = ResourceNode{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[13] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1018,7 +1066,7 @@ func (x *ResourceNode) String() string { func (*ResourceNode) ProtoMessage() {} func (x *ResourceNode) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[13] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1031,7 +1079,7 @@ func (x *ResourceNode) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceNode.ProtoReflect.Descriptor instead. func (*ResourceNode) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{13} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{13} } func (x *ResourceNode) GetGroup() string { @@ -1165,7 +1213,7 @@ type InfoItem struct { func (x *InfoItem) Reset() { *x = InfoItem{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[14] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1178,7 +1226,7 @@ func (x *InfoItem) String() string { func (*InfoItem) ProtoMessage() {} func (x *InfoItem) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[14] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1191,7 +1239,7 @@ func (x *InfoItem) ProtoReflect() protoreflect.Message { // Deprecated: Use InfoItem.ProtoReflect.Descriptor instead. func (*InfoItem) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{14} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{14} } func (x *InfoItem) GetName() string { @@ -1220,7 +1268,7 @@ type HealthStatus struct { func (x *HealthStatus) Reset() { *x = HealthStatus{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[15] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1233,7 +1281,7 @@ func (x *HealthStatus) String() string { func (*HealthStatus) ProtoMessage() {} func (x *HealthStatus) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[15] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[15] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1246,7 +1294,7 @@ func (x *HealthStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use HealthStatus.ProtoReflect.Descriptor instead. func (*HealthStatus) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{15} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{15} } func (x *HealthStatus) GetStatus() string { @@ -1274,7 +1322,7 @@ type ResourceNetworkingInfo struct { func (x *ResourceNetworkingInfo) Reset() { *x = ResourceNetworkingInfo{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[16] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1287,7 +1335,7 @@ func (x *ResourceNetworkingInfo) String() string { func (*ResourceNetworkingInfo) ProtoMessage() {} func (x *ResourceNetworkingInfo) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[16] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[16] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1300,7 +1348,7 @@ func (x *ResourceNetworkingInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceNetworkingInfo.ProtoReflect.Descriptor instead. func (*ResourceNetworkingInfo) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{16} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{16} } func (x *ResourceNetworkingInfo) GetLabels() map[string]string { @@ -1326,7 +1374,7 @@ type ResourceRef struct { func (x *ResourceRef) Reset() { *x = ResourceRef{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[17] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1339,7 +1387,7 @@ func (x *ResourceRef) String() string { func (*ResourceRef) ProtoMessage() {} func (x *ResourceRef) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[17] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[17] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1352,7 +1400,7 @@ func (x *ResourceRef) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceRef.ProtoReflect.Descriptor instead. func (*ResourceRef) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{17} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{17} } func (x *ResourceRef) GetGroup() string { @@ -1413,7 +1461,7 @@ type PodMetadata struct { func (x *PodMetadata) Reset() { *x = PodMetadata{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[18] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1426,7 +1474,7 @@ func (x *PodMetadata) String() string { func (*PodMetadata) ProtoMessage() {} func (x *PodMetadata) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[18] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[18] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1439,7 +1487,7 @@ func (x *PodMetadata) ProtoReflect() protoreflect.Message { // Deprecated: Use PodMetadata.ProtoReflect.Descriptor instead. func (*PodMetadata) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{18} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{18} } func (x *PodMetadata) GetName() string { @@ -1496,7 +1544,7 @@ type EphemeralContainerData struct { func (x *EphemeralContainerData) Reset() { *x = EphemeralContainerData{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[19] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1509,7 +1557,7 @@ func (x *EphemeralContainerData) String() string { func (*EphemeralContainerData) ProtoMessage() {} func (x *EphemeralContainerData) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[19] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1522,7 +1570,7 @@ func (x *EphemeralContainerData) ProtoReflect() protoreflect.Message { // Deprecated: Use EphemeralContainerData.ProtoReflect.Descriptor instead. func (*EphemeralContainerData) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{19} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{19} } func (x *EphemeralContainerData) GetName() string { @@ -1551,7 +1599,7 @@ type HibernateRequest struct { func (x *HibernateRequest) Reset() { *x = HibernateRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[20] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1564,7 +1612,7 @@ func (x *HibernateRequest) String() string { func (*HibernateRequest) ProtoMessage() {} func (x *HibernateRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[20] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1577,7 +1625,7 @@ func (x *HibernateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HibernateRequest.ProtoReflect.Descriptor instead. func (*HibernateRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{20} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{20} } func (x *HibernateRequest) GetClusterConfig() *ClusterConfig { @@ -1609,7 +1657,7 @@ type ObjectIdentifier struct { func (x *ObjectIdentifier) Reset() { *x = ObjectIdentifier{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[21] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1622,7 +1670,7 @@ func (x *ObjectIdentifier) String() string { func (*ObjectIdentifier) ProtoMessage() {} func (x *ObjectIdentifier) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[21] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1635,7 +1683,7 @@ func (x *ObjectIdentifier) ProtoReflect() protoreflect.Message { // Deprecated: Use ObjectIdentifier.ProtoReflect.Descriptor instead. func (*ObjectIdentifier) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{21} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{21} } func (x *ObjectIdentifier) GetGroup() string { @@ -1686,7 +1734,7 @@ type HibernateStatus struct { func (x *HibernateStatus) Reset() { *x = HibernateStatus{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[22] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1699,7 +1747,7 @@ func (x *HibernateStatus) String() string { func (*HibernateStatus) ProtoMessage() {} func (x *HibernateStatus) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[22] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1712,7 +1760,7 @@ func (x *HibernateStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use HibernateStatus.ProtoReflect.Descriptor instead. func (*HibernateStatus) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{22} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{22} } func (x *HibernateStatus) GetTargetObject() *ObjectIdentifier { @@ -1747,7 +1795,7 @@ type HibernateResponse struct { func (x *HibernateResponse) Reset() { *x = HibernateResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[23] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1760,7 +1808,7 @@ func (x *HibernateResponse) String() string { func (*HibernateResponse) ProtoMessage() {} func (x *HibernateResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[23] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[23] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1773,7 +1821,7 @@ func (x *HibernateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use HibernateResponse.ProtoReflect.Descriptor instead. func (*HibernateResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{23} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{23} } func (x *HibernateResponse) GetStatus() []*HibernateStatus { @@ -1799,7 +1847,7 @@ type HelmAppDeploymentDetail struct { func (x *HelmAppDeploymentDetail) Reset() { *x = HelmAppDeploymentDetail{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[24] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1812,7 +1860,7 @@ func (x *HelmAppDeploymentDetail) String() string { func (*HelmAppDeploymentDetail) ProtoMessage() {} func (x *HelmAppDeploymentDetail) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[24] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[24] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1825,7 +1873,7 @@ func (x *HelmAppDeploymentDetail) ProtoReflect() protoreflect.Message { // Deprecated: Use HelmAppDeploymentDetail.ProtoReflect.Descriptor instead. func (*HelmAppDeploymentDetail) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{24} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{24} } func (x *HelmAppDeploymentDetail) GetChartMetadata() *ChartMetadata { @@ -1881,7 +1929,7 @@ type HelmAppDeploymentHistory struct { func (x *HelmAppDeploymentHistory) Reset() { *x = HelmAppDeploymentHistory{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[25] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1894,7 +1942,7 @@ func (x *HelmAppDeploymentHistory) String() string { func (*HelmAppDeploymentHistory) ProtoMessage() {} func (x *HelmAppDeploymentHistory) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[25] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[25] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1907,7 +1955,7 @@ func (x *HelmAppDeploymentHistory) ProtoReflect() protoreflect.Message { // Deprecated: Use HelmAppDeploymentHistory.ProtoReflect.Descriptor instead. func (*HelmAppDeploymentHistory) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{25} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{25} } func (x *HelmAppDeploymentHistory) GetDeploymentHistory() []*HelmAppDeploymentDetail { @@ -1933,7 +1981,7 @@ type ReleaseInfo struct { func (x *ReleaseInfo) Reset() { *x = ReleaseInfo{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[26] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1946,7 +1994,7 @@ func (x *ReleaseInfo) String() string { func (*ReleaseInfo) ProtoMessage() {} func (x *ReleaseInfo) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[26] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1959,7 +2007,7 @@ func (x *ReleaseInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use ReleaseInfo.ProtoReflect.Descriptor instead. func (*ReleaseInfo) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{26} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{26} } func (x *ReleaseInfo) GetDeployedAppDetail() *DeployedAppDetail { @@ -2018,7 +2066,7 @@ type ObjectRequest struct { func (x *ObjectRequest) Reset() { *x = ObjectRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[27] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2031,7 +2079,7 @@ func (x *ObjectRequest) String() string { func (*ObjectRequest) ProtoMessage() {} func (x *ObjectRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[27] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[27] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2044,7 +2092,7 @@ func (x *ObjectRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ObjectRequest.ProtoReflect.Descriptor instead. func (*ObjectRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{27} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{27} } func (x *ObjectRequest) GetClusterConfig() *ClusterConfig { @@ -2086,7 +2134,7 @@ type DesiredManifestResponse struct { func (x *DesiredManifestResponse) Reset() { *x = DesiredManifestResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[28] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2099,7 +2147,7 @@ func (x *DesiredManifestResponse) String() string { func (*DesiredManifestResponse) ProtoMessage() {} func (x *DesiredManifestResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[28] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2112,7 +2160,7 @@ func (x *DesiredManifestResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DesiredManifestResponse.ProtoReflect.Descriptor instead. func (*DesiredManifestResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{28} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{28} } func (x *DesiredManifestResponse) GetManifest() string { @@ -2133,7 +2181,7 @@ type UninstallReleaseResponse struct { func (x *UninstallReleaseResponse) Reset() { *x = UninstallReleaseResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[29] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2146,7 +2194,7 @@ func (x *UninstallReleaseResponse) String() string { func (*UninstallReleaseResponse) ProtoMessage() {} func (x *UninstallReleaseResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[29] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2159,7 +2207,7 @@ func (x *UninstallReleaseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UninstallReleaseResponse.ProtoReflect.Descriptor instead. func (*UninstallReleaseResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{29} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{29} } func (x *UninstallReleaseResponse) GetSuccess() bool { @@ -2182,7 +2230,7 @@ type ReleaseIdentifier struct { func (x *ReleaseIdentifier) Reset() { *x = ReleaseIdentifier{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[30] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2195,7 +2243,7 @@ func (x *ReleaseIdentifier) String() string { func (*ReleaseIdentifier) ProtoMessage() {} func (x *ReleaseIdentifier) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[30] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2208,7 +2256,7 @@ func (x *ReleaseIdentifier) ProtoReflect() protoreflect.Message { // Deprecated: Use ReleaseIdentifier.ProtoReflect.Descriptor instead. func (*ReleaseIdentifier) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{30} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{30} } func (x *ReleaseIdentifier) GetClusterConfig() *ClusterConfig { @@ -2247,7 +2295,7 @@ type UpgradeReleaseRequest struct { func (x *UpgradeReleaseRequest) Reset() { *x = UpgradeReleaseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[31] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2260,7 +2308,7 @@ func (x *UpgradeReleaseRequest) String() string { func (*UpgradeReleaseRequest) ProtoMessage() {} func (x *UpgradeReleaseRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[31] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2273,7 +2321,7 @@ func (x *UpgradeReleaseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpgradeReleaseRequest.ProtoReflect.Descriptor instead. func (*UpgradeReleaseRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{31} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{31} } func (x *UpgradeReleaseRequest) GetReleaseIdentifier() *ReleaseIdentifier { @@ -2322,7 +2370,7 @@ type UpgradeReleaseResponse struct { func (x *UpgradeReleaseResponse) Reset() { *x = UpgradeReleaseResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[32] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2335,7 +2383,7 @@ func (x *UpgradeReleaseResponse) String() string { func (*UpgradeReleaseResponse) ProtoMessage() {} func (x *UpgradeReleaseResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[32] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2348,7 +2396,7 @@ func (x *UpgradeReleaseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpgradeReleaseResponse.ProtoReflect.Descriptor instead. func (*UpgradeReleaseResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{32} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{32} } func (x *UpgradeReleaseResponse) GetSuccess() bool { @@ -2370,7 +2418,7 @@ type DeploymentDetailRequest struct { func (x *DeploymentDetailRequest) Reset() { *x = DeploymentDetailRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[33] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2383,7 +2431,7 @@ func (x *DeploymentDetailRequest) String() string { func (*DeploymentDetailRequest) ProtoMessage() {} func (x *DeploymentDetailRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[33] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[33] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2396,7 +2444,7 @@ func (x *DeploymentDetailRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeploymentDetailRequest.ProtoReflect.Descriptor instead. func (*DeploymentDetailRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{33} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{33} } func (x *DeploymentDetailRequest) GetReleaseIdentifier() *ReleaseIdentifier { @@ -2425,7 +2473,7 @@ type DeploymentDetailResponse struct { func (x *DeploymentDetailResponse) Reset() { *x = DeploymentDetailResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[34] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2438,7 +2486,7 @@ func (x *DeploymentDetailResponse) String() string { func (*DeploymentDetailResponse) ProtoMessage() {} func (x *DeploymentDetailResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[34] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[34] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2451,7 +2499,7 @@ func (x *DeploymentDetailResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeploymentDetailResponse.ProtoReflect.Descriptor instead. func (*DeploymentDetailResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{34} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{34} } func (x *DeploymentDetailResponse) GetManifest() string { @@ -2482,7 +2530,7 @@ type ChartRepository struct { func (x *ChartRepository) Reset() { *x = ChartRepository{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[35] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2495,7 +2543,7 @@ func (x *ChartRepository) String() string { func (*ChartRepository) ProtoMessage() {} func (x *ChartRepository) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[35] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[35] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2508,7 +2556,7 @@ func (x *ChartRepository) ProtoReflect() protoreflect.Message { // Deprecated: Use ChartRepository.ProtoReflect.Descriptor instead. func (*ChartRepository) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{35} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{35} } func (x *ChartRepository) GetName() string { @@ -2560,7 +2608,7 @@ type InstallReleaseRequest struct { func (x *InstallReleaseRequest) Reset() { *x = InstallReleaseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[36] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2573,7 +2621,7 @@ func (x *InstallReleaseRequest) String() string { func (*InstallReleaseRequest) ProtoMessage() {} func (x *InstallReleaseRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[36] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[36] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2586,7 +2634,7 @@ func (x *InstallReleaseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use InstallReleaseRequest.ProtoReflect.Descriptor instead. func (*InstallReleaseRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{36} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{36} } func (x *InstallReleaseRequest) GetReleaseIdentifier() *ReleaseIdentifier { @@ -2677,7 +2725,7 @@ type InstallReleaseResponse struct { func (x *InstallReleaseResponse) Reset() { *x = InstallReleaseResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[37] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2690,7 +2738,7 @@ func (x *InstallReleaseResponse) String() string { func (*InstallReleaseResponse) ProtoMessage() {} func (x *InstallReleaseResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[37] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[37] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2703,7 +2751,7 @@ func (x *InstallReleaseResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use InstallReleaseResponse.ProtoReflect.Descriptor instead. func (*InstallReleaseResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{37} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{37} } func (x *InstallReleaseResponse) GetSuccess() bool { @@ -2724,7 +2772,7 @@ type BooleanResponse struct { func (x *BooleanResponse) Reset() { *x = BooleanResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[38] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2737,7 +2785,7 @@ func (x *BooleanResponse) String() string { func (*BooleanResponse) ProtoMessage() {} func (x *BooleanResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[38] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[38] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2750,7 +2798,7 @@ func (x *BooleanResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use BooleanResponse.ProtoReflect.Descriptor instead. func (*BooleanResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{38} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{38} } func (x *BooleanResponse) GetResult() bool { @@ -2772,7 +2820,7 @@ type RollbackReleaseRequest struct { func (x *RollbackReleaseRequest) Reset() { *x = RollbackReleaseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[39] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2785,7 +2833,7 @@ func (x *RollbackReleaseRequest) String() string { func (*RollbackReleaseRequest) ProtoMessage() {} func (x *RollbackReleaseRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[39] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[39] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2798,7 +2846,7 @@ func (x *RollbackReleaseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RollbackReleaseRequest.ProtoReflect.Descriptor instead. func (*RollbackReleaseRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{39} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{39} } func (x *RollbackReleaseRequest) GetReleaseIdentifier() *ReleaseIdentifier { @@ -2826,7 +2874,7 @@ type TemplateChartResponse struct { func (x *TemplateChartResponse) Reset() { *x = TemplateChartResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[40] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2839,7 +2887,7 @@ func (x *TemplateChartResponse) String() string { func (*TemplateChartResponse) ProtoMessage() {} func (x *TemplateChartResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[40] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[40] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2852,7 +2900,7 @@ func (x *TemplateChartResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TemplateChartResponse.ProtoReflect.Descriptor instead. func (*TemplateChartResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{40} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{40} } func (x *TemplateChartResponse) GetGeneratedManifest() string { @@ -2876,7 +2924,7 @@ type HelmInstallCustomRequest struct { func (x *HelmInstallCustomRequest) Reset() { *x = HelmInstallCustomRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[41] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2889,7 +2937,7 @@ func (x *HelmInstallCustomRequest) String() string { func (*HelmInstallCustomRequest) ProtoMessage() {} func (x *HelmInstallCustomRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[41] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[41] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2902,7 +2950,7 @@ func (x *HelmInstallCustomRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HelmInstallCustomRequest.ProtoReflect.Descriptor instead. func (*HelmInstallCustomRequest) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{41} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{41} } func (x *HelmInstallCustomRequest) GetValuesYaml() string { @@ -2944,7 +2992,7 @@ type HelmInstallCustomResponse struct { func (x *HelmInstallCustomResponse) Reset() { *x = HelmInstallCustomResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[42] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2957,7 +3005,7 @@ func (x *HelmInstallCustomResponse) String() string { func (*HelmInstallCustomResponse) ProtoMessage() {} func (x *HelmInstallCustomResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[42] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[42] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2970,7 +3018,7 @@ func (x *HelmInstallCustomResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use HelmInstallCustomResponse.ProtoReflect.Descriptor instead. func (*HelmInstallCustomResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{42} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{42} } func (x *HelmInstallCustomResponse) GetSuccess() bool { @@ -2991,7 +3039,7 @@ type ChartContent struct { func (x *ChartContent) Reset() { *x = ChartContent{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[43] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[43] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3004,7 +3052,7 @@ func (x *ChartContent) String() string { func (*ChartContent) ProtoMessage() {} func (x *ChartContent) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[43] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[43] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3017,7 +3065,7 @@ func (x *ChartContent) ProtoReflect() protoreflect.Message { // Deprecated: Use ChartContent.ProtoReflect.Descriptor instead. func (*ChartContent) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{43} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{43} } func (x *ChartContent) GetContent() []byte { @@ -3040,7 +3088,7 @@ type Gvk struct { func (x *Gvk) Reset() { *x = Gvk{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[44] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[44] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3053,7 +3101,7 @@ func (x *Gvk) String() string { func (*Gvk) ProtoMessage() {} func (x *Gvk) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[44] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[44] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3066,7 +3114,7 @@ func (x *Gvk) ProtoReflect() protoreflect.Message { // Deprecated: Use Gvk.ProtoReflect.Descriptor instead. func (*Gvk) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{44} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{44} } func (x *Gvk) GetGroup() string { @@ -3102,7 +3150,7 @@ type ResourceFilter struct { func (x *ResourceFilter) Reset() { *x = ResourceFilter{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[45] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[45] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3115,7 +3163,7 @@ func (x *ResourceFilter) String() string { func (*ResourceFilter) ProtoMessage() {} func (x *ResourceFilter) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[45] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[45] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3128,7 +3176,7 @@ func (x *ResourceFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceFilter.ProtoReflect.Descriptor instead. func (*ResourceFilter) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{45} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{45} } func (x *ResourceFilter) GetGvk() *Gvk { @@ -3156,7 +3204,7 @@ type ResourceIdentifier struct { func (x *ResourceIdentifier) Reset() { *x = ResourceIdentifier{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[46] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[46] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3169,7 +3217,7 @@ func (x *ResourceIdentifier) String() string { func (*ResourceIdentifier) ProtoMessage() {} func (x *ResourceIdentifier) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[46] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[46] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3182,7 +3230,7 @@ func (x *ResourceIdentifier) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceIdentifier.ProtoReflect.Descriptor instead. func (*ResourceIdentifier) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{46} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{46} } func (x *ResourceIdentifier) GetLabels() map[string]string { @@ -3204,7 +3252,7 @@ type ResourceTreeFilter struct { func (x *ResourceTreeFilter) Reset() { *x = ResourceTreeFilter{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[47] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[47] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3217,7 +3265,7 @@ func (x *ResourceTreeFilter) String() string { func (*ResourceTreeFilter) ProtoMessage() {} func (x *ResourceTreeFilter) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[47] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[47] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3230,7 +3278,7 @@ func (x *ResourceTreeFilter) ProtoReflect() protoreflect.Message { // Deprecated: Use ResourceTreeFilter.ProtoReflect.Descriptor instead. func (*ResourceTreeFilter) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{47} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{47} } func (x *ResourceTreeFilter) GetGlobalFilter() *ResourceIdentifier { @@ -3258,7 +3306,7 @@ type ChartNotesResponse struct { func (x *ChartNotesResponse) Reset() { *x = ChartNotesResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[48] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[48] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3271,7 +3319,7 @@ func (x *ChartNotesResponse) String() string { func (*ChartNotesResponse) ProtoMessage() {} func (x *ChartNotesResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[48] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[48] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3284,7 +3332,7 @@ func (x *ChartNotesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ChartNotesResponse.ProtoReflect.Descriptor instead. func (*ChartNotesResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{48} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{48} } func (x *ChartNotesResponse) GetNotes() string { @@ -3294,6 +3342,85 @@ func (x *ChartNotesResponse) GetNotes() string { return "" } +type OCIRegistryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Chart []byte `protobuf:"bytes,1,opt,name=Chart,proto3" json:"Chart,omitempty"` + ChartName string `protobuf:"bytes,2,opt,name=ChartName,proto3" json:"ChartName,omitempty"` + ChartVersion string `protobuf:"bytes,3,opt,name=ChartVersion,proto3" json:"ChartVersion,omitempty"` + IsInsecure bool `protobuf:"varint,4,opt,name=IsInsecure,proto3" json:"IsInsecure,omitempty"` + RegistryCredential *RegistryCredential `protobuf:"bytes,5,opt,name=RegistryCredential,proto3" json:"RegistryCredential,omitempty"` +} + +func (x *OCIRegistryRequest) Reset() { + *x = OCIRegistryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[49] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OCIRegistryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OCIRegistryRequest) ProtoMessage() {} + +func (x *OCIRegistryRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[49] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OCIRegistryRequest.ProtoReflect.Descriptor instead. +func (*OCIRegistryRequest) Descriptor() ([]byte, []int) { + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{49} +} + +func (x *OCIRegistryRequest) GetChart() []byte { + if x != nil { + return x.Chart + } + return nil +} + +func (x *OCIRegistryRequest) GetChartName() string { + if x != nil { + return x.ChartName + } + return "" +} + +func (x *OCIRegistryRequest) GetChartVersion() string { + if x != nil { + return x.ChartVersion + } + return "" +} + +func (x *OCIRegistryRequest) GetIsInsecure() bool { + if x != nil { + return x.IsInsecure + } + return false +} + +func (x *OCIRegistryRequest) GetRegistryCredential() *RegistryCredential { + if x != nil { + return x.RegistryCredential + } + return nil +} + type RegistryCredential struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3313,7 +3440,7 @@ type RegistryCredential struct { func (x *RegistryCredential) Reset() { *x = RegistryCredential{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[49] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[50] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3326,7 +3453,7 @@ func (x *RegistryCredential) String() string { func (*RegistryCredential) ProtoMessage() {} func (x *RegistryCredential) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[49] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[50] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3339,7 +3466,7 @@ func (x *RegistryCredential) ProtoReflect() protoreflect.Message { // Deprecated: Use RegistryCredential.ProtoReflect.Descriptor instead. func (*RegistryCredential) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{49} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{50} } func (x *RegistryCredential) GetRegistryUrl() string { @@ -3410,13 +3537,14 @@ type OCIRegistryResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IsLoggedIn bool `protobuf:"varint,1,opt,name=IsLoggedIn,proto3" json:"IsLoggedIn,omitempty"` + IsLoggedIn bool `protobuf:"varint,1,opt,name=IsLoggedIn,proto3" json:"IsLoggedIn,omitempty"` + PushResult *OCIRegistryPushResponse `protobuf:"bytes,2,opt,name=PushResult,proto3" json:"PushResult,omitempty"` } func (x *OCIRegistryResponse) Reset() { *x = OCIRegistryResponse{} if protoimpl.UnsafeEnabled { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[50] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[51] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3429,7 +3557,7 @@ func (x *OCIRegistryResponse) String() string { func (*OCIRegistryResponse) ProtoMessage() {} func (x *OCIRegistryResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_helm_app_gRPC_applist_proto_msgTypes[50] + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[51] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -3442,7 +3570,7 @@ func (x *OCIRegistryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use OCIRegistryResponse.ProtoReflect.Descriptor instead. func (*OCIRegistryResponse) Descriptor() ([]byte, []int) { - return file_api_helm_app_gRPC_applist_proto_rawDescGZIP(), []int{50} + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{51} } func (x *OCIRegistryResponse) GetIsLoggedIn() bool { @@ -3452,616 +3580,722 @@ func (x *OCIRegistryResponse) GetIsLoggedIn() bool { return false } -var File_api_helm_app_gRPC_applist_proto protoreflect.FileDescriptor - -var file_api_helm_app_gRPC_applist_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x65, 0x6c, 0x6d, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x67, - 0x52, 0x50, 0x43, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x8d, 0x02, 0x0a, 0x0d, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x61, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x55, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x70, 0x69, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, - 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, - 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x34, - 0x0a, 0x15, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x53, 0x6b, 0x69, 0x70, 0x54, 0x4c, - 0x53, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x69, - 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x53, 0x6b, 0x69, 0x70, 0x54, 0x4c, 0x53, 0x56, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, - 0x0a, 0x08, 0x63, 0x65, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x63, 0x65, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, - 0x44, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x61, 0x44, 0x61, - 0x74, 0x61, 0x22, 0x3c, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x08, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x73, - 0x22, 0xa4, 0x01, 0x0a, 0x1b, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x16, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, - 0x16, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x8e, 0x01, 0x0a, 0x16, 0x45, 0x78, 0x74, 0x65, +func (x *OCIRegistryResponse) GetPushResult() *OCIRegistryPushResponse { + if x != nil { + return x.PushResult + } + return nil +} + +type OCIRegistryPushResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Digest string `protobuf:"bytes,1,opt,name=Digest,proto3" json:"Digest,omitempty"` + PushedURL string `protobuf:"bytes,2,opt,name=PushedURL,proto3" json:"PushedURL,omitempty"` +} + +func (x *OCIRegistryPushResponse) Reset() { + *x = OCIRegistryPushResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[52] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OCIRegistryPushResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OCIRegistryPushResponse) ProtoMessage() {} + +func (x *OCIRegistryPushResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_helm_app_gRPC_client_applist_proto_msgTypes[52] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OCIRegistryPushResponse.ProtoReflect.Descriptor instead. +func (*OCIRegistryPushResponse) Descriptor() ([]byte, []int) { + return file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP(), []int{52} +} + +func (x *OCIRegistryPushResponse) GetDigest() string { + if x != nil { + return x.Digest + } + return "" +} + +func (x *OCIRegistryPushResponse) GetPushedURL() string { + if x != nil { + return x.PushedURL + } + return "" +} + +var File_api_helm_app_gRPC_client_applist_proto protoreflect.FileDescriptor + +var file_api_helm_app_gRPC_client_applist_proto_rawDesc = []byte{ + 0x0a, 0x26, 0x61, 0x70, 0x69, 0x2f, 0x68, 0x65, 0x6c, 0x6d, 0x2d, 0x61, 0x70, 0x70, 0x2f, 0x67, + 0x52, 0x50, 0x43, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x04, 0x0a, 0x0d, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x61, + 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x61, 0x70, 0x69, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, + 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x65, 0x53, 0x6b, 0x69, 0x70, 0x54, 0x4c, 0x53, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x53, 0x6b, + 0x69, 0x70, 0x54, 0x4c, 0x53, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6b, + 0x65, 0x79, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, + 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x65, 0x72, 0x74, 0x44, 0x61, 0x74, + 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x65, 0x72, 0x74, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x61, 0x44, 0x61, 0x74, 0x61, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x63, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x55, 0x72, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x36, 0x0a, 0x16, 0x74, 0x6f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x57, 0x69, 0x74, 0x68, 0x53, 0x53, 0x48, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x74, 0x6f, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x57, 0x69, 0x74, 0x68, 0x53, 0x53, 0x48, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x24, 0x0a, + 0x0d, 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x11, 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, + 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, + 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x41, 0x75, + 0x74, 0x68, 0x4b, 0x65, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x73, 0x68, + 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x41, 0x75, 0x74, 0x68, 0x4b, 0x65, 0x79, 0x12, 0x36, 0x0a, + 0x16, 0x73, 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x73, + 0x73, 0x68, 0x54, 0x75, 0x6e, 0x6e, 0x65, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x3c, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x08, 0x63, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x63, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x1b, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x16, 0x65, 0x78, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x74, + 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, - 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xa7, 0x01, 0x0a, 0x0f, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, + 0x69, 0x6c, 0x52, 0x16, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x8e, 0x01, 0x0a, 0x16, 0x45, + 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6b, + 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, + 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xa7, 0x01, 0x0a, 0x0f, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x12, + 0x40, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x44, 0x65, 0x70, + 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, - 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x1c, - 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x65, 0x64, 0x22, 0xaa, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, - 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x72, - 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x68, 0x61, - 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x72, 0x74, 0x41, - 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61, - 0x72, 0x74, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x41, 0x0a, 0x11, 0x65, 0x6e, 0x76, 0x69, - 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, - 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x11, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, - 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x3e, 0x0a, 0x0c, 0x4c, - 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x4c, - 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x63, - 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, - 0x72, 0x0a, 0x12, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x22, 0xcd, 0x01, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x0b, - 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x43, - 0x0a, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, - 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, - 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x22, 0x99, 0x03, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x61, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, - 0x34, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3e, 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, - 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0d, 0x63, 0x68, - 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x49, 0x0a, 0x14, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x52, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x12, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, - 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, - 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x12, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, - 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x45, 0x78, 0x69, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x45, 0x78, 0x69, 0x73, 0x74, 0x22, - 0xc1, 0x01, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2c, 0x0a, + 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x65, 0x64, 0x22, 0xaa, 0x02, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, + 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x61, + 0x70, 0x70, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, + 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, + 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, + 0x72, 0x74, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x63, 0x68, 0x61, 0x72, 0x74, 0x41, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x41, 0x0a, 0x11, 0x65, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, + 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x11, 0x65, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x3e, + 0x0a, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x12, 0x22, + 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x22, 0x72, 0x0a, 0x12, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xcd, 0x01, 0x0a, 0x10, 0x41, 0x70, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x43, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, + 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x52, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, + 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x22, 0x99, 0x03, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x65, 0x64, 0x22, 0x63, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, + 0x75, 0x73, 0x12, 0x34, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3e, 0x0a, 0x0c, 0x6c, 0x61, 0x73, 0x74, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x68, 0x61, 0x72, + 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, + 0x0d, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x49, + 0x0a, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x52, 0x14, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x12, 0x65, 0x6e, 0x76, + 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, + 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x12, 0x65, 0x6e, 0x76, 0x69, + 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x22, + 0x0a, 0x0c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x45, 0x78, 0x69, 0x73, 0x74, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x45, 0x78, 0x69, + 0x73, 0x74, 0x22, 0xc1, 0x01, 0x0a, 0x09, 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x2c, 0x0a, 0x11, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x61, 0x70, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, + 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x0a, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, + 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x44, 0x65, + 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x22, 0x63, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb7, 0x01, 0x0a, 0x0d, + 0x43, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, + 0x09, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x63, + 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, + 0x6f, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x20, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x6b, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, + 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, + 0x65, 0x73, 0x12, 0x2e, 0x0a, 0x0b, 0x70, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0b, 0x70, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x22, 0xa9, 0x04, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, + 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x0a, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x66, 0x52, 0x0a, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x66, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x17, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x06, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x22, 0x0a, 0x0c, 0x69, + 0x73, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0c, 0x69, 0x73, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, + 0x28, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x42, 0x65, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, + 0x65, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x63, 0x61, 0x6e, 0x42, 0x65, 0x48, + 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x69, 0x6e, 0x66, + 0x6f, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x74, + 0x65, 0x6d, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x0f, + 0x20, 0x03, 0x28, 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, + 0x48, 0x6f, 0x6f, 0x6b, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x48, 0x6f, + 0x6f, 0x6b, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x6f, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x11, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x6f, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0x34, + 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0x40, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xb7, 0x01, 0x0a, 0x0d, 0x43, 0x68, 0x61, - 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, - 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, - 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, - 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x68, 0x6f, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x07, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, - 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x74, - 0x65, 0x73, 0x22, 0x6b, 0x0a, 0x14, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, - 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x6e, 0x6f, - 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, - 0x2e, 0x0a, 0x0b, 0x70, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x52, 0x0b, 0x70, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, - 0xa9, 0x04, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x0a, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x66, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x66, 0x73, 0x12, 0x3f, 0x0a, 0x0e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, - 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0e, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x25, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x06, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x12, 0x22, 0x0a, 0x0c, 0x69, 0x73, 0x48, 0x69, - 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, - 0x69, 0x73, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, 0x28, 0x0a, 0x0f, - 0x63, 0x61, 0x6e, 0x42, 0x65, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x63, 0x61, 0x6e, 0x42, 0x65, 0x48, 0x69, 0x62, 0x65, - 0x72, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x0d, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x74, 0x65, 0x6d, 0x52, - 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, - 0x41, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x41, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x0f, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x48, 0x6f, 0x6f, - 0x6b, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x48, 0x6f, 0x6f, 0x6b, 0x12, - 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x6f, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x68, 0x6f, 0x6f, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0x34, 0x0a, 0x08, 0x49, - 0x6e, 0x66, 0x6f, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x22, 0x40, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x3b, - 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, - 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, - 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x95, 0x01, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, - 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, - 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0xdc, - 0x01, 0x0a, 0x0b, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, - 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, - 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x69, 0x6e, - 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, - 0x69, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x4e, - 0x65, 0x77, 0x12, 0x49, 0x0a, 0x13, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, - 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x17, 0x2e, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x61, - 0x69, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x13, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, - 0x72, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x22, 0x4c, 0x0a, - 0x16, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, - 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, - 0x73, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0a, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x87, 0x01, 0x0a, 0x10, - 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3d, 0x0a, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x11, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, - 0x69, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0x88, 0x01, 0x0a, 0x10, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x22, 0x7e, 0x0a, 0x0f, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x4f, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x0c, 0x74, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, - 0x22, 0x3d, 0x0a, 0x11, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, - 0x81, 0x02, 0x0a, 0x17, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x34, 0x0a, 0x0d, 0x63, - 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x52, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x3a, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x64, - 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x42, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x42, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x22, 0x62, 0x0a, 0x18, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, - 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, - 0x46, 0x0a, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, - 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x48, 0x65, 0x6c, - 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x85, 0x02, 0x0a, 0x0b, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, - 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, - 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x66, - 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, - 0x26, 0x0a, 0x0e, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, - 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, - 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, - 0x65, 0x72, 0x67, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, - 0x65, 0x61, 0x64, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, - 0x64, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x4a, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4a, 0x73, 0x6f, 0x6e, 0x22, - 0xd2, 0x01, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3d, 0x0a, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x11, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x22, 0x35, 0x0a, 0x17, 0x44, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x4d, - 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0x34, 0x0a, 0x18, 0x55, - 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x22, 0x97, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, - 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, - 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, - 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xe8, 0x01, 0x0a, 0x15, - 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x69, 0x73, 0x74, 0x6f, - 0x72, 0x79, 0x4d, 0x61, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x68, 0x69, 0x73, - 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, - 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x63, 0x68, - 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x75, - 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x52, 0x75, - 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x22, 0x32, 0x0a, 0x16, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, - 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x17, 0x44, - 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x11, 0x64, 0x65, 0x70, 0x6c, - 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x56, 0x0a, 0x18, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x3b, 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x23, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, + 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x95, 0x01, 0x0a, 0x0b, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, + 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1c, 0x0a, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, + 0x64, 0x22, 0xdc, 0x01, 0x0a, 0x0b, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x61, + 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x43, + 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0e, 0x69, 0x6e, 0x69, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x12, + 0x14, 0x0a, 0x05, 0x69, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, + 0x69, 0x73, 0x4e, 0x65, 0x77, 0x12, 0x49, 0x0a, 0x13, 0x65, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, + 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, 0x6f, + 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x13, 0x65, 0x70, 0x68, + 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, + 0x22, 0x4c, 0x0a, 0x16, 0x45, 0x70, 0x68, 0x65, 0x6d, 0x65, 0x72, 0x61, 0x6c, 0x43, 0x6f, 0x6e, + 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x87, + 0x01, 0x0a, 0x10, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3d, 0x0a, 0x10, 0x6f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0x88, 0x01, 0x0a, 0x10, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x14, 0x0a, + 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x22, 0x7e, 0x0a, 0x0f, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x35, 0x0a, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, + 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x4d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x4d, 0x73, 0x67, 0x22, 0x3d, 0x0a, 0x11, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, + 0x6e, 0x61, 0x74, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x22, 0x81, 0x02, 0x0a, 0x17, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, + 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x34, + 0x0a, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x0d, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x6f, 0x63, 0x6b, 0x65, 0x72, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x6f, 0x63, 0x6b, + 0x65, 0x72, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x3a, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1e, + 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x42, 0x79, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x42, 0x79, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x62, 0x0a, 0x18, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, + 0x70, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, + 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x85, 0x02, 0x0a, 0x0b, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x40, 0x0a, 0x11, 0x64, 0x65, + 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, + 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, + 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x24, 0x0a, 0x0d, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, + 0x72, 0x67, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x72, 0x65, 0x61, 0x64, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4a, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x10, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x4a, 0x73, + 0x6f, 0x6e, 0x22, 0xd2, 0x01, 0x0a, 0x0d, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3d, 0x0a, 0x10, 0x6f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x35, 0x0a, 0x17, 0x44, 0x65, 0x73, 0x69, 0x72, + 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x1e, - 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x22, 0x6f, - 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, - 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, - 0x8d, 0x04, 0x0a, 0x15, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x09, 0x63, - 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x68, 0x61, - 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, - 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x3a, 0x0a, - 0x0f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x0f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x52, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x4b, 0x38, 0x73, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x4b, - 0x38, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x69, 0x73, - 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x68, - 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x43, 0x0a, 0x12, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x12, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x1c, - 0x0a, 0x09, 0x49, 0x73, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x70, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x09, 0x49, 0x73, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x70, 0x6f, 0x12, 0x3e, 0x0a, 0x1a, - 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x41, 0x70, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x1a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x41, 0x70, 0x70, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x31, 0x0a, 0x0c, - 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x74, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, - 0x32, 0x0a, 0x16, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x22, 0x29, 0x0a, 0x0f, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x74, - 0x0a, 0x16, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0x34, + 0x0a, 0x18, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x22, 0x97, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x0d, 0x63, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x0d, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x10, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x72, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0xe8, + 0x01, 0x0a, 0x15, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x45, 0x0a, 0x15, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, - 0x11, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, - 0x74, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0xcb, 0x01, 0x0a, 0x18, - 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, - 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, - 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, - 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x63, - 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, + 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x69, + 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, + 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x31, 0x0a, 0x0c, 0x63, 0x68, + 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0d, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, + 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x22, 0x32, 0x0a, 0x16, 0x55, 0x70, 0x67, + 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x89, 0x01, + 0x0a, 0x17, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x11, 0x64, + 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x56, 0x0a, 0x18, 0x44, 0x65, 0x70, + 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, + 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, + 0x6c, 0x22, 0x6f, 0x0a, 0x0f, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, + 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, + 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, + 0x72, 0x64, 0x22, 0x8d, 0x04, 0x0a, 0x15, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, + 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1c, + 0x0a, 0x09, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x63, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, + 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x1e, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, + 0x12, 0x3a, 0x0a, 0x0f, 0x63, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x43, 0x68, 0x61, 0x72, + 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x0f, 0x63, 0x68, 0x61, + 0x72, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1e, 0x0a, 0x0a, + 0x4b, 0x38, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x4b, 0x38, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, + 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0a, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x43, 0x0a, 0x12, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x61, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x12, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, + 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x73, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x70, 0x6f, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x49, 0x73, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x70, 0x6f, 0x12, + 0x3e, 0x0a, 0x1a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x41, 0x70, 0x70, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x1a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x41, 0x70, 0x70, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, + 0x31, 0x0a, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x16, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, + 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x29, 0x0a, 0x0f, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x22, 0x74, 0x0a, 0x16, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x1a, 0x0a, - 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x22, 0x35, 0x0a, 0x19, 0x48, 0x65, 0x6c, - 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x22, 0x28, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, - 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x49, 0x0a, 0x03, 0x47, 0x76, - 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x22, 0x6d, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x03, 0x67, 0x76, 0x6b, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x04, 0x2e, 0x47, 0x76, 0x6b, 0x52, 0x03, 0x67, 0x76, 0x6b, 0x12, - 0x43, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x52, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x66, 0x69, 0x65, 0x72, 0x22, 0x88, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x06, 0x6c, - 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, - 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x6c, 0x61, - 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x88, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, - 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0c, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, - 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, - 0x72, 0x52, 0x0c, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, - 0x39, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, - 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x22, 0x2a, 0x0a, 0x12, 0x43, 0x68, - 0x61, 0x72, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0xa4, 0x02, 0x0a, 0x12, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x12, 0x20, 0x0a, - 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x55, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x55, 0x72, 0x6c, 0x12, - 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x41, 0x77, 0x73, 0x52, 0x65, - 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x41, 0x77, 0x73, 0x52, - 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, - 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, - 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x65, 0x70, 0x6f, 0x4e, 0x61, 0x6d, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x52, 0x65, 0x70, 0x6f, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x08, 0x49, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x22, 0x35, 0x0a, - 0x13, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x73, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x64, - 0x49, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x49, 0x73, 0x4c, 0x6f, 0x67, 0x67, - 0x65, 0x64, 0x49, 0x6e, 0x32, 0x98, 0x0b, 0x0a, 0x12, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x4c, - 0x69, 0x73, 0x74, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x0f, 0x2e, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x10, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x4c, 0x69, - 0x73, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x2f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, 0x70, 0x70, - 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x41, 0x70, 0x70, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, 0x70, - 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x41, 0x70, 0x70, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x48, 0x69, 0x62, 0x65, - 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, - 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, - 0x0a, 0x0b, 0x55, 0x6e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, - 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x11, - 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x00, 0x12, 0x32, - 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, - 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, - 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x2e, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x44, 0x65, 0x73, 0x69, 0x72, - 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x10, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x19, 0x2e, 0x55, - 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x55, 0x70, - 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, - 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x19, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, - 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, - 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, - 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x50, 0x0a, 0x1b, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x68, 0x61, 0x72, 0x74, 0x49, 0x6e, 0x66, 0x6f, + 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x45, 0x0a, 0x15, 0x54, 0x65, 0x6d, 0x70, 0x6c, + 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x2c, 0x0a, 0x11, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x6e, + 0x69, 0x66, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x67, 0x65, 0x6e, + 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x22, 0xcb, + 0x01, 0x0a, 0x18, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, + 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x31, 0x0a, 0x0c, 0x63, + 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x52, 0x0c, 0x63, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x40, + 0x0a, 0x11, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x52, 0x11, 0x72, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, + 0x12, 0x1a, 0x0a, 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x08, 0x52, 0x75, 0x6e, 0x49, 0x6e, 0x43, 0x74, 0x78, 0x22, 0x35, 0x0a, 0x19, + 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x22, 0x28, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x49, 0x0a, + 0x03, 0x47, 0x76, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x4b, 0x69, 0x6e, 0x64, 0x22, 0x6d, 0x0a, 0x0e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x03, 0x67, 0x76, + 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x04, 0x2e, 0x47, 0x76, 0x6b, 0x52, 0x03, 0x67, + 0x76, 0x6b, 0x12, 0x43, 0x0a, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x52, 0x12, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0x88, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x37, + 0x0a, 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x06, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x4c, 0x61, 0x62, 0x65, 0x6c, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x88, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, + 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x37, 0x0a, 0x0c, 0x67, 0x6c, 0x6f, + 0x62, 0x61, 0x6c, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x13, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x52, 0x0c, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x12, 0x39, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0f, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x22, 0x2a, 0x0a, + 0x12, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x6e, 0x6f, 0x74, 0x65, 0x73, 0x22, 0xd1, 0x01, 0x0a, 0x12, 0x4f, 0x43, + 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x05, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x43, 0x68, 0x61, 0x72, 0x74, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x68, 0x61, 0x72, 0x74, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x68, 0x61, 0x72, + 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x73, 0x49, 0x6e, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x49, 0x73, + 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x43, 0x0a, 0x12, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, + 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x52, 0x12, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x22, 0xa4, 0x02, + 0x0a, 0x12, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x61, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x55, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1c, + 0x0a, 0x09, 0x41, 0x77, 0x73, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x41, 0x77, 0x73, 0x52, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, + 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, + 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x53, + 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x52, 0x65, 0x70, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x52, 0x65, 0x70, 0x6f, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x73, 0x50, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x49, 0x73, 0x50, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x22, 0x6f, 0x0a, 0x13, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x49, + 0x73, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x64, 0x49, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0a, 0x49, 0x73, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x64, 0x49, 0x6e, 0x12, 0x38, 0x0a, 0x0a, 0x50, + 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x18, 0x2e, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x75, 0x73, + 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x50, 0x75, 0x73, 0x68, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x4f, 0x0a, 0x17, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x75, 0x73, 0x68, + 0x65, 0x64, 0x55, 0x52, 0x4c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x75, 0x73, + 0x68, 0x65, 0x64, 0x55, 0x52, 0x4c, 0x32, 0xe3, 0x0b, 0x0a, 0x12, 0x41, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, + 0x10, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x0f, 0x2e, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, + 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x2f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, + 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x41, 0x70, + 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x0c, 0x47, 0x65, 0x74, + 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x41, + 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x48, 0x69, + 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, + 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, + 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x36, 0x0a, 0x0b, 0x55, 0x6e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, + 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x44, + 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, + 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, + 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x00, + 0x12, 0x32, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, + 0x6c, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x6e, + 0x66, 0x6f, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, 0x73, 0x69, 0x72, + 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x2e, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x44, 0x65, 0x73, + 0x69, 0x72, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x10, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x19, + 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x55, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, + 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x4c, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x19, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, + 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x12, 0x49, 0x73, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x10, 0x2e, - 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, - 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x41, 0x0a, 0x0d, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, - 0x72, 0x74, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, 0x65, 0x6d, - 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, - 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, - 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x1a, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, - 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x39, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x1d, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, - 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, - 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, - 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x1a, 0x14, 0x2e, 0x4f, 0x43, 0x49, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x5c, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x54, 0x72, 0x65, 0x65, 0x46, 0x6f, 0x72, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x65, - 0x76, 0x74, 0x72, 0x6f, 0x6e, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x6c, - 0x69, 0x6e, 0x6b, 0x2f, 0x62, 0x65, 0x61, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x1b, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x68, 0x61, 0x72, 0x74, 0x49, 0x6e, + 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, + 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x12, 0x49, 0x73, 0x52, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x12, 0x2e, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, + 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0d, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, + 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, + 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, + 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x73, 0x74, + 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, + 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x39, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x49, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x6f, 0x74, 0x65, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x1d, 0x55, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, + 0x68, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x55, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x49, 0x0a, 0x1a, 0x50, 0x75, 0x73, 0x68, 0x48, 0x65, 0x6c, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, + 0x54, 0x6f, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x13, 0x2e, + 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x13, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x12, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x1a, 0x14, 0x2e, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, + 0x0a, 0x23, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, + 0x65, 0x46, 0x6f, 0x72, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, + 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x33, 0x5a, 0x31, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x65, 0x76, 0x74, 0x72, + 0x6f, 0x6e, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x6c, 0x69, 0x6e, 0x6b, + 0x2f, 0x62, 0x65, 0x61, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_api_helm_app_gRPC_applist_proto_rawDescOnce sync.Once - file_api_helm_app_gRPC_applist_proto_rawDescData = file_api_helm_app_gRPC_applist_proto_rawDesc + file_api_helm_app_gRPC_client_applist_proto_rawDescOnce sync.Once + file_api_helm_app_gRPC_client_applist_proto_rawDescData = file_api_helm_app_gRPC_client_applist_proto_rawDesc ) -func file_api_helm_app_gRPC_applist_proto_rawDescGZIP() []byte { - file_api_helm_app_gRPC_applist_proto_rawDescOnce.Do(func() { - file_api_helm_app_gRPC_applist_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_helm_app_gRPC_applist_proto_rawDescData) +func file_api_helm_app_gRPC_client_applist_proto_rawDescGZIP() []byte { + file_api_helm_app_gRPC_client_applist_proto_rawDescOnce.Do(func() { + file_api_helm_app_gRPC_client_applist_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_helm_app_gRPC_client_applist_proto_rawDescData) }) - return file_api_helm_app_gRPC_applist_proto_rawDescData + return file_api_helm_app_gRPC_client_applist_proto_rawDescData } -var file_api_helm_app_gRPC_applist_proto_msgTypes = make([]protoimpl.MessageInfo, 53) -var file_api_helm_app_gRPC_applist_proto_goTypes = []interface{}{ +var file_api_helm_app_gRPC_client_applist_proto_msgTypes = make([]protoimpl.MessageInfo, 55) +var file_api_helm_app_gRPC_client_applist_proto_goTypes = []interface{}{ (*ClusterConfig)(nil), // 0: ClusterConfig (*AppListRequest)(nil), // 1: AppListRequest (*ExternalResourceTreeRequest)(nil), // 2: ExternalResourceTreeRequest @@ -4111,41 +4345,43 @@ var file_api_helm_app_gRPC_applist_proto_goTypes = []interface{}{ (*ResourceIdentifier)(nil), // 46: ResourceIdentifier (*ResourceTreeFilter)(nil), // 47: ResourceTreeFilter (*ChartNotesResponse)(nil), // 48: ChartNotesResponse - (*RegistryCredential)(nil), // 49: RegistryCredential - (*OCIRegistryResponse)(nil), // 50: OCIRegistryResponse - nil, // 51: ResourceNetworkingInfo.LabelsEntry - nil, // 52: ResourceIdentifier.LabelsEntry - (*timestamp.Timestamp)(nil), // 53: google.protobuf.Timestamp -} -var file_api_helm_app_gRPC_applist_proto_depIdxs = []int32{ + (*OCIRegistryRequest)(nil), // 49: OCIRegistryRequest + (*RegistryCredential)(nil), // 50: RegistryCredential + (*OCIRegistryResponse)(nil), // 51: OCIRegistryResponse + (*OCIRegistryPushResponse)(nil), // 52: OCIRegistryPushResponse + nil, // 53: ResourceNetworkingInfo.LabelsEntry + nil, // 54: ResourceIdentifier.LabelsEntry + (*timestamp.Timestamp)(nil), // 55: google.protobuf.Timestamp +} +var file_api_helm_app_gRPC_client_applist_proto_depIdxs = []int32{ 0, // 0: AppListRequest.clusters:type_name -> ClusterConfig 0, // 1: ExternalResourceTreeRequest.clusterConfig:type_name -> ClusterConfig 3, // 2: ExternalResourceTreeRequest.externalResourceDetail:type_name -> ExternalResourceDetail 5, // 3: DeployedAppList.DeployedAppDetail:type_name -> DeployedAppDetail 6, // 4: DeployedAppDetail.environmentDetail:type_name -> EnvironmentDetails - 53, // 5: DeployedAppDetail.LastDeployed:type_name -> google.protobuf.Timestamp + 55, // 5: DeployedAppDetail.LastDeployed:type_name -> google.protobuf.Timestamp 0, // 6: AppDetailRequest.clusterConfig:type_name -> ClusterConfig 47, // 7: AppDetailRequest.resourceTreeFilter:type_name -> ResourceTreeFilter 10, // 8: AppDetail.releaseStatus:type_name -> ReleaseStatus - 53, // 9: AppDetail.lastDeployed:type_name -> google.protobuf.Timestamp + 55, // 9: AppDetail.lastDeployed:type_name -> google.protobuf.Timestamp 11, // 10: AppDetail.chartMetadata:type_name -> ChartMetadata 12, // 11: AppDetail.resourceTreeResponse:type_name -> ResourceTreeResponse 6, // 12: AppDetail.environmentDetails:type_name -> EnvironmentDetails - 53, // 13: AppStatus.LastDeployed:type_name -> google.protobuf.Timestamp + 55, // 13: AppStatus.LastDeployed:type_name -> google.protobuf.Timestamp 13, // 14: ResourceTreeResponse.nodes:type_name -> ResourceNode 18, // 15: ResourceTreeResponse.podMetadata:type_name -> PodMetadata 17, // 16: ResourceNode.parentRefs:type_name -> ResourceRef 16, // 17: ResourceNode.networkingInfo:type_name -> ResourceNetworkingInfo 15, // 18: ResourceNode.health:type_name -> HealthStatus 14, // 19: ResourceNode.info:type_name -> InfoItem - 51, // 20: ResourceNetworkingInfo.labels:type_name -> ResourceNetworkingInfo.LabelsEntry + 53, // 20: ResourceNetworkingInfo.labels:type_name -> ResourceNetworkingInfo.LabelsEntry 19, // 21: PodMetadata.ephemeralContainers:type_name -> EphemeralContainerData 0, // 22: HibernateRequest.clusterConfig:type_name -> ClusterConfig 21, // 23: HibernateRequest.objectIdentifier:type_name -> ObjectIdentifier 21, // 24: HibernateStatus.targetObject:type_name -> ObjectIdentifier 22, // 25: HibernateResponse.status:type_name -> HibernateStatus 11, // 26: HelmAppDeploymentDetail.chartMetadata:type_name -> ChartMetadata - 53, // 27: HelmAppDeploymentDetail.deployedAt:type_name -> google.protobuf.Timestamp + 55, // 27: HelmAppDeploymentDetail.deployedAt:type_name -> google.protobuf.Timestamp 24, // 28: HelmAppDeploymentHistory.deploymentHistory:type_name -> HelmAppDeploymentDetail 5, // 29: ReleaseInfo.deployedAppDetail:type_name -> DeployedAppDetail 0, // 30: ObjectRequest.clusterConfig:type_name -> ClusterConfig @@ -4156,72 +4392,76 @@ var file_api_helm_app_gRPC_applist_proto_depIdxs = []int32{ 30, // 35: DeploymentDetailRequest.releaseIdentifier:type_name -> ReleaseIdentifier 30, // 36: InstallReleaseRequest.releaseIdentifier:type_name -> ReleaseIdentifier 35, // 37: InstallReleaseRequest.chartRepository:type_name -> ChartRepository - 49, // 38: InstallReleaseRequest.RegistryCredential:type_name -> RegistryCredential + 50, // 38: InstallReleaseRequest.RegistryCredential:type_name -> RegistryCredential 43, // 39: InstallReleaseRequest.chartContent:type_name -> ChartContent 30, // 40: RollbackReleaseRequest.releaseIdentifier:type_name -> ReleaseIdentifier 43, // 41: HelmInstallCustomRequest.chartContent:type_name -> ChartContent 30, // 42: HelmInstallCustomRequest.releaseIdentifier:type_name -> ReleaseIdentifier 44, // 43: ResourceFilter.gvk:type_name -> Gvk 46, // 44: ResourceFilter.resourceIdentifier:type_name -> ResourceIdentifier - 52, // 45: ResourceIdentifier.labels:type_name -> ResourceIdentifier.LabelsEntry + 54, // 45: ResourceIdentifier.labels:type_name -> ResourceIdentifier.LabelsEntry 46, // 46: ResourceTreeFilter.globalFilter:type_name -> ResourceIdentifier 45, // 47: ResourceTreeFilter.resourceFilters:type_name -> ResourceFilter - 1, // 48: ApplicationService.ListApplications:input_type -> AppListRequest - 7, // 49: ApplicationService.GetAppDetail:input_type -> AppDetailRequest - 7, // 50: ApplicationService.GetAppStatus:input_type -> AppDetailRequest - 20, // 51: ApplicationService.Hibernate:input_type -> HibernateRequest - 20, // 52: ApplicationService.UnHibernate:input_type -> HibernateRequest - 7, // 53: ApplicationService.GetDeploymentHistory:input_type -> AppDetailRequest - 7, // 54: ApplicationService.GetValuesYaml:input_type -> AppDetailRequest - 27, // 55: ApplicationService.GetDesiredManifest:input_type -> ObjectRequest - 30, // 56: ApplicationService.UninstallRelease:input_type -> ReleaseIdentifier - 31, // 57: ApplicationService.UpgradeRelease:input_type -> UpgradeReleaseRequest - 33, // 58: ApplicationService.GetDeploymentDetail:input_type -> DeploymentDetailRequest - 36, // 59: ApplicationService.InstallRelease:input_type -> InstallReleaseRequest - 36, // 60: ApplicationService.UpgradeReleaseWithChartInfo:input_type -> InstallReleaseRequest - 30, // 61: ApplicationService.IsReleaseInstalled:input_type -> ReleaseIdentifier - 39, // 62: ApplicationService.RollbackRelease:input_type -> RollbackReleaseRequest - 36, // 63: ApplicationService.TemplateChart:input_type -> InstallReleaseRequest - 41, // 64: ApplicationService.InstallReleaseWithCustomChart:input_type -> HelmInstallCustomRequest - 36, // 65: ApplicationService.GetNotes:input_type -> InstallReleaseRequest - 31, // 66: ApplicationService.UpgradeReleaseWithCustomChart:input_type -> UpgradeReleaseRequest - 49, // 67: ApplicationService.ValidateOCIRegistry:input_type -> RegistryCredential - 2, // 68: ApplicationService.GetResourceTreeForExternalResources:input_type -> ExternalResourceTreeRequest - 4, // 69: ApplicationService.ListApplications:output_type -> DeployedAppList - 8, // 70: ApplicationService.GetAppDetail:output_type -> AppDetail - 9, // 71: ApplicationService.GetAppStatus:output_type -> AppStatus - 23, // 72: ApplicationService.Hibernate:output_type -> HibernateResponse - 23, // 73: ApplicationService.UnHibernate:output_type -> HibernateResponse - 25, // 74: ApplicationService.GetDeploymentHistory:output_type -> HelmAppDeploymentHistory - 26, // 75: ApplicationService.GetValuesYaml:output_type -> ReleaseInfo - 28, // 76: ApplicationService.GetDesiredManifest:output_type -> DesiredManifestResponse - 29, // 77: ApplicationService.UninstallRelease:output_type -> UninstallReleaseResponse - 32, // 78: ApplicationService.UpgradeRelease:output_type -> UpgradeReleaseResponse - 34, // 79: ApplicationService.GetDeploymentDetail:output_type -> DeploymentDetailResponse - 37, // 80: ApplicationService.InstallRelease:output_type -> InstallReleaseResponse - 32, // 81: ApplicationService.UpgradeReleaseWithChartInfo:output_type -> UpgradeReleaseResponse - 38, // 82: ApplicationService.IsReleaseInstalled:output_type -> BooleanResponse - 38, // 83: ApplicationService.RollbackRelease:output_type -> BooleanResponse - 40, // 84: ApplicationService.TemplateChart:output_type -> TemplateChartResponse - 42, // 85: ApplicationService.InstallReleaseWithCustomChart:output_type -> HelmInstallCustomResponse - 48, // 86: ApplicationService.GetNotes:output_type -> ChartNotesResponse - 32, // 87: ApplicationService.UpgradeReleaseWithCustomChart:output_type -> UpgradeReleaseResponse - 50, // 88: ApplicationService.ValidateOCIRegistry:output_type -> OCIRegistryResponse - 12, // 89: ApplicationService.GetResourceTreeForExternalResources:output_type -> ResourceTreeResponse - 69, // [69:90] is the sub-list for method output_type - 48, // [48:69] is the sub-list for method input_type - 48, // [48:48] is the sub-list for extension type_name - 48, // [48:48] is the sub-list for extension extendee - 0, // [0:48] is the sub-list for field type_name -} - -func init() { file_api_helm_app_gRPC_applist_proto_init() } -func file_api_helm_app_gRPC_applist_proto_init() { - if File_api_helm_app_gRPC_applist_proto != nil { + 50, // 48: OCIRegistryRequest.RegistryCredential:type_name -> RegistryCredential + 52, // 49: OCIRegistryResponse.PushResult:type_name -> OCIRegistryPushResponse + 1, // 50: ApplicationService.ListApplications:input_type -> AppListRequest + 7, // 51: ApplicationService.GetAppDetail:input_type -> AppDetailRequest + 7, // 52: ApplicationService.GetAppStatus:input_type -> AppDetailRequest + 20, // 53: ApplicationService.Hibernate:input_type -> HibernateRequest + 20, // 54: ApplicationService.UnHibernate:input_type -> HibernateRequest + 7, // 55: ApplicationService.GetDeploymentHistory:input_type -> AppDetailRequest + 7, // 56: ApplicationService.GetValuesYaml:input_type -> AppDetailRequest + 27, // 57: ApplicationService.GetDesiredManifest:input_type -> ObjectRequest + 30, // 58: ApplicationService.UninstallRelease:input_type -> ReleaseIdentifier + 31, // 59: ApplicationService.UpgradeRelease:input_type -> UpgradeReleaseRequest + 33, // 60: ApplicationService.GetDeploymentDetail:input_type -> DeploymentDetailRequest + 36, // 61: ApplicationService.InstallRelease:input_type -> InstallReleaseRequest + 36, // 62: ApplicationService.UpgradeReleaseWithChartInfo:input_type -> InstallReleaseRequest + 30, // 63: ApplicationService.IsReleaseInstalled:input_type -> ReleaseIdentifier + 39, // 64: ApplicationService.RollbackRelease:input_type -> RollbackReleaseRequest + 36, // 65: ApplicationService.TemplateChart:input_type -> InstallReleaseRequest + 41, // 66: ApplicationService.InstallReleaseWithCustomChart:input_type -> HelmInstallCustomRequest + 36, // 67: ApplicationService.GetNotes:input_type -> InstallReleaseRequest + 31, // 68: ApplicationService.UpgradeReleaseWithCustomChart:input_type -> UpgradeReleaseRequest + 49, // 69: ApplicationService.PushHelmChartToOCIRegistry:input_type -> OCIRegistryRequest + 50, // 70: ApplicationService.ValidateOCIRegistry:input_type -> RegistryCredential + 2, // 71: ApplicationService.GetResourceTreeForExternalResources:input_type -> ExternalResourceTreeRequest + 4, // 72: ApplicationService.ListApplications:output_type -> DeployedAppList + 8, // 73: ApplicationService.GetAppDetail:output_type -> AppDetail + 9, // 74: ApplicationService.GetAppStatus:output_type -> AppStatus + 23, // 75: ApplicationService.Hibernate:output_type -> HibernateResponse + 23, // 76: ApplicationService.UnHibernate:output_type -> HibernateResponse + 25, // 77: ApplicationService.GetDeploymentHistory:output_type -> HelmAppDeploymentHistory + 26, // 78: ApplicationService.GetValuesYaml:output_type -> ReleaseInfo + 28, // 79: ApplicationService.GetDesiredManifest:output_type -> DesiredManifestResponse + 29, // 80: ApplicationService.UninstallRelease:output_type -> UninstallReleaseResponse + 32, // 81: ApplicationService.UpgradeRelease:output_type -> UpgradeReleaseResponse + 34, // 82: ApplicationService.GetDeploymentDetail:output_type -> DeploymentDetailResponse + 37, // 83: ApplicationService.InstallRelease:output_type -> InstallReleaseResponse + 32, // 84: ApplicationService.UpgradeReleaseWithChartInfo:output_type -> UpgradeReleaseResponse + 38, // 85: ApplicationService.IsReleaseInstalled:output_type -> BooleanResponse + 38, // 86: ApplicationService.RollbackRelease:output_type -> BooleanResponse + 40, // 87: ApplicationService.TemplateChart:output_type -> TemplateChartResponse + 42, // 88: ApplicationService.InstallReleaseWithCustomChart:output_type -> HelmInstallCustomResponse + 48, // 89: ApplicationService.GetNotes:output_type -> ChartNotesResponse + 32, // 90: ApplicationService.UpgradeReleaseWithCustomChart:output_type -> UpgradeReleaseResponse + 51, // 91: ApplicationService.PushHelmChartToOCIRegistry:output_type -> OCIRegistryResponse + 51, // 92: ApplicationService.ValidateOCIRegistry:output_type -> OCIRegistryResponse + 12, // 93: ApplicationService.GetResourceTreeForExternalResources:output_type -> ResourceTreeResponse + 72, // [72:94] is the sub-list for method output_type + 50, // [50:72] is the sub-list for method input_type + 50, // [50:50] is the sub-list for extension type_name + 50, // [50:50] is the sub-list for extension extendee + 0, // [0:50] is the sub-list for field type_name +} + +func init() { file_api_helm_app_gRPC_client_applist_proto_init() } +func file_api_helm_app_gRPC_client_applist_proto_init() { + if File_api_helm_app_gRPC_client_applist_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_api_helm_app_gRPC_applist_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ClusterConfig); i { case 0: return &v.state @@ -4233,7 +4473,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AppListRequest); i { case 0: return &v.state @@ -4245,7 +4485,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ExternalResourceTreeRequest); i { case 0: return &v.state @@ -4257,7 +4497,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ExternalResourceDetail); i { case 0: return &v.state @@ -4269,7 +4509,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeployedAppList); i { case 0: return &v.state @@ -4281,7 +4521,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeployedAppDetail); i { case 0: return &v.state @@ -4293,7 +4533,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*EnvironmentDetails); i { case 0: return &v.state @@ -4305,7 +4545,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AppDetailRequest); i { case 0: return &v.state @@ -4317,7 +4557,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AppDetail); i { case 0: return &v.state @@ -4329,7 +4569,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AppStatus); i { case 0: return &v.state @@ -4341,7 +4581,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ReleaseStatus); i { case 0: return &v.state @@ -4353,7 +4593,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChartMetadata); i { case 0: return &v.state @@ -4365,7 +4605,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceTreeResponse); i { case 0: return &v.state @@ -4377,7 +4617,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceNode); i { case 0: return &v.state @@ -4389,7 +4629,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InfoItem); i { case 0: return &v.state @@ -4401,7 +4641,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HealthStatus); i { case 0: return &v.state @@ -4413,7 +4653,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceNetworkingInfo); i { case 0: return &v.state @@ -4425,7 +4665,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceRef); i { case 0: return &v.state @@ -4437,7 +4677,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PodMetadata); i { case 0: return &v.state @@ -4449,7 +4689,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*EphemeralContainerData); i { case 0: return &v.state @@ -4461,7 +4701,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HibernateRequest); i { case 0: return &v.state @@ -4473,7 +4713,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ObjectIdentifier); i { case 0: return &v.state @@ -4485,7 +4725,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HibernateStatus); i { case 0: return &v.state @@ -4497,7 +4737,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HibernateResponse); i { case 0: return &v.state @@ -4509,7 +4749,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[24].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelmAppDeploymentDetail); i { case 0: return &v.state @@ -4521,7 +4761,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[25].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelmAppDeploymentHistory); i { case 0: return &v.state @@ -4533,7 +4773,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[26].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ReleaseInfo); i { case 0: return &v.state @@ -4545,7 +4785,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ObjectRequest); i { case 0: return &v.state @@ -4557,7 +4797,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DesiredManifestResponse); i { case 0: return &v.state @@ -4569,7 +4809,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UninstallReleaseResponse); i { case 0: return &v.state @@ -4581,7 +4821,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ReleaseIdentifier); i { case 0: return &v.state @@ -4593,7 +4833,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpgradeReleaseRequest); i { case 0: return &v.state @@ -4605,7 +4845,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpgradeReleaseResponse); i { case 0: return &v.state @@ -4617,7 +4857,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[33].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeploymentDetailRequest); i { case 0: return &v.state @@ -4629,7 +4869,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DeploymentDetailResponse); i { case 0: return &v.state @@ -4641,7 +4881,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChartRepository); i { case 0: return &v.state @@ -4653,7 +4893,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstallReleaseRequest); i { case 0: return &v.state @@ -4665,7 +4905,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*InstallReleaseResponse); i { case 0: return &v.state @@ -4677,7 +4917,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*BooleanResponse); i { case 0: return &v.state @@ -4689,7 +4929,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RollbackReleaseRequest); i { case 0: return &v.state @@ -4701,7 +4941,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TemplateChartResponse); i { case 0: return &v.state @@ -4713,7 +4953,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelmInstallCustomRequest); i { case 0: return &v.state @@ -4725,7 +4965,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[42].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*HelmInstallCustomResponse); i { case 0: return &v.state @@ -4737,7 +4977,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[43].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChartContent); i { case 0: return &v.state @@ -4749,7 +4989,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[44].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Gvk); i { case 0: return &v.state @@ -4761,7 +5001,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[45].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceFilter); i { case 0: return &v.state @@ -4773,7 +5013,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[46].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceIdentifier); i { case 0: return &v.state @@ -4785,7 +5025,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[47].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ResourceTreeFilter); i { case 0: return &v.state @@ -4797,7 +5037,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[48].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ChartNotesResponse); i { case 0: return &v.state @@ -4809,7 +5049,19 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[49].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OCIRegistryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_helm_app_gRPC_client_applist_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*RegistryCredential); i { case 0: return &v.state @@ -4821,7 +5073,7 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } - file_api_helm_app_gRPC_applist_proto_msgTypes[50].Exporter = func(v interface{}, i int) interface{} { + file_api_helm_app_gRPC_client_applist_proto_msgTypes[51].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*OCIRegistryResponse); i { case 0: return &v.state @@ -4833,23 +5085,35 @@ func file_api_helm_app_gRPC_applist_proto_init() { return nil } } + file_api_helm_app_gRPC_client_applist_proto_msgTypes[52].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OCIRegistryPushResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_helm_app_gRPC_applist_proto_rawDesc, + RawDescriptor: file_api_helm_app_gRPC_client_applist_proto_rawDesc, NumEnums: 0, - NumMessages: 53, + NumMessages: 55, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_api_helm_app_gRPC_applist_proto_goTypes, - DependencyIndexes: file_api_helm_app_gRPC_applist_proto_depIdxs, - MessageInfos: file_api_helm_app_gRPC_applist_proto_msgTypes, + GoTypes: file_api_helm_app_gRPC_client_applist_proto_goTypes, + DependencyIndexes: file_api_helm_app_gRPC_client_applist_proto_depIdxs, + MessageInfos: file_api_helm_app_gRPC_client_applist_proto_msgTypes, }.Build() - File_api_helm_app_gRPC_applist_proto = out.File - file_api_helm_app_gRPC_applist_proto_rawDesc = nil - file_api_helm_app_gRPC_applist_proto_goTypes = nil - file_api_helm_app_gRPC_applist_proto_depIdxs = nil + File_api_helm_app_gRPC_client_applist_proto = out.File + file_api_helm_app_gRPC_client_applist_proto_rawDesc = nil + file_api_helm_app_gRPC_client_applist_proto_goTypes = nil + file_api_helm_app_gRPC_client_applist_proto_depIdxs = nil } diff --git a/api/helm-app/gRPC/applist.proto b/api/helm-app/gRPC/client/applist.proto similarity index 93% rename from api/helm-app/gRPC/applist.proto rename to api/helm-app/gRPC/client/applist.proto index 25b665bb31..2f97f9c644 100644 --- a/api/helm-app/gRPC/applist.proto +++ b/api/helm-app/gRPC/client/applist.proto @@ -13,6 +13,12 @@ message ClusterConfig { string keyData = 6; string certData = 7; string caData = 8; + string proxyUrl = 9; + bool toConnectWithSSHTunnel = 10; + string sshTunnelUser = 11; + string sshTunnelPassword = 12; + string sshTunnelAuthKey = 13; + string sshTunnelServerAddress = 14; } message AppListRequest { @@ -39,6 +45,7 @@ service ApplicationService { rpc InstallReleaseWithCustomChart(HelmInstallCustomRequest) returns (HelmInstallCustomResponse) {} rpc GetNotes(InstallReleaseRequest) returns (ChartNotesResponse) {} rpc UpgradeReleaseWithCustomChart(UpgradeReleaseRequest) returns(UpgradeReleaseResponse){} + rpc PushHelmChartToOCIRegistry(OCIRegistryRequest) returns(OCIRegistryResponse) {} rpc ValidateOCIRegistry(RegistryCredential) returns(OCIRegistryResponse) {} rpc GetResourceTreeForExternalResources(ExternalResourceTreeRequest) returns(ResourceTreeResponse){} } @@ -350,6 +357,14 @@ message ChartNotesResponse{ string notes = 1; } +message OCIRegistryRequest { + bytes Chart = 1; + string ChartName = 2; + string ChartVersion = 3; + bool IsInsecure = 4; + RegistryCredential RegistryCredential = 5; +} + message RegistryCredential { string RegistryUrl = 1; string Username = 2; @@ -364,4 +379,10 @@ message RegistryCredential { message OCIRegistryResponse { bool IsLoggedIn = 1; + OCIRegistryPushResponse PushResult = 2; +} + +message OCIRegistryPushResponse { + string Digest = 1; + string PushedURL = 2; } \ No newline at end of file diff --git a/api/helm-app/gRPC/applist_grpc.pb.go b/api/helm-app/gRPC/client/applist_grpc.pb.go similarity index 81% rename from api/helm-app/gRPC/applist_grpc.pb.go rename to api/helm-app/gRPC/client/applist_grpc.pb.go index acce13ae8b..2d5c9578e6 100644 --- a/api/helm-app/gRPC/applist_grpc.pb.go +++ b/api/helm-app/gRPC/client/applist_grpc.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 +// - protoc-gen-go-grpc v1.3.0 // - protoc v3.9.1 -// source: api/helm-app/gRPC/applist.proto +// source: api/helm-app/gRPC/client/applist.proto -package gRPC +package client import ( context "context" @@ -18,6 +18,31 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + ApplicationService_ListApplications_FullMethodName = "/ApplicationService/ListApplications" + ApplicationService_GetAppDetail_FullMethodName = "/ApplicationService/GetAppDetail" + ApplicationService_GetAppStatus_FullMethodName = "/ApplicationService/GetAppStatus" + ApplicationService_Hibernate_FullMethodName = "/ApplicationService/Hibernate" + ApplicationService_UnHibernate_FullMethodName = "/ApplicationService/UnHibernate" + ApplicationService_GetDeploymentHistory_FullMethodName = "/ApplicationService/GetDeploymentHistory" + ApplicationService_GetValuesYaml_FullMethodName = "/ApplicationService/GetValuesYaml" + ApplicationService_GetDesiredManifest_FullMethodName = "/ApplicationService/GetDesiredManifest" + ApplicationService_UninstallRelease_FullMethodName = "/ApplicationService/UninstallRelease" + ApplicationService_UpgradeRelease_FullMethodName = "/ApplicationService/UpgradeRelease" + ApplicationService_GetDeploymentDetail_FullMethodName = "/ApplicationService/GetDeploymentDetail" + ApplicationService_InstallRelease_FullMethodName = "/ApplicationService/InstallRelease" + ApplicationService_UpgradeReleaseWithChartInfo_FullMethodName = "/ApplicationService/UpgradeReleaseWithChartInfo" + ApplicationService_IsReleaseInstalled_FullMethodName = "/ApplicationService/IsReleaseInstalled" + ApplicationService_RollbackRelease_FullMethodName = "/ApplicationService/RollbackRelease" + ApplicationService_TemplateChart_FullMethodName = "/ApplicationService/TemplateChart" + ApplicationService_InstallReleaseWithCustomChart_FullMethodName = "/ApplicationService/InstallReleaseWithCustomChart" + ApplicationService_GetNotes_FullMethodName = "/ApplicationService/GetNotes" + ApplicationService_UpgradeReleaseWithCustomChart_FullMethodName = "/ApplicationService/UpgradeReleaseWithCustomChart" + ApplicationService_PushHelmChartToOCIRegistry_FullMethodName = "/ApplicationService/PushHelmChartToOCIRegistry" + ApplicationService_ValidateOCIRegistry_FullMethodName = "/ApplicationService/ValidateOCIRegistry" + ApplicationService_GetResourceTreeForExternalResources_FullMethodName = "/ApplicationService/GetResourceTreeForExternalResources" +) + // ApplicationServiceClient is the client API for ApplicationService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -41,6 +66,7 @@ type ApplicationServiceClient interface { InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest, opts ...grpc.CallOption) (*HelmInstallCustomResponse, error) GetNotes(ctx context.Context, in *InstallReleaseRequest, opts ...grpc.CallOption) (*ChartNotesResponse, error) UpgradeReleaseWithCustomChart(ctx context.Context, in *UpgradeReleaseRequest, opts ...grpc.CallOption) (*UpgradeReleaseResponse, error) + PushHelmChartToOCIRegistry(ctx context.Context, in *OCIRegistryRequest, opts ...grpc.CallOption) (*OCIRegistryResponse, error) ValidateOCIRegistry(ctx context.Context, in *RegistryCredential, opts ...grpc.CallOption) (*OCIRegistryResponse, error) GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest, opts ...grpc.CallOption) (*ResourceTreeResponse, error) } @@ -54,7 +80,7 @@ func NewApplicationServiceClient(cc grpc.ClientConnInterface) ApplicationService } func (c *applicationServiceClient) ListApplications(ctx context.Context, in *AppListRequest, opts ...grpc.CallOption) (ApplicationService_ListApplicationsClient, error) { - stream, err := c.cc.NewStream(ctx, &ApplicationService_ServiceDesc.Streams[0], "/ApplicationService/ListApplications", opts...) + stream, err := c.cc.NewStream(ctx, &ApplicationService_ServiceDesc.Streams[0], ApplicationService_ListApplications_FullMethodName, opts...) if err != nil { return nil, err } @@ -87,7 +113,7 @@ func (x *applicationServiceListApplicationsClient) Recv() (*DeployedAppList, err func (c *applicationServiceClient) GetAppDetail(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppDetail, error) { out := new(AppDetail) - err := c.cc.Invoke(ctx, "/ApplicationService/GetAppDetail", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetAppDetail_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -96,7 +122,7 @@ func (c *applicationServiceClient) GetAppDetail(ctx context.Context, in *AppDeta func (c *applicationServiceClient) GetAppStatus(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppStatus, error) { out := new(AppStatus) - err := c.cc.Invoke(ctx, "/ApplicationService/GetAppStatus", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetAppStatus_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -105,7 +131,7 @@ func (c *applicationServiceClient) GetAppStatus(ctx context.Context, in *AppDeta func (c *applicationServiceClient) Hibernate(ctx context.Context, in *HibernateRequest, opts ...grpc.CallOption) (*HibernateResponse, error) { out := new(HibernateResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/Hibernate", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_Hibernate_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -114,7 +140,7 @@ func (c *applicationServiceClient) Hibernate(ctx context.Context, in *HibernateR func (c *applicationServiceClient) UnHibernate(ctx context.Context, in *HibernateRequest, opts ...grpc.CallOption) (*HibernateResponse, error) { out := new(HibernateResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/UnHibernate", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_UnHibernate_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -123,7 +149,7 @@ func (c *applicationServiceClient) UnHibernate(ctx context.Context, in *Hibernat func (c *applicationServiceClient) GetDeploymentHistory(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*HelmAppDeploymentHistory, error) { out := new(HelmAppDeploymentHistory) - err := c.cc.Invoke(ctx, "/ApplicationService/GetDeploymentHistory", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetDeploymentHistory_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -132,7 +158,7 @@ func (c *applicationServiceClient) GetDeploymentHistory(ctx context.Context, in func (c *applicationServiceClient) GetValuesYaml(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*ReleaseInfo, error) { out := new(ReleaseInfo) - err := c.cc.Invoke(ctx, "/ApplicationService/GetValuesYaml", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetValuesYaml_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -141,7 +167,7 @@ func (c *applicationServiceClient) GetValuesYaml(ctx context.Context, in *AppDet func (c *applicationServiceClient) GetDesiredManifest(ctx context.Context, in *ObjectRequest, opts ...grpc.CallOption) (*DesiredManifestResponse, error) { out := new(DesiredManifestResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/GetDesiredManifest", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetDesiredManifest_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -150,7 +176,7 @@ func (c *applicationServiceClient) GetDesiredManifest(ctx context.Context, in *O func (c *applicationServiceClient) UninstallRelease(ctx context.Context, in *ReleaseIdentifier, opts ...grpc.CallOption) (*UninstallReleaseResponse, error) { out := new(UninstallReleaseResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/UninstallRelease", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_UninstallRelease_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -159,7 +185,7 @@ func (c *applicationServiceClient) UninstallRelease(ctx context.Context, in *Rel func (c *applicationServiceClient) UpgradeRelease(ctx context.Context, in *UpgradeReleaseRequest, opts ...grpc.CallOption) (*UpgradeReleaseResponse, error) { out := new(UpgradeReleaseResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/UpgradeRelease", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_UpgradeRelease_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -168,7 +194,7 @@ func (c *applicationServiceClient) UpgradeRelease(ctx context.Context, in *Upgra func (c *applicationServiceClient) GetDeploymentDetail(ctx context.Context, in *DeploymentDetailRequest, opts ...grpc.CallOption) (*DeploymentDetailResponse, error) { out := new(DeploymentDetailResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/GetDeploymentDetail", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetDeploymentDetail_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -177,7 +203,7 @@ func (c *applicationServiceClient) GetDeploymentDetail(ctx context.Context, in * func (c *applicationServiceClient) InstallRelease(ctx context.Context, in *InstallReleaseRequest, opts ...grpc.CallOption) (*InstallReleaseResponse, error) { out := new(InstallReleaseResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/InstallRelease", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_InstallRelease_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -186,7 +212,7 @@ func (c *applicationServiceClient) InstallRelease(ctx context.Context, in *Insta func (c *applicationServiceClient) UpgradeReleaseWithChartInfo(ctx context.Context, in *InstallReleaseRequest, opts ...grpc.CallOption) (*UpgradeReleaseResponse, error) { out := new(UpgradeReleaseResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/UpgradeReleaseWithChartInfo", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_UpgradeReleaseWithChartInfo_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -195,7 +221,7 @@ func (c *applicationServiceClient) UpgradeReleaseWithChartInfo(ctx context.Conte func (c *applicationServiceClient) IsReleaseInstalled(ctx context.Context, in *ReleaseIdentifier, opts ...grpc.CallOption) (*BooleanResponse, error) { out := new(BooleanResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/IsReleaseInstalled", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_IsReleaseInstalled_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -204,7 +230,7 @@ func (c *applicationServiceClient) IsReleaseInstalled(ctx context.Context, in *R func (c *applicationServiceClient) RollbackRelease(ctx context.Context, in *RollbackReleaseRequest, opts ...grpc.CallOption) (*BooleanResponse, error) { out := new(BooleanResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/RollbackRelease", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_RollbackRelease_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -213,7 +239,7 @@ func (c *applicationServiceClient) RollbackRelease(ctx context.Context, in *Roll func (c *applicationServiceClient) TemplateChart(ctx context.Context, in *InstallReleaseRequest, opts ...grpc.CallOption) (*TemplateChartResponse, error) { out := new(TemplateChartResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/TemplateChart", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_TemplateChart_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -222,7 +248,7 @@ func (c *applicationServiceClient) TemplateChart(ctx context.Context, in *Instal func (c *applicationServiceClient) InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest, opts ...grpc.CallOption) (*HelmInstallCustomResponse, error) { out := new(HelmInstallCustomResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/InstallReleaseWithCustomChart", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_InstallReleaseWithCustomChart_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -231,7 +257,7 @@ func (c *applicationServiceClient) InstallReleaseWithCustomChart(ctx context.Con func (c *applicationServiceClient) GetNotes(ctx context.Context, in *InstallReleaseRequest, opts ...grpc.CallOption) (*ChartNotesResponse, error) { out := new(ChartNotesResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/GetNotes", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetNotes_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -240,7 +266,16 @@ func (c *applicationServiceClient) GetNotes(ctx context.Context, in *InstallRele func (c *applicationServiceClient) UpgradeReleaseWithCustomChart(ctx context.Context, in *UpgradeReleaseRequest, opts ...grpc.CallOption) (*UpgradeReleaseResponse, error) { out := new(UpgradeReleaseResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/UpgradeReleaseWithCustomChart", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_UpgradeReleaseWithCustomChart_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *applicationServiceClient) PushHelmChartToOCIRegistry(ctx context.Context, in *OCIRegistryRequest, opts ...grpc.CallOption) (*OCIRegistryResponse, error) { + out := new(OCIRegistryResponse) + err := c.cc.Invoke(ctx, ApplicationService_PushHelmChartToOCIRegistry_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -249,7 +284,7 @@ func (c *applicationServiceClient) UpgradeReleaseWithCustomChart(ctx context.Con func (c *applicationServiceClient) ValidateOCIRegistry(ctx context.Context, in *RegistryCredential, opts ...grpc.CallOption) (*OCIRegistryResponse, error) { out := new(OCIRegistryResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/ValidateOCIRegistry", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_ValidateOCIRegistry_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -258,7 +293,7 @@ func (c *applicationServiceClient) ValidateOCIRegistry(ctx context.Context, in * func (c *applicationServiceClient) GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest, opts ...grpc.CallOption) (*ResourceTreeResponse, error) { out := new(ResourceTreeResponse) - err := c.cc.Invoke(ctx, "/ApplicationService/GetResourceTreeForExternalResources", in, out, opts...) + err := c.cc.Invoke(ctx, ApplicationService_GetResourceTreeForExternalResources_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -288,6 +323,7 @@ type ApplicationServiceServer interface { InstallReleaseWithCustomChart(context.Context, *HelmInstallCustomRequest) (*HelmInstallCustomResponse, error) GetNotes(context.Context, *InstallReleaseRequest) (*ChartNotesResponse, error) UpgradeReleaseWithCustomChart(context.Context, *UpgradeReleaseRequest) (*UpgradeReleaseResponse, error) + PushHelmChartToOCIRegistry(context.Context, *OCIRegistryRequest) (*OCIRegistryResponse, error) ValidateOCIRegistry(context.Context, *RegistryCredential) (*OCIRegistryResponse, error) GetResourceTreeForExternalResources(context.Context, *ExternalResourceTreeRequest) (*ResourceTreeResponse, error) mustEmbedUnimplementedApplicationServiceServer() @@ -354,6 +390,9 @@ func (UnimplementedApplicationServiceServer) GetNotes(context.Context, *InstallR func (UnimplementedApplicationServiceServer) UpgradeReleaseWithCustomChart(context.Context, *UpgradeReleaseRequest) (*UpgradeReleaseResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpgradeReleaseWithCustomChart not implemented") } +func (UnimplementedApplicationServiceServer) PushHelmChartToOCIRegistry(context.Context, *OCIRegistryRequest) (*OCIRegistryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PushHelmChartToOCIRegistry not implemented") +} func (UnimplementedApplicationServiceServer) ValidateOCIRegistry(context.Context, *RegistryCredential) (*OCIRegistryResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ValidateOCIRegistry not implemented") } @@ -404,7 +443,7 @@ func _ApplicationService_GetAppDetail_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetAppDetail", + FullMethod: ApplicationService_GetAppDetail_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetAppDetail(ctx, req.(*AppDetailRequest)) @@ -422,7 +461,7 @@ func _ApplicationService_GetAppStatus_Handler(srv interface{}, ctx context.Conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetAppStatus", + FullMethod: ApplicationService_GetAppStatus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetAppStatus(ctx, req.(*AppDetailRequest)) @@ -440,7 +479,7 @@ func _ApplicationService_Hibernate_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/Hibernate", + FullMethod: ApplicationService_Hibernate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).Hibernate(ctx, req.(*HibernateRequest)) @@ -458,7 +497,7 @@ func _ApplicationService_UnHibernate_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/UnHibernate", + FullMethod: ApplicationService_UnHibernate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).UnHibernate(ctx, req.(*HibernateRequest)) @@ -476,7 +515,7 @@ func _ApplicationService_GetDeploymentHistory_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetDeploymentHistory", + FullMethod: ApplicationService_GetDeploymentHistory_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetDeploymentHistory(ctx, req.(*AppDetailRequest)) @@ -494,7 +533,7 @@ func _ApplicationService_GetValuesYaml_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetValuesYaml", + FullMethod: ApplicationService_GetValuesYaml_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetValuesYaml(ctx, req.(*AppDetailRequest)) @@ -512,7 +551,7 @@ func _ApplicationService_GetDesiredManifest_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetDesiredManifest", + FullMethod: ApplicationService_GetDesiredManifest_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetDesiredManifest(ctx, req.(*ObjectRequest)) @@ -530,7 +569,7 @@ func _ApplicationService_UninstallRelease_Handler(srv interface{}, ctx context.C } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/UninstallRelease", + FullMethod: ApplicationService_UninstallRelease_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).UninstallRelease(ctx, req.(*ReleaseIdentifier)) @@ -548,7 +587,7 @@ func _ApplicationService_UpgradeRelease_Handler(srv interface{}, ctx context.Con } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/UpgradeRelease", + FullMethod: ApplicationService_UpgradeRelease_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).UpgradeRelease(ctx, req.(*UpgradeReleaseRequest)) @@ -566,7 +605,7 @@ func _ApplicationService_GetDeploymentDetail_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetDeploymentDetail", + FullMethod: ApplicationService_GetDeploymentDetail_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetDeploymentDetail(ctx, req.(*DeploymentDetailRequest)) @@ -584,7 +623,7 @@ func _ApplicationService_InstallRelease_Handler(srv interface{}, ctx context.Con } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/InstallRelease", + FullMethod: ApplicationService_InstallRelease_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).InstallRelease(ctx, req.(*InstallReleaseRequest)) @@ -602,7 +641,7 @@ func _ApplicationService_UpgradeReleaseWithChartInfo_Handler(srv interface{}, ct } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/UpgradeReleaseWithChartInfo", + FullMethod: ApplicationService_UpgradeReleaseWithChartInfo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).UpgradeReleaseWithChartInfo(ctx, req.(*InstallReleaseRequest)) @@ -620,7 +659,7 @@ func _ApplicationService_IsReleaseInstalled_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/IsReleaseInstalled", + FullMethod: ApplicationService_IsReleaseInstalled_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).IsReleaseInstalled(ctx, req.(*ReleaseIdentifier)) @@ -638,7 +677,7 @@ func _ApplicationService_RollbackRelease_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/RollbackRelease", + FullMethod: ApplicationService_RollbackRelease_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).RollbackRelease(ctx, req.(*RollbackReleaseRequest)) @@ -656,7 +695,7 @@ func _ApplicationService_TemplateChart_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/TemplateChart", + FullMethod: ApplicationService_TemplateChart_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).TemplateChart(ctx, req.(*InstallReleaseRequest)) @@ -674,7 +713,7 @@ func _ApplicationService_InstallReleaseWithCustomChart_Handler(srv interface{}, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/InstallReleaseWithCustomChart", + FullMethod: ApplicationService_InstallReleaseWithCustomChart_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).InstallReleaseWithCustomChart(ctx, req.(*HelmInstallCustomRequest)) @@ -692,7 +731,7 @@ func _ApplicationService_GetNotes_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetNotes", + FullMethod: ApplicationService_GetNotes_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetNotes(ctx, req.(*InstallReleaseRequest)) @@ -710,7 +749,7 @@ func _ApplicationService_UpgradeReleaseWithCustomChart_Handler(srv interface{}, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/UpgradeReleaseWithCustomChart", + FullMethod: ApplicationService_UpgradeReleaseWithCustomChart_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).UpgradeReleaseWithCustomChart(ctx, req.(*UpgradeReleaseRequest)) @@ -718,6 +757,24 @@ func _ApplicationService_UpgradeReleaseWithCustomChart_Handler(srv interface{}, return interceptor(ctx, in, info, handler) } +func _ApplicationService_PushHelmChartToOCIRegistry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OCIRegistryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApplicationServiceServer).PushHelmChartToOCIRegistry(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ApplicationService_PushHelmChartToOCIRegistry_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApplicationServiceServer).PushHelmChartToOCIRegistry(ctx, req.(*OCIRegistryRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _ApplicationService_ValidateOCIRegistry_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RegistryCredential) if err := dec(in); err != nil { @@ -728,7 +785,7 @@ func _ApplicationService_ValidateOCIRegistry_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/ValidateOCIRegistry", + FullMethod: ApplicationService_ValidateOCIRegistry_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).ValidateOCIRegistry(ctx, req.(*RegistryCredential)) @@ -746,7 +803,7 @@ func _ApplicationService_GetResourceTreeForExternalResources_Handler(srv interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ApplicationService/GetResourceTreeForExternalResources", + FullMethod: ApplicationService_GetResourceTreeForExternalResources_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ApplicationServiceServer).GetResourceTreeForExternalResources(ctx, req.(*ExternalResourceTreeRequest)) @@ -833,6 +890,10 @@ var ApplicationService_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpgradeReleaseWithCustomChart", Handler: _ApplicationService_UpgradeReleaseWithCustomChart_Handler, }, + { + MethodName: "PushHelmChartToOCIRegistry", + Handler: _ApplicationService_PushHelmChartToOCIRegistry_Handler, + }, { MethodName: "ValidateOCIRegistry", Handler: _ApplicationService_ValidateOCIRegistry_Handler, @@ -849,5 +910,5 @@ var ApplicationService_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "api/helm-app/gRPC/applist.proto", + Metadata: "api/helm-app/gRPC/client/applist.proto", } diff --git a/api/helm-app/mocks/HelmAppClient.go b/api/helm-app/mocks/HelmAppClient.go index ac80fdd6a9..cd10df5919 100644 --- a/api/helm-app/mocks/HelmAppClient.go +++ b/api/helm-app/mocks/HelmAppClient.go @@ -4,7 +4,7 @@ package mocks import ( context "context" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" mock "github.com/stretchr/testify/mock" ) @@ -14,23 +14,23 @@ type HelmAppClient struct { } // DeleteApplication provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *gRPC.ReleaseIdentifier) (*gRPC.UninstallReleaseResponse, error) { +func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.UninstallReleaseResponse + var r0 *client.UninstallReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) (*gRPC.UninstallReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) (*client.UninstallReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) *gRPC.UninstallReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) *client.UninstallReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.UninstallReleaseResponse) + r0 = ret.Get(0).(*client.UninstallReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ReleaseIdentifier) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.ReleaseIdentifier) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -40,23 +40,23 @@ func (_m *HelmAppClient) DeleteApplication(ctx context.Context, in *gRPC.Release } // GetAppDetail provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.AppDetail, error) { +func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *client.AppDetailRequest) (*client.AppDetail, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.AppDetail + var r0 *client.AppDetail var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.AppDetail, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.AppDetail, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.AppDetail); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.AppDetail); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.AppDetail) + r0 = ret.Get(0).(*client.AppDetail) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -66,23 +66,23 @@ func (_m *HelmAppClient) GetAppDetail(ctx context.Context, in *gRPC.AppDetailReq } // GetAppStatus provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.AppStatus, error) { +func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *client.AppDetailRequest) (*client.AppStatus, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.AppStatus + var r0 *client.AppStatus var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.AppStatus, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.AppStatus, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.AppStatus); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.AppStatus); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.AppStatus) + r0 = ret.Get(0).(*client.AppStatus) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -92,23 +92,23 @@ func (_m *HelmAppClient) GetAppStatus(ctx context.Context, in *gRPC.AppDetailReq } // GetDeploymentDetail provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *gRPC.DeploymentDetailRequest) (*gRPC.DeploymentDetailResponse, error) { +func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.DeploymentDetailResponse + var r0 *client.DeploymentDetailResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.DeploymentDetailRequest) (*gRPC.DeploymentDetailResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.DeploymentDetailRequest) (*client.DeploymentDetailResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.DeploymentDetailRequest) *gRPC.DeploymentDetailResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.DeploymentDetailRequest) *client.DeploymentDetailResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.DeploymentDetailResponse) + r0 = ret.Get(0).(*client.DeploymentDetailResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.DeploymentDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.DeploymentDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -118,23 +118,23 @@ func (_m *HelmAppClient) GetDeploymentDetail(ctx context.Context, in *gRPC.Deplo } // GetDeploymentHistory provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.HelmAppDeploymentHistory, error) { +func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.HelmAppDeploymentHistory + var r0 *client.HelmAppDeploymentHistory var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.HelmAppDeploymentHistory, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.HelmAppDeploymentHistory, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.HelmAppDeploymentHistory); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.HelmAppDeploymentHistory); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.HelmAppDeploymentHistory) + r0 = ret.Get(0).(*client.HelmAppDeploymentHistory) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -144,23 +144,23 @@ func (_m *HelmAppClient) GetDeploymentHistory(ctx context.Context, in *gRPC.AppD } // GetDesiredManifest provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *gRPC.ObjectRequest) (*gRPC.DesiredManifestResponse, error) { +func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *client.ObjectRequest) (*client.DesiredManifestResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.DesiredManifestResponse + var r0 *client.DesiredManifestResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ObjectRequest) (*gRPC.DesiredManifestResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ObjectRequest) (*client.DesiredManifestResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ObjectRequest) *gRPC.DesiredManifestResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ObjectRequest) *client.DesiredManifestResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.DesiredManifestResponse) + r0 = ret.Get(0).(*client.DesiredManifestResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ObjectRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.ObjectRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -170,23 +170,23 @@ func (_m *HelmAppClient) GetDesiredManifest(ctx context.Context, in *gRPC.Object } // GetNotes provides a mock function with given fields: ctx, request -func (_m *HelmAppClient) GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (*gRPC.ChartNotesResponse, error) { +func (_m *HelmAppClient) GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (*client.ChartNotesResponse, error) { ret := _m.Called(ctx, request) - var r0 *gRPC.ChartNotesResponse + var r0 *client.ChartNotesResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.ChartNotesResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.ChartNotesResponse, error)); ok { return rf(ctx, request) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.ChartNotesResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.ChartNotesResponse); ok { r0 = rf(ctx, request) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.ChartNotesResponse) + r0 = ret.Get(0).(*client.ChartNotesResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { r1 = rf(ctx, request) } else { r1 = ret.Error(1) @@ -196,23 +196,23 @@ func (_m *HelmAppClient) GetNotes(ctx context.Context, request *gRPC.InstallRele } // GetValuesYaml provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *gRPC.AppDetailRequest) (*gRPC.ReleaseInfo, error) { +func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *client.AppDetailRequest) (*client.ReleaseInfo, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.ReleaseInfo + var r0 *client.ReleaseInfo var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) (*gRPC.ReleaseInfo, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) (*client.ReleaseInfo, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppDetailRequest) *gRPC.ReleaseInfo); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppDetailRequest) *client.ReleaseInfo); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.ReleaseInfo) + r0 = ret.Get(0).(*client.ReleaseInfo) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppDetailRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppDetailRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -222,23 +222,23 @@ func (_m *HelmAppClient) GetValuesYaml(ctx context.Context, in *gRPC.AppDetailRe } // Hibernate provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) Hibernate(ctx context.Context, in *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error) { +func (_m *HelmAppClient) Hibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.HibernateResponse + var r0 *client.HibernateResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) (*client.HibernateResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) *gRPC.HibernateResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) *client.HibernateResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.HibernateResponse) + r0 = ret.Get(0).(*client.HibernateResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HibernateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.HibernateRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -248,23 +248,23 @@ func (_m *HelmAppClient) Hibernate(ctx context.Context, in *gRPC.HibernateReques } // InstallRelease provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) { +func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.InstallReleaseResponse + var r0 *client.InstallReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.InstallReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.InstallReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.InstallReleaseResponse) + r0 = ret.Get(0).(*client.InstallReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -274,23 +274,23 @@ func (_m *HelmAppClient) InstallRelease(ctx context.Context, in *gRPC.InstallRel } // InstallReleaseWithCustomChart provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in *gRPC.HelmInstallCustomRequest) (*gRPC.HelmInstallCustomResponse, error) { +func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.HelmInstallCustomResponse + var r0 *client.HelmInstallCustomResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HelmInstallCustomRequest) (*gRPC.HelmInstallCustomResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HelmInstallCustomRequest) (*client.HelmInstallCustomResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HelmInstallCustomRequest) *gRPC.HelmInstallCustomResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HelmInstallCustomRequest) *client.HelmInstallCustomResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.HelmInstallCustomResponse) + r0 = ret.Get(0).(*client.HelmInstallCustomResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HelmInstallCustomRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.HelmInstallCustomRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -300,23 +300,23 @@ func (_m *HelmAppClient) InstallReleaseWithCustomChart(ctx context.Context, in * } // IsReleaseInstalled provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *gRPC.ReleaseIdentifier) (*gRPC.BooleanResponse, error) { +func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *client.ReleaseIdentifier) (*client.BooleanResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.BooleanResponse + var r0 *client.BooleanResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) (*gRPC.BooleanResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) (*client.BooleanResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.ReleaseIdentifier) *gRPC.BooleanResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.ReleaseIdentifier) *client.BooleanResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.BooleanResponse) + r0 = ret.Get(0).(*client.BooleanResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.ReleaseIdentifier) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.ReleaseIdentifier) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -326,23 +326,23 @@ func (_m *HelmAppClient) IsReleaseInstalled(ctx context.Context, in *gRPC.Releas } // ListApplication provides a mock function with given fields: ctx, req -func (_m *HelmAppClient) ListApplication(ctx context.Context, req *gRPC.AppListRequest) (gRPC.ApplicationService_ListApplicationsClient, error) { +func (_m *HelmAppClient) ListApplication(ctx context.Context, req *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error) { ret := _m.Called(ctx, req) - var r0 gRPC.ApplicationService_ListApplicationsClient + var r0 client.ApplicationService_ListApplicationsClient var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppListRequest) (gRPC.ApplicationService_ListApplicationsClient, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppListRequest) (client.ApplicationService_ListApplicationsClient, error)); ok { return rf(ctx, req) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.AppListRequest) gRPC.ApplicationService_ListApplicationsClient); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.AppListRequest) client.ApplicationService_ListApplicationsClient); ok { r0 = rf(ctx, req) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(gRPC.ApplicationService_ListApplicationsClient) + r0 = ret.Get(0).(client.ApplicationService_ListApplicationsClient) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.AppListRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.AppListRequest) error); ok { r1 = rf(ctx, req) } else { r1 = ret.Error(1) @@ -352,23 +352,23 @@ func (_m *HelmAppClient) ListApplication(ctx context.Context, req *gRPC.AppListR } // RollbackRelease provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *gRPC.RollbackReleaseRequest) (*gRPC.BooleanResponse, error) { +func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *client.RollbackReleaseRequest) (*client.BooleanResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.BooleanResponse + var r0 *client.BooleanResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.RollbackReleaseRequest) (*gRPC.BooleanResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.RollbackReleaseRequest) (*client.BooleanResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.RollbackReleaseRequest) *gRPC.BooleanResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.RollbackReleaseRequest) *client.BooleanResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.BooleanResponse) + r0 = ret.Get(0).(*client.BooleanResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.RollbackReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.RollbackReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -378,23 +378,23 @@ func (_m *HelmAppClient) RollbackRelease(ctx context.Context, in *gRPC.RollbackR } // TemplateChart provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.TemplateChartResponse, error) { +func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *client.InstallReleaseRequest) (*client.TemplateChartResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.TemplateChartResponse + var r0 *client.TemplateChartResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.TemplateChartResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.TemplateChartResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.TemplateChartResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.TemplateChartResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.TemplateChartResponse) + r0 = ret.Get(0).(*client.TemplateChartResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -404,23 +404,23 @@ func (_m *HelmAppClient) TemplateChart(ctx context.Context, in *gRPC.InstallRele } // UnHibernate provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error) { +func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *client.HibernateRequest) (*client.HibernateResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.HibernateResponse + var r0 *client.HibernateResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) (*gRPC.HibernateResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) (*client.HibernateResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.HibernateRequest) *gRPC.HibernateResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.HibernateRequest) *client.HibernateResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.HibernateResponse) + r0 = ret.Get(0).(*client.HibernateResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.HibernateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.HibernateRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -430,23 +430,23 @@ func (_m *HelmAppClient) UnHibernate(ctx context.Context, in *gRPC.HibernateRequ } // UpdateApplication provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *gRPC.UpgradeReleaseRequest) (*gRPC.UpgradeReleaseResponse, error) { +func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.UpgradeReleaseResponse + var r0 *client.UpgradeReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.UpgradeReleaseRequest) (*gRPC.UpgradeReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.UpgradeReleaseRequest) (*client.UpgradeReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.UpgradeReleaseRequest) *gRPC.UpgradeReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.UpgradeReleaseRequest) *client.UpgradeReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.UpgradeReleaseResponse) + r0 = ret.Get(0).(*client.UpgradeReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.UpgradeReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.UpgradeReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) @@ -456,23 +456,23 @@ func (_m *HelmAppClient) UpdateApplication(ctx context.Context, in *gRPC.Upgrade } // UpdateApplicationWithChartInfo provides a mock function with given fields: ctx, in -func (_m *HelmAppClient) UpdateApplicationWithChartInfo(ctx context.Context, in *gRPC.InstallReleaseRequest) (*gRPC.UpgradeReleaseResponse, error) { +func (_m *HelmAppClient) UpdateApplicationWithChartInfo(ctx context.Context, in *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error) { ret := _m.Called(ctx, in) - var r0 *gRPC.UpgradeReleaseResponse + var r0 *client.UpgradeReleaseResponse var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) (*gRPC.UpgradeReleaseResponse, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) (*client.UpgradeReleaseResponse, error)); ok { return rf(ctx, in) } - if rf, ok := ret.Get(0).(func(context.Context, *gRPC.InstallReleaseRequest) *gRPC.UpgradeReleaseResponse); ok { + if rf, ok := ret.Get(0).(func(context.Context, *client.InstallReleaseRequest) *client.UpgradeReleaseResponse); ok { r0 = rf(ctx, in) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*gRPC.UpgradeReleaseResponse) + r0 = ret.Get(0).(*client.UpgradeReleaseResponse) } } - if rf, ok := ret.Get(1).(func(context.Context, *gRPC.InstallReleaseRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *client.InstallReleaseRequest) error); ok { r1 = rf(ctx, in) } else { r1 = ret.Error(1) diff --git a/api/helm-app/mocks/HelmAppService.go b/api/helm-app/mocks/HelmAppService.go index 895130dd23..abeca4f775 100644 --- a/api/helm-app/mocks/HelmAppService.go +++ b/api/helm-app/mocks/HelmAppService.go @@ -5,7 +5,7 @@ package mocks import ( context "context" "github.com/devtron-labs/devtron/api/helm-app/bean" - bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" http "net/http" diff --git a/api/helm-app/service/HelmAppService.go b/api/helm-app/service/HelmAppService.go index a4f306a499..c1eeebf702 100644 --- a/api/helm-app/service/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -7,6 +7,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "github.com/devtron-labs/devtron/api/helm-app/models" "github.com/devtron-labs/devtron/internals/constants" repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" @@ -46,32 +47,32 @@ import ( type HelmAppService interface { ListHelmApplications(ctx context.Context, clusterIds []int, w http.ResponseWriter, token string, helmAuth func(token string, object string) bool) - GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*gRPC.AppDetail, error) - GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) - GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) + GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*client.AppDetail, error) + GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*client.AppStatus, error) + GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *client.ResourceTreeFilter) (*client.AppDetail, error) HibernateApplication(ctx context.Context, app *AppIdentifier, hibernateRequest *openapi.HibernateRequest) ([]*openapi.HibernateStatus, error) UnHibernateApplication(ctx context.Context, app *AppIdentifier, hibernateRequest *openapi.HibernateRequest) ([]*openapi.HibernateStatus, error) DecodeAppId(appId string) (*AppIdentifier, error) EncodeAppId(appIdentifier *AppIdentifier) string - GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*gRPC.HelmAppDeploymentHistory, error) - GetValuesYaml(ctx context.Context, app *AppIdentifier) (*gRPC.ReleaseInfo, error) + GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*client.HelmAppDeploymentHistory, error) + GetValuesYaml(ctx context.Context, app *AppIdentifier) (*client.ReleaseInfo, error) GetDesiredManifest(ctx context.Context, app *AppIdentifier, resource *openapi.ResourceIdentifier) (*openapi.DesiredManifestResponse, error) DeleteApplication(ctx context.Context, app *AppIdentifier) (*openapi.UninstallReleaseResponse, error) DeleteDBLinkedHelmApplication(ctx context.Context, app *AppIdentifier, useId int32) (*openapi.UninstallReleaseResponse, error) UpdateApplication(ctx context.Context, app *AppIdentifier, request *bean.UpdateApplicationRequestDto) (*openapi.UpdateReleaseResponse, error) GetDeploymentDetail(ctx context.Context, app *AppIdentifier, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) - InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) + InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) UpdateApplicationWithChartInfo(ctx context.Context, clusterId int, request *bean.UpdateApplicationWithChartInfoRequestDto) (*openapi.UpdateReleaseResponse, error) IsReleaseInstalled(ctx context.Context, app *AppIdentifier) (bool, error) RollbackRelease(ctx context.Context, app *AppIdentifier, version int32) (bool, error) - GetClusterConf(clusterId int) (*gRPC.ClusterConfig, error) + GetClusterConf(clusterId int) (*client.ClusterConfig, error) GetDevtronHelmAppIdentifier() *AppIdentifier - UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, chartRepository *gRPC.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) + UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, chartRepository *client.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) TemplateChart(ctx context.Context, templateChartRequest *openapi2.TemplateChartRequest) (*openapi2.TemplateChartResponse, error) - GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (string, error) - ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *gRPC.RegistryCredential) bool + GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (string, error) + ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *client.RegistryCredential) bool GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32 - GetResourceTreeForExternalResources(ctx context.Context, clusterId int, clusterConfig *gRPC.ClusterConfig, resources []*gRPC.ExternalResourceDetail) (*gRPC.ResourceTreeResponse, error) + GetResourceTreeForExternalResources(ctx context.Context, clusterId int, clusterConfig *client.ClusterConfig, resources []*client.ExternalResourceDetail) (*client.ResourceTreeResponse, error) } type HelmAppServiceImpl struct { @@ -131,7 +132,7 @@ func GetHelmReleaseConfig() (*HelmReleaseConfig, error) { return cfg, err } -func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds []int) (gRPC.ApplicationService_ListApplicationsClient, error) { +func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds []int) (client.ApplicationService_ListApplicationsClient, error) { if len(clusterIds) == 0 { return nil, nil } @@ -142,9 +143,9 @@ func (impl *HelmAppServiceImpl) listApplications(ctx context.Context, clusterIds impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &gRPC.AppListRequest{} + req := &client.AppListRequest{} for _, clusterDetail := range clusters { - config := &gRPC.ClusterConfig{ + config := &client.ClusterConfig{ ApiServerUrl: clusterDetail.ServerUrl, Token: clusterDetail.Config[k8s.BearerToken], ClusterId: int32(clusterDetail.Id), @@ -202,14 +203,14 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste return appStream.Recv() }, err, func(message interface{}) interface{} { - return impl.appListRespProtoTransformer(message.(*gRPC.DeployedAppList), token, helmAuth, helmCdPipelines, installedHelmApps) + return impl.appListRespProtoTransformer(message.(*client.DeployedAppList), token, helmAuth, helmCdPipelines, installedHelmApps) }) } -func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.HibernateRequest) *gRPC.HibernateRequest { - req := &gRPC.HibernateRequest{} +func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.HibernateRequest) *client.HibernateRequest { + req := &client.HibernateRequest{} for _, reqObject := range hibernateRequest.GetResources() { - obj := &gRPC.ObjectIdentifier{ + obj := &client.ObjectIdentifier{ Group: *reqObject.Group, Kind: *reqObject.Kind, Version: *reqObject.Version, @@ -220,7 +221,7 @@ func (impl *HelmAppServiceImpl) hibernateReqAdaptor(hibernateRequest *openapi.Hi } return req } -func (impl *HelmAppServiceImpl) hibernateResponseAdaptor(in []*gRPC.HibernateStatus) []*openapi.HibernateStatus { +func (impl *HelmAppServiceImpl) hibernateResponseAdaptor(in []*client.HibernateStatus) []*openapi.HibernateStatus { var resStatus []*openapi.HibernateStatus for _, status := range in { resObj := &openapi.HibernateStatus{ @@ -269,13 +270,13 @@ func (impl *HelmAppServiceImpl) UnHibernateApplication(ctx context.Context, app return response, nil } -func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*gRPC.ClusterConfig, error) { +func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*client.ClusterConfig, error) { cluster, err := impl.clusterService.FindById(clusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - config := &gRPC.ClusterConfig{ + config := &client.ClusterConfig{ ApiServerUrl: cluster.ServerUrl, Token: cluster.Config[k8s.BearerToken], ClusterId: int32(cluster.Id), @@ -290,25 +291,25 @@ func (impl *HelmAppServiceImpl) GetClusterConf(clusterId int) (*gRPC.ClusterConf return config, nil } -func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*gRPC.AppDetail, error) { +func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *AppIdentifier) (*client.AppDetail, error) { return impl.getApplicationDetail(ctx, app, nil) } -func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) { +func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*client.AppStatus, error) { return impl.getApplicationAndReleaseStatus(ctx, app) } -func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { +func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *AppIdentifier, resourceTreeFilter *client.ResourceTreeFilter) (*client.AppDetail, error) { return impl.getApplicationDetail(ctx, app, resourceTreeFilter) } -func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { +func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *AppIdentifier, resourceTreeFilter *client.ResourceTreeFilter) (*client.AppDetail, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &gRPC.AppDetailRequest{ + req := &client.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -339,8 +340,8 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *A } func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.Context, clusterId int, - clusterConfig *gRPC.ClusterConfig, resources []*gRPC.ExternalResourceDetail) (*gRPC.ResourceTreeResponse, error) { - var config *gRPC.ClusterConfig + clusterConfig *client.ClusterConfig, resources []*client.ExternalResourceDetail) (*client.ResourceTreeResponse, error) { + var config *client.ClusterConfig var err error if clusterId > 0 { config, err = impl.GetClusterConf(clusterId) @@ -351,20 +352,20 @@ func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context. } else { config = clusterConfig } - req := &gRPC.ExternalResourceTreeRequest{ + req := &client.ExternalResourceTreeRequest{ ClusterConfig: config, ExternalResourceDetail: resources, } return impl.helmAppClient.GetResourceTreeForExternalResources(ctx, req) } -func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*gRPC.AppStatus, error) { +func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Context, app *AppIdentifier) (*client.AppStatus, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &gRPC.AppDetailRequest{ + req := &client.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -377,13 +378,13 @@ func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Conte return appStatus, err } -func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*gRPC.HelmAppDeploymentHistory, error) { +func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *AppIdentifier) (*client.HelmAppDeploymentHistory, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &gRPC.AppDetailRequest{ + req := &client.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -399,13 +400,13 @@ func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *A return history, err } -func (impl *HelmAppServiceImpl) GetValuesYaml(ctx context.Context, app *AppIdentifier) (*gRPC.ReleaseInfo, error) { +func (impl *HelmAppServiceImpl) GetValuesYaml(ctx context.Context, app *AppIdentifier) (*client.ReleaseInfo, error) { config, err := impl.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) return nil, err } - req := &gRPC.AppDetailRequest{ + req := &client.AppDetailRequest{ ClusterConfig: config, Namespace: app.Namespace, ReleaseName: app.ReleaseName, @@ -421,11 +422,11 @@ func (impl *HelmAppServiceImpl) GetDesiredManifest(ctx context.Context, app *App return nil, err } - req := &gRPC.ObjectRequest{ + req := &client.ObjectRequest{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, - ObjectIdentifier: &gRPC.ObjectIdentifier{ + ObjectIdentifier: &client.ObjectIdentifier{ Group: resource.GetGroup(), Kind: resource.GetKind(), Version: resource.GetVersion(), @@ -544,7 +545,7 @@ func (impl *HelmAppServiceImpl) DeleteApplication(ctx context.Context, app *AppI return nil, models.NamespaceNotExistError{Err: fmt.Errorf("namespace %s does not exist", app.Namespace)} } - req := &gRPC.ReleaseIdentifier{ + req := &client.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -606,8 +607,8 @@ func (impl *HelmAppServiceImpl) UpdateApplication(ctx context.Context, app *AppI return nil, err } - req := &gRPC.UpgradeReleaseRequest{ - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + req := &client.UpgradeReleaseRequest{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -635,8 +636,8 @@ func (impl *HelmAppServiceImpl) GetDeploymentDetail(ctx context.Context, app *Ap return nil, err } - req := &gRPC.DeploymentDetailRequest{ - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + req := &client.DeploymentDetailRequest{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -658,7 +659,7 @@ func (impl *HelmAppServiceImpl) GetDeploymentDetail(ctx context.Context, app *Ap return response, nil } -func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *gRPC.InstallReleaseRequest) (*gRPC.InstallReleaseResponse, error) { +func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId int, installReleaseRequest *client.InstallReleaseRequest) (*client.InstallReleaseResponse, error) { config, err := impl.GetClusterConf(clusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "clusterId", clusterId, "err", err) @@ -706,7 +707,7 @@ func (impl *HelmAppServiceImpl) IsReleaseInstalled(ctx context.Context, app *App return false, err } - req := &gRPC.ReleaseIdentifier{ + req := &client.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -728,8 +729,8 @@ func (impl *HelmAppServiceImpl) RollbackRelease(ctx context.Context, app *AppIde return false, err } - req := &gRPC.RollbackReleaseRequest{ - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + req := &client.RollbackReleaseRequest{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: app.ReleaseName, ReleaseNamespace: app.Namespace, @@ -755,7 +756,7 @@ func (impl *HelmAppServiceImpl) GetDevtronHelmAppIdentifier() *AppIdentifier { } func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ctx context.Context, appIdentifier *AppIdentifier, - chartRepository *gRPC.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { + chartRepository *client.ChartRepository, extraValues map[string]interface{}, extraValuesYamlUrl string, useLatestChartVersion bool) (*openapi.UpdateReleaseResponse, error) { // get release info releaseInfo, err := impl.GetValuesYaml(context.Background(), appIdentifier) @@ -830,8 +831,8 @@ func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ct // update in helm updateReleaseRequest := &bean.UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &gRPC.InstallReleaseRequest{ - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + InstallReleaseRequest: &client.InstallReleaseRequest{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ReleaseName: appIdentifier.ReleaseName, ReleaseNamespace: appIdentifier.Namespace, }, @@ -900,8 +901,8 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart return nil, err } var IsOCIRepo bool - var registryCredential *gRPC.RegistryCredential - var chartRepository *gRPC.ChartRepository + var registryCredential *client.RegistryCredential + var chartRepository *client.ChartRepository dockerRegistryId := appStoreAppVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs := appStoreAppVersion.AppStore.DockerArtifactStore.OCIRegistryConfig @@ -917,7 +918,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart } } IsOCIRepo = true - registryCredential = &gRPC.RegistryCredential{ + registryCredential = &client.RegistryCredential{ RegistryUrl: appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreAppVersion.AppStore.DockerArtifactStore.Username, Password: appStoreAppVersion.AppStore.DockerArtifactStore.Password, @@ -929,7 +930,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &gRPC.ChartRepository{ + chartRepository = &client.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, @@ -937,13 +938,13 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart } } - installReleaseRequest := &gRPC.InstallReleaseRequest{ + installReleaseRequest := &client.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: *templateChartRequest.ValuesYaml, K8SVersion: k8sServerVersion.String(), ChartRepository: chartRepository, - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ReleaseNamespace: *templateChartRequest.Namespace, ReleaseName: *templateChartRequest.ReleaseName, }, @@ -971,7 +972,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart return response, nil } -func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *gRPC.InstallReleaseRequest) (string, error) { +func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *client.InstallReleaseRequest) (string, error) { var notesTxt string response, err := impl.helmAppClient.GetNotes(ctx, request) if err != nil { @@ -982,7 +983,7 @@ func (impl *HelmAppServiceImpl) GetNotes(ctx context.Context, request *gRPC.Inst return notesTxt, err } -func (impl *HelmAppServiceImpl) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *gRPC.RegistryCredential) bool { +func (impl *HelmAppServiceImpl) ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *client.RegistryCredential) bool { response, err := impl.helmAppClient.ValidateOCIRegistry(ctx, OCIRegistryRequest) if err != nil { impl.logger.Errorw("error in fetching chart", "err", err) @@ -1020,7 +1021,7 @@ func (impl *HelmAppServiceImpl) EncodeAppId(appIdentifier *AppIdentifier) string return fmt.Sprintf("%d|%s|%s", appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName) } -func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *gRPC.DeployedAppList, token string, helmAuth func(token string, object string) bool, helmCdPipelines []*pipelineConfig.Pipeline, installedHelmApps []*repository.InstalledApps) openapi.AppList { +func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *client.DeployedAppList, token string, helmAuth func(token string, object string) bool, helmCdPipelines []*pipelineConfig.Pipeline, installedHelmApps []*repository.InstalledApps) openapi.AppList { applicationType := "HELM-APP" appList := openapi.AppList{ClusterIds: &[]int32{deployedApps.ClusterId}, ApplicationType: &applicationType} if deployedApps.Errored { diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index b9a98b730c..c76eb0115b 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -22,6 +22,7 @@ import ( "encoding/json" "fmt" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" util3 "github.com/devtron-labs/devtron/api/util" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" @@ -1059,7 +1060,7 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter if err != nil { handler.logger.Errorw("error in fetching cluster detail", "err", err) } - req := &gRPC.AppDetailRequest{ + req := &client2.AppDetailRequest{ ClusterConfig: config, Namespace: cdPipeline.Environment.Namespace, ReleaseName: cdPipeline.DeploymentAppName, diff --git a/client/telemetry/TelemetryEventClient.go b/client/telemetry/TelemetryEventClient.go index 229a5dc28a..b00ce27116 100644 --- a/client/telemetry/TelemetryEventClient.go +++ b/client/telemetry/TelemetryEventClient.go @@ -7,6 +7,7 @@ import ( "fmt" cloudProviderIdentifier "github.com/devtron-labs/common-lib/cloud-provider-identifier" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" cron3 "github.com/devtron-labs/devtron/util/cron" "net/http" "time" @@ -240,8 +241,8 @@ func (impl *TelemetryEventClientImpl) SummaryDetailsForTelemetry() (cluster []cl ExternalHelmAppClusterCount = make(map[int32]int) for _, clusterDetail := range clusters { - req := &gRPC.AppListRequest{} - config := &gRPC.ClusterConfig{ + req := &client.AppListRequest{} + config := &client.ClusterConfig{ ApiServerUrl: clusterDetail.ServerUrl, Token: clusterDetail.Config[k8s.BearerToken], ClusterId: int32(clusterDetail.Id), diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go index ff4a3c907b..1a68fa9308 100644 --- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go +++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go @@ -22,7 +22,7 @@ import ( "errors" "fmt" bean3 "github.com/devtron-labs/devtron/api/helm-app/bean" - bean4 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + bean4 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" openapi "github.com/devtron-labs/devtron/api/helm-app/openapiClient" "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" diff --git a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go index 28319eb280..eb56f4adb6 100644 --- a/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/EAMode/EAModeDeploymentService.go @@ -5,6 +5,7 @@ import ( "errors" bean2 "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" repository2 "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/bean" @@ -28,7 +29,7 @@ type EAModeDeploymentService interface { InstallApp(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, chartGitAttr *commonBean.ChartGitAttribute, ctx context.Context, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) DeleteInstalledApp(ctx context.Context, appName string, environmentName string, installAppVersionRequest *appStoreBean.InstallAppVersionDTO, installedApps *repository.InstalledApps, dbTransaction *pg.Tx) error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) - GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) + GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client2.HelmAppDeploymentHistory, error) GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) UpgradeDeployment(installAppVersionRequest *appStoreBean.InstallAppVersionDTO, ChartGitAttribute *commonBean.ChartGitAttribute, installedAppVersionHistoryId int, ctx context.Context) error } @@ -75,8 +76,8 @@ func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *ap return installAppVersionRequest, err } var IsOCIRepo bool - var registryCredential *gRPC.RegistryCredential - var chartRepository *gRPC.ChartRepository + var registryCredential *client2.RegistryCredential + var chartRepository *client2.ChartRepository dockerRegistryId := appStoreAppVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs, err := impl.OCIRegistryConfigRepository.FindByDockerRegistryId(dockerRegistryId) @@ -92,7 +93,7 @@ func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *ap } } IsOCIRepo = true - registryCredential = &gRPC.RegistryCredential{ + registryCredential = &client2.RegistryCredential{ RegistryUrl: appStoreAppVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreAppVersion.AppStore.DockerArtifactStore.Username, Password: appStoreAppVersion.AppStore.DockerArtifactStore.Password, @@ -104,19 +105,19 @@ func (impl *EAModeDeploymentServiceImpl) InstallApp(installAppVersionRequest *ap IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &gRPC.ChartRepository{ + chartRepository = &client2.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, Password: appStoreAppVersion.AppStore.ChartRepo.Password, } } - installReleaseRequest := &gRPC.InstallReleaseRequest{ + installReleaseRequest := &client2.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: installAppVersionRequest.ValuesOverrideYaml, ChartRepository: chartRepository, - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + ReleaseIdentifier: &client2.ReleaseIdentifier{ ReleaseNamespace: installAppVersionRequest.Namespace, ReleaseName: installAppVersionRequest.AppName, }, @@ -200,7 +201,7 @@ func (impl *EAModeDeploymentServiceImpl) RollbackRelease(ctx context.Context, in return installedApp, success, nil } -func (impl *EAModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { +func (impl *EAModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client2.HelmAppDeploymentHistory, error) { helmAppIdentifier := &client.AppIdentifier{ ClusterId: installedApp.ClusterId, Namespace: installedApp.Namespace, @@ -222,8 +223,8 @@ func (impl *EAModeDeploymentServiceImpl) GetDeploymentHistoryInfo(ctx context.Co return nil, err } - req := &gRPC.DeploymentDetailRequest{ - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + req := &client2.DeploymentDetailRequest{ + ReleaseIdentifier: &client2.ReleaseIdentifier{ ClusterConfig: config, ReleaseName: helmAppIdeltifier.ReleaseName, ReleaseNamespace: helmAppIdeltifier.Namespace, @@ -258,8 +259,8 @@ func (impl *EAModeDeploymentServiceImpl) updateApplicationWithChartInfo(ctx cont return err } var IsOCIRepo bool - var registryCredential *gRPC.RegistryCredential - var chartRepository *gRPC.ChartRepository + var registryCredential *client2.RegistryCredential + var chartRepository *client2.ChartRepository dockerRegistryId := appStoreApplicationVersion.AppStore.DockerArtifactStoreId if dockerRegistryId != "" { ociRegistryConfigs, err := impl.OCIRegistryConfigRepository.FindByDockerRegistryId(dockerRegistryId) @@ -275,7 +276,7 @@ func (impl *EAModeDeploymentServiceImpl) updateApplicationWithChartInfo(ctx cont } } IsOCIRepo = true - registryCredential = &gRPC.RegistryCredential{ + registryCredential = &client2.RegistryCredential{ RegistryUrl: appStoreApplicationVersion.AppStore.DockerArtifactStore.RegistryURL, Username: appStoreApplicationVersion.AppStore.DockerArtifactStore.Username, Password: appStoreApplicationVersion.AppStore.DockerArtifactStore.Password, @@ -287,7 +288,7 @@ func (impl *EAModeDeploymentServiceImpl) updateApplicationWithChartInfo(ctx cont IsPublic: ociRegistryConfig.IsPublic, } } else { - chartRepository = &gRPC.ChartRepository{ + chartRepository = &client2.ChartRepository{ Name: appStoreApplicationVersion.AppStore.ChartRepo.Name, Url: appStoreApplicationVersion.AppStore.ChartRepo.Url, Username: appStoreApplicationVersion.AppStore.ChartRepo.UserName, @@ -296,9 +297,9 @@ func (impl *EAModeDeploymentServiceImpl) updateApplicationWithChartInfo(ctx cont } updateReleaseRequest := &bean2.UpdateApplicationWithChartInfoRequestDto{ - InstallReleaseRequest: &gRPC.InstallReleaseRequest{ + InstallReleaseRequest: &client2.InstallReleaseRequest{ ValuesYaml: valuesOverrideYaml, - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + ReleaseIdentifier: &client2.ReleaseIdentifier{ ReleaseNamespace: installedApp.Environment.Namespace, ReleaseName: installedApp.App.AppName, }, diff --git a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go index 65f9c1edeb..8a57bef06a 100644 --- a/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go +++ b/pkg/appStore/installedApp/service/FullMode/deployment/FullModeDeploymentService.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/common" repository5 "github.com/devtron-labs/devtron/pkg/cluster/repository" @@ -50,7 +50,7 @@ type FullModeDeploymentService interface { // RollbackRelease will rollback to a previous deployment for the given installedAppVersionHistoryId; returns - valuesYamlStr, success, error RollbackRelease(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, deploymentVersion int32, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, bool, error) // GetDeploymentHistory will return gRPC.HelmAppDeploymentHistory for the given installedAppDto.InstalledAppId - GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) + GetDeploymentHistory(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO) (*client2.HelmAppDeploymentHistory, error) // GetDeploymentHistoryInfo will return openapi.HelmAppDeploymentManifestDetail for the given appStoreBean.InstallAppVersionDTO GetDeploymentHistoryInfo(ctx context.Context, installedApp *appStoreBean.InstallAppVersionDTO, version int32) (*openapi.HelmAppDeploymentManifestDetail, error) @@ -335,9 +335,9 @@ func (impl *FullModeDeploymentServiceImpl) RollbackRelease(ctx context.Context, return installedApp, true, nil } -func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*gRPC.HelmAppDeploymentHistory, error) { - result := &gRPC.HelmAppDeploymentHistory{} - var history []*gRPC.HelmAppDeploymentDetail +func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Context, installedAppDto *appStoreBean.InstallAppVersionDTO) (*client2.HelmAppDeploymentHistory, error) { + result := &client2.HelmAppDeploymentHistory{} + var history []*client2.HelmAppDeploymentDetail //TODO - response setup installedAppVersions, err := impl.installedAppRepository.GetInstalledAppVersionByInstalledAppIdMeta(installedAppDto.InstalledAppId) @@ -370,8 +370,8 @@ func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Cont if user != nil { emailId = user.EmailId } - history = append(history, &gRPC.HelmAppDeploymentDetail{ - ChartMetadata: &gRPC.ChartMetadata{ + history = append(history, &client2.HelmAppDeploymentDetail{ + ChartMetadata: &client2.ChartMetadata{ ChartName: installedAppVersionModel.AppStoreApplicationVersion.AppStore.Name, ChartVersion: installedAppVersionModel.AppStoreApplicationVersion.Version, Description: installedAppVersionModel.AppStoreApplicationVersion.Description, @@ -391,7 +391,7 @@ func (impl *FullModeDeploymentServiceImpl) GetDeploymentHistory(ctx context.Cont } if len(history) == 0 { - history = make([]*gRPC.HelmAppDeploymentDetail, 0) + history = make([]*client2.HelmAppDeploymentDetail, 0) } result.DeploymentHistory = history return result, err diff --git a/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go index 9803558f04..9563331295 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/NotesService.go @@ -3,7 +3,7 @@ package resource import ( "context" "fmt" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "github.com/devtron-labs/devtron/internals/util" "github.com/go-pg/pg" "net/http" @@ -79,18 +79,18 @@ func (impl *InstalledAppResourceServiceImpl) findNotesForArgoApplication(install return notes, appName, err } - installReleaseRequest := &gRPC.InstallReleaseRequest{ + installReleaseRequest := &client.InstallReleaseRequest{ ChartName: appStoreAppVersion.Name, ChartVersion: appStoreAppVersion.Version, ValuesYaml: installedAppVerison.ValuesYaml, K8SVersion: k8sServerVersion.String(), - ChartRepository: &gRPC.ChartRepository{ + ChartRepository: &client.ChartRepository{ Name: appStoreAppVersion.AppStore.ChartRepo.Name, Url: appStoreAppVersion.AppStore.ChartRepo.Url, Username: appStoreAppVersion.AppStore.ChartRepo.UserName, Password: appStoreAppVersion.AppStore.ChartRepo.Password, }, - ReleaseIdentifier: &gRPC.ReleaseIdentifier{ + ReleaseIdentifier: &client.ReleaseIdentifier{ ReleaseNamespace: installedAppVerison.InstalledApp.Environment.Namespace, ReleaseName: installedAppVerison.InstalledApp.App.AppName, }, diff --git a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 8180a038a6..49f16b971f 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -10,6 +10,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internals/constants" @@ -92,7 +93,7 @@ func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Cont if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) } - req := &gRPC.AppDetailRequest{ + req := &client2.AppDetailRequest{ ClusterConfig: config, Namespace: installedApp.Environment.Namespace, ReleaseName: installedApp.App.AppName, @@ -390,9 +391,9 @@ func (impl *InstalledAppResourceServiceImpl) filterOutReplicaNodes(responseTreeN return replicaNodes } -func (impl *InstalledAppResourceServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *gRPC.ReleaseStatus { +func (impl *InstalledAppResourceServiceImpl) getReleaseStatusFromHelmReleaseInstallStatus(helmReleaseInstallStatus string, status string) *client2.ReleaseStatus { //release status is sent in resource tree call and is shown on UI as helm config apply status - releaseStatus := &gRPC.ReleaseStatus{} + releaseStatus := &client2.ReleaseStatus{} if len(helmReleaseInstallStatus) > 0 { helmInstallStatus := &appStoreBean.HelmReleaseStatusConfig{} err := json.Unmarshal([]byte(helmReleaseInstallStatus), helmInstallStatus) diff --git a/pkg/argoApplication/ArgoApplicationService.go b/pkg/argoApplication/ArgoApplicationService.go index f0afbf0d3d..c1f94d05cd 100644 --- a/pkg/argoApplication/ArgoApplicationService.go +++ b/pkg/argoApplication/ArgoApplicationService.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/common-lib/utils/k8s" @@ -194,10 +194,10 @@ func (impl *ArgoApplicationServiceImpl) GetAppDetail(resourceName, resourceNames } func (impl *ArgoApplicationServiceImpl) getResourceTreeForExternalCluster(clusterId int, destinationServer string, - configOfClusterWhereAppIsDeployed bean.ArgoClusterConfigObj, argoManagedResources []*bean.ArgoManagedResource) (*gRPC.ResourceTreeResponse, error) { - var resources []*gRPC.ExternalResourceDetail + configOfClusterWhereAppIsDeployed bean.ArgoClusterConfigObj, argoManagedResources []*bean.ArgoManagedResource) (*client.ResourceTreeResponse, error) { + var resources []*client.ExternalResourceDetail for _, argoManagedResource := range argoManagedResources { - resources = append(resources, &gRPC.ExternalResourceDetail{ + resources = append(resources, &client.ExternalResourceDetail{ Group: argoManagedResource.Group, Kind: argoManagedResource.Kind, Version: argoManagedResource.Version, @@ -205,9 +205,9 @@ func (impl *ArgoApplicationServiceImpl) getResourceTreeForExternalCluster(cluste Namespace: argoManagedResource.Namespace, }) } - var clusterConfigOfClusterWhereAppIsDeployed *gRPC.ClusterConfig + var clusterConfigOfClusterWhereAppIsDeployed *client.ClusterConfig if len(configOfClusterWhereAppIsDeployed.BearerToken) > 0 { - clusterConfigOfClusterWhereAppIsDeployed = &gRPC.ClusterConfig{ + clusterConfigOfClusterWhereAppIsDeployed = &client.ClusterConfig{ ApiServerUrl: destinationServer, Token: configOfClusterWhereAppIsDeployed.BearerToken, InsecureSkipTLSVerify: configOfClusterWhereAppIsDeployed.TlsClientConfig.Insecure, diff --git a/pkg/argoApplication/bean/bean.go b/pkg/argoApplication/bean/bean.go index 353ca17a28..2bb1a87e64 100644 --- a/pkg/argoApplication/bean/bean.go +++ b/pkg/argoApplication/bean/bean.go @@ -2,7 +2,7 @@ package bean import ( k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -43,8 +43,8 @@ type ArgoApplicationListDto struct { type ArgoApplicationDetailDto struct { *ArgoApplicationListDto - ResourceTree *gRPC.ResourceTreeResponse `json:"resourceTree"` - Manifest map[string]interface{} `json:"manifest"` + ResourceTree *client.ResourceTreeResponse `json:"resourceTree"` + Manifest map[string]interface{} `json:"manifest"` } type ArgoManagedResource struct { diff --git a/pkg/deployment/trigger/devtronApps/TriggerService.go b/pkg/deployment/trigger/devtronApps/TriggerService.go index a9d29a8451..f2b94cfdf9 100644 --- a/pkg/deployment/trigger/devtronApps/TriggerService.go +++ b/pkg/deployment/trigger/devtronApps/TriggerService.go @@ -9,6 +9,7 @@ import ( bean3 "github.com/devtron-labs/devtron/api/bean" bean6 "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client3 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client2 "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/client/argocdServer" bean7 "github.com/devtron-labs/devtron/client/argocdServer/bean" @@ -885,7 +886,7 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(overrideRequest *bean releaseName := pipeline.DeploymentAppName cluster := envOverride.Environment.Cluster bearerToken := cluster.Config[util5.BearerToken] - clusterConfig := &gRPC.ClusterConfig{ + clusterConfig := &client3.ClusterConfig{ ClusterName: cluster.ClusterName, Token: bearerToken, ApiServerUrl: cluster.ServerUrl, @@ -896,18 +897,18 @@ func (impl *TriggerServiceImpl) createHelmAppForCdPipeline(overrideRequest *bean clusterConfig.CertData = cluster.Config[util5.CertData] clusterConfig.CaData = cluster.Config[util5.CertificateAuthorityData] } - releaseIdentifier := &gRPC.ReleaseIdentifier{ + releaseIdentifier := &client3.ReleaseIdentifier{ ReleaseName: releaseName, ReleaseNamespace: envOverride.Namespace, ClusterConfig: clusterConfig, } if pipeline.DeploymentAppCreated { - req := &gRPC.UpgradeReleaseRequest{ + req := &client3.UpgradeReleaseRequest{ ReleaseIdentifier: releaseIdentifier, ValuesYaml: mergeAndSave, HistoryMax: impl.helmAppService.GetRevisionHistoryMaxValue(bean6.SOURCE_DEVTRON_APP), - ChartContent: &gRPC.ChartContent{Content: referenceChartByte}, + ChartContent: &client3.ChartContent{Content: referenceChartByte}, } if impl.IsDevtronAsyncInstallModeEnabled(bean.Helm) { req.RunInCtx = true @@ -1130,11 +1131,11 @@ func (impl *TriggerServiceImpl) updatePipeline(pipeline *pipelineConfig.Pipeline } // helmInstallReleaseWithCustomChart performs helm install with custom chart -func (impl *TriggerServiceImpl) helmInstallReleaseWithCustomChart(ctx context.Context, releaseIdentifier *gRPC.ReleaseIdentifier, referenceChartByte []byte, valuesYaml string) (*gRPC.HelmInstallCustomResponse, error) { +func (impl *TriggerServiceImpl) helmInstallReleaseWithCustomChart(ctx context.Context, releaseIdentifier *client3.ReleaseIdentifier, referenceChartByte []byte, valuesYaml string) (*client3.HelmInstallCustomResponse, error) { - helmInstallRequest := gRPC.HelmInstallCustomRequest{ + helmInstallRequest := client3.HelmInstallCustomRequest{ ValuesYaml: valuesYaml, - ChartContent: &gRPC.ChartContent{Content: referenceChartByte}, + ChartContent: &client3.ChartContent{Content: referenceChartByte}, ReleaseIdentifier: releaseIdentifier, } if impl.IsDevtronAsyncInstallModeEnabled(bean.Helm) { diff --git a/pkg/generateManifest/DeployementTemplateService.go b/pkg/generateManifest/DeployementTemplateService.go index c807ac2d37..b282e4a073 100644 --- a/pkg/generateManifest/DeployementTemplateService.go +++ b/pkg/generateManifest/DeployementTemplateService.go @@ -6,6 +6,7 @@ import ( "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/helm-app/bean" "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" "github.com/devtron-labs/devtron/internals/sql/repository" @@ -48,14 +49,14 @@ const ( Manifest RequestDataMode = 2 ) -var ChartRepository = &gRPC.ChartRepository{ +var ChartRepository = &client2.ChartRepository{ Name: "repo", Url: "http://localhost:8080/", Username: "admin", Password: "password", } -var ReleaseIdentifier = &gRPC.ReleaseIdentifier{ +var ReleaseIdentifier = &client2.ReleaseIdentifier{ ReleaseNamespace: "devtron-demo", ReleaseName: "release-name", } @@ -342,14 +343,14 @@ func (impl DeploymentTemplateServiceImpl) GenerateManifest(ctx context.Context, impl.Logger.Errorw("exception caught in getting k8sServerVersion", "err", err) return nil, err } - installReleaseRequest := &gRPC.InstallReleaseRequest{ + installReleaseRequest := &client2.InstallReleaseRequest{ ChartName: template, ChartVersion: version, ValuesYaml: valuesYaml, K8SVersion: k8sServerVersion.String(), ChartRepository: ChartRepository, ReleaseIdentifier: ReleaseIdentifier, - ChartContent: &gRPC.ChartContent{ + ChartContent: &client2.ChartContent{ Content: chartBytes, }, } diff --git a/pkg/generateManifest/DeployementTemplateService_test.go b/pkg/generateManifest/DeployementTemplateService_test.go index 305b7e1b65..b46db97069 100644 --- a/pkg/generateManifest/DeployementTemplateService_test.go +++ b/pkg/generateManifest/DeployementTemplateService_test.go @@ -6,7 +6,7 @@ import ( client2 "github.com/devtron-labs/authenticator/client" "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/devtron/api/bean" - client "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" mocks4 "github.com/devtron-labs/devtron/api/helm-app/mocks" "github.com/devtron-labs/devtron/internals/sql/repository" mocks3 "github.com/devtron-labs/devtron/internals/sql/repository/mocks" diff --git a/pkg/k8s/application/k8sApplicationService.go b/pkg/k8s/application/k8sApplicationService.go index 6544ff5bf5..ac4d3432b2 100644 --- a/pkg/k8s/application/k8sApplicationService.go +++ b/pkg/k8s/application/k8sApplicationService.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" "github.com/devtron-labs/common-lib/utils" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "io" @@ -449,7 +449,7 @@ func (impl *K8sApplicationServiceImpl) ValidateResourceRequest(ctx context.Conte return impl.validateContainerNameIfReqd(valid, request, app), nil } -func (impl *K8sApplicationServiceImpl) validateContainerNameIfReqd(valid bool, request *k8s2.K8sRequestBean, app *gRPC.AppDetail) bool { +func (impl *K8sApplicationServiceImpl) validateContainerNameIfReqd(valid bool, request *k8s2.K8sRequestBean, app *client2.AppDetail) bool { if !valid { requestContainerName := request.PodLogsRequest.ContainerName podName := request.ResourceIdentifier.Name diff --git a/pkg/module/ModuleCronService.go b/pkg/module/ModuleCronService.go index 3f62ca58c6..04e81bc457 100644 --- a/pkg/module/ModuleCronService.go +++ b/pkg/module/ModuleCronService.go @@ -21,7 +21,7 @@ import ( "context" "encoding/json" "fmt" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleDataStore "github.com/devtron-labs/devtron/pkg/module/store" @@ -160,7 +160,7 @@ func (impl *ModuleCronServiceImpl) handleModuleStatus(moduleNameInput string) { } -func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDetail *gRPC.AppDetail) error { +func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDetail *client2.AppDetail) error { impl.logger.Infow("updating module resources status", "moduleId", moduleId) if appDetail == nil || appDetail.ResourceTreeResponse == nil { return nil @@ -235,7 +235,7 @@ func (impl *ModuleCronServiceImpl) saveModuleResourcesStatus(moduleId int, appDe return nil } -func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (*gRPC.ResourceTreeFilter, error) { +func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (*client2.ResourceTreeFilter, error) { moduleMetaData, err := impl.moduleServiceHelper.GetModuleMetadata(moduleName) if err != nil { impl.logger.Errorw("Error in getting module metadata", "moduleName", moduleName, "err", err) @@ -256,13 +256,13 @@ func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (* return nil, err } - var resourceTreeFilter *gRPC.ResourceTreeFilter + var resourceTreeFilter *client2.ResourceTreeFilter // handle global filter globalFilter := resourceFilterIfaceValue.GlobalFilter if globalFilter != nil { - resourceTreeFilter = &gRPC.ResourceTreeFilter{ - GlobalFilter: &gRPC.ResourceIdentifier{ + resourceTreeFilter = &client2.ResourceTreeFilter{ + GlobalFilter: &client2.ResourceIdentifier{ Labels: globalFilter.Labels, }, } @@ -270,21 +270,21 @@ func (impl *ModuleCronServiceImpl) buildResourceTreeFilter(moduleName string) (* } // otherwise handle gvk level - var resourceFilters []*gRPC.ResourceFilter + var resourceFilters []*client2.ResourceFilter for _, gvkLevelFilters := range resourceFilterIfaceValue.GvkLevelFilters { gvk := gvkLevelFilters.Gvk - resourceFilters = append(resourceFilters, &gRPC.ResourceFilter{ - Gvk: &gRPC.Gvk{ + resourceFilters = append(resourceFilters, &client2.ResourceFilter{ + Gvk: &client2.Gvk{ Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind, }, - ResourceIdentifier: &gRPC.ResourceIdentifier{ + ResourceIdentifier: &client2.ResourceIdentifier{ Labels: gvkLevelFilters.ResourceIdentifier.Labels, }, }) } - resourceTreeFilter = &gRPC.ResourceTreeFilter{ + resourceTreeFilter = &client2.ResourceTreeFilter{ ResourceFilters: resourceFilters, } return resourceTreeFilter, nil diff --git a/pkg/module/ModuleService.go b/pkg/module/ModuleService.go index 4c2b381b0b..010025249b 100644 --- a/pkg/module/ModuleService.go +++ b/pkg/module/ModuleService.go @@ -21,7 +21,7 @@ import ( "context" "errors" "github.com/caarlos0/env/v6" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/internals/sql/repository/security" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" @@ -396,7 +396,7 @@ func (impl ModuleServiceImpl) HandleModuleAction(userId int32, moduleName string // HELM_OPERATION Starts devtronHelmAppIdentifier := impl.helmAppService.GetDevtronHelmAppIdentifier() - chartRepository := &gRPC.ChartRepository{ + chartRepository := &client2.ChartRepository{ Name: impl.serverEnvConfig.DevtronHelmRepoName, Url: impl.serverEnvConfig.DevtronHelmRepoUrl, } diff --git a/pkg/pipeline/DockerRegistryConfig.go b/pkg/pipeline/DockerRegistryConfig.go index 91af445b5e..2a346e6cfb 100644 --- a/pkg/pipeline/DockerRegistryConfig.go +++ b/pkg/pipeline/DockerRegistryConfig.go @@ -20,7 +20,7 @@ package pipeline import ( "context" "fmt" - bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/sql" diff --git a/pkg/pipeline/DockerRegistryConfig_test.go b/pkg/pipeline/DockerRegistryConfig_test.go index 9e18e9f95d..0d6376b1cf 100644 --- a/pkg/pipeline/DockerRegistryConfig_test.go +++ b/pkg/pipeline/DockerRegistryConfig_test.go @@ -3,7 +3,7 @@ package pipeline import ( "context" "fmt" - client "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" "github.com/devtron-labs/devtron/api/helm-app/mocks" repository "github.com/devtron-labs/devtron/internals/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/pkg/dockerRegistry" diff --git a/pkg/server/ServerService.go b/pkg/server/ServerService.go index 75a19c99f6..34bf9f5902 100644 --- a/pkg/server/ServerService.go +++ b/pkg/server/ServerService.go @@ -20,7 +20,7 @@ package server import ( "context" "errors" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + client2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo" moduleUtil "github.com/devtron-labs/devtron/pkg/module/util" @@ -131,7 +131,7 @@ func (impl ServerServiceImpl) HandleServerAction(userId int32, serverActionReque // HELM_OPERATION Starts devtronHelmAppIdentifier := impl.helmAppService.GetDevtronHelmAppIdentifier() - chartRepository := &gRPC.ChartRepository{ + chartRepository := &client2.ChartRepository{ Name: impl.serverEnvConfig.DevtronHelmRepoName, Url: impl.serverEnvConfig.DevtronHelmRepoUrl, } diff --git a/pkg/webhook/helm/WebhookHelmService.go b/pkg/webhook/helm/WebhookHelmService.go index 1058bd728c..eb7762202e 100644 --- a/pkg/webhook/helm/WebhookHelmService.go +++ b/pkg/webhook/helm/WebhookHelmService.go @@ -21,7 +21,7 @@ import ( "context" "fmt" "github.com/devtron-labs/devtron/api/helm-app/bean" - bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC" + bean2 "github.com/devtron-labs/devtron/api/helm-app/gRPC/client" client "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/pkg/attributes" From 202b77eb4cd39a441350cd5edfb2f026cb8d1d5c Mon Sep 17 00:00:00 2001 From: ShashwatDadhich Date: Fri, 1 Mar 2024 17:35:20 +0530 Subject: [PATCH 83/83] struct refactored --- pkg/pipeline/types/CiCdConfig.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/pipeline/types/CiCdConfig.go b/pkg/pipeline/types/CiCdConfig.go index 87d90f27f3..98fbec0332 100644 --- a/pkg/pipeline/types/CiCdConfig.go +++ b/pkg/pipeline/types/CiCdConfig.go @@ -92,6 +92,8 @@ type CiCdConfig struct { UseBlobStorageConfigInCdWorkflow bool `env:"USE_BLOB_STORAGE_CONFIG_IN_CD_WORKFLOW" envDefault:"true"` CdWorkflowExecutorType pipelineConfig.WorkflowExecutorType `env:"CD_WORKFLOW_EXECUTOR_TYPE" envDefault:"AWF"` TerminationGracePeriod int `env:"TERMINATION_GRACE_PERIOD_SECS" envDefault:"180"` + CloningMode string `env:"CLONING_MODE" envDefault:"SHALLOW"` + GitProviders string `env:"GIT_PROVIDERS" envDefault:"github,gitlab"` MaxCdWorkflowRunnerRetries int `env:"MAX_CD_WORKFLOW_RUNNER_RETRIES" envDefault:"0"` // common in both ciconfig and cd config @@ -120,6 +122,7 @@ type CiCdConfig struct { BuildxProvenanceMode string `env:"BUILDX_PROVENANCE_MODE" envDefault:""` // provenance is set to false if this flag is not set ExtBlobStorageCmName string `env:"EXTERNAL_BLOB_STORAGE_CM_NAME" envDefault:"blob-storage-cm"` ExtBlobStorageSecretName string `env:"EXTERNAL_BLOB_STORAGE_SECRET_NAME" envDefault:"blob-storage-secret"` + CanApproverDeploy bool `env:"CAN_APPROVER_DEPLOY" envDefault:"false"` UseArtifactListingQueryV2 bool `env:"USE_ARTIFACT_LISTING_QUERY_V2" envDefault:"true"` UseImageTagFromGitProviderForTagBasedBuild bool `env:"USE_IMAGE_TAG_FROM_GIT_PROVIDER_FOR_TAG_BASED_BUILD" envDefault:"false"` // this is being done for https://github.com/devtron-labs/devtron/issues/4263 }