Skip to content

Commit

Permalink
Merge pull request #4616 from devtron-labs/refactoring-template-gitOp…
Browse files Browse the repository at this point in the history
…s-appStore

chore: Refactoring deployment template GitOps & AppStore
  • Loading branch information
nishant-d committed Feb 6, 2024
2 parents 95f7e2d + 93f6cdf commit 05f8197
Show file tree
Hide file tree
Showing 135 changed files with 5,292 additions and 5,832 deletions.
27 changes: 6 additions & 21 deletions Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ 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"
"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"
Expand All @@ -100,6 +98,8 @@ 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"
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"
Expand Down Expand Up @@ -161,6 +161,8 @@ func InitializeApp() (*App, error) {
apiToken.ApiTokenWireSet,
webhookHelm.WebhookHelmWireSet,
terminal.TerminalWireSet,
deployment2.DeploymentWireSet,

// -------wireset end ----------
//-------
gitSensor.GetConfig,
Expand All @@ -174,10 +176,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,

Expand Down Expand Up @@ -265,8 +263,6 @@ func InitializeApp() (*App, error) {

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,
Expand Down Expand Up @@ -335,8 +331,6 @@ func InitializeApp() (*App, error) {
eClient.NewEventRESTClientImpl,
wire.Bind(new(eClient.EventClient), new(*eClient.EventRESTClientImpl)),

util3.NewTokenCache,

eClient.NewEventSimpleFactoryImpl,
wire.Bind(new(eClient.EventFactory), new(*eClient.EventSimpleFactoryImpl)),

Expand All @@ -353,7 +347,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)),
Expand Down Expand Up @@ -527,11 +521,6 @@ func InitializeApp() (*App, error) {

restHandler.NewExternalCiRestHandlerImpl,
wire.Bind(new(restHandler.ExternalCiRestHandler), new(*restHandler.ExternalCiRestHandlerImpl)),
repository.NewAppLevelMetricsRepositoryImpl,
wire.Bind(new(repository.AppLevelMetricsRepository), new(*repository.AppLevelMetricsRepositoryImpl)),

repository.NewEnvLevelAppMetricsRepositoryImpl,
wire.Bind(new(repository.EnvLevelAppMetricsRepository), new(*repository.EnvLevelAppMetricsRepositoryImpl)),

grafana.GetGrafanaClientConfig,
grafana.NewGrafanaClientImpl,
Expand Down Expand Up @@ -649,8 +638,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)),
Expand All @@ -671,7 +658,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)),
Expand Down Expand Up @@ -732,8 +719,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,
Expand Down
2 changes: 1 addition & 1 deletion api/appStore/InstalledAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/json"
"errors"
"fmt"
service2 "github.com/devtron-labs/devtron/api/helm-app/service"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -67,15 +68,15 @@ 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
}

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,
Expand Down
50 changes: 24 additions & 26 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
service2 "github.com/devtron-labs/devtron/api/helm-app/service"
"net/http"
"strconv"
"time"
Expand All @@ -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"
Expand All @@ -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) {
Expand All @@ -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.StatusBadRequest, UserMessage: "unable to find app in database"}
return appOfferingMode, installedAppDto, err
Expand All @@ -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.StatusBadRequest, UserMessage: "unable to find app in database"}
return appOfferingMode, installedAppDto, err
Expand Down
1 change: 1 addition & 0 deletions api/bean/GitOpsConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
7 changes: 1 addition & 6 deletions api/chartRepo/ChartRepositoryRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,23 +63,19 @@ 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,
userAuthService: userAuthService,
enforcer: enforcer,
validator: validator,
deleteService: deleteService,
chartRefRepository: chartRefRepository,
refChartDir: refChartDir,
attributesService: attributesService,
}
}
Expand Down

0 comments on commit 05f8197

Please sign in to comment.