@@ -23,6 +23,8 @@ import (
23
23
"errors"
24
24
"fmt"
25
25
client "github.com/devtron-labs/devtron/api/helm-app/gRPC"
26
+ "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode"
27
+ "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource"
26
28
"net/http"
27
29
"strconv"
28
30
"strings"
@@ -39,8 +41,8 @@ import (
39
41
app2 "github.com/devtron-labs/devtron/pkg/app"
40
42
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
41
43
"github.com/devtron-labs/devtron/pkg/appStore/chartGroup"
42
- "github.com/devtron-labs/devtron/pkg/appStore/deployment /repository"
43
- "github.com/devtron-labs/devtron/pkg/appStore/deployment /service"
44
+ "github.com/devtron-labs/devtron/pkg/appStore/installedApp /repository"
45
+ "github.com/devtron-labs/devtron/pkg/appStore/installedApp /service"
44
46
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
45
47
"github.com/devtron-labs/devtron/pkg/auth/user"
46
48
"github.com/devtron-labs/devtron/pkg/cluster"
@@ -75,7 +77,9 @@ type InstalledAppRestHandlerImpl struct {
75
77
enforcer casbin.Enforcer
76
78
enforcerUtil rbac.EnforcerUtil
77
79
enforcerUtilHelm rbac.EnforcerUtilHelm
78
- installedAppService service.InstalledAppService
80
+ installedAppService FullMode.InstalledAppDBExtendedService
81
+ installedAppResourceService resource.InstalledAppResourceService
82
+ chartGroupService chartGroup.ChartGroupService
79
83
validator * validator.Validate
80
84
clusterService cluster.ClusterService
81
85
acdServiceClient application.ServiceClient
@@ -89,10 +93,11 @@ type InstalledAppRestHandlerImpl struct {
89
93
}
90
94
91
95
func NewInstalledAppRestHandlerImpl (Logger * zap.SugaredLogger , userAuthService user.UserService ,
92
- enforcer casbin.Enforcer , enforcerUtil rbac.EnforcerUtil , enforcerUtilHelm rbac.EnforcerUtilHelm , installedAppService service.InstalledAppService ,
93
- validator * validator.Validate , clusterService cluster.ClusterService , acdServiceClient application.ServiceClient ,
94
- appStoreDeploymentService service.AppStoreDeploymentService , helmAppClient client.HelmAppClient ,
95
- argoUserService argo.ArgoUserService ,
96
+ enforcer casbin.Enforcer , enforcerUtil rbac.EnforcerUtil , enforcerUtilHelm rbac.EnforcerUtilHelm ,
97
+ installedAppService FullMode.InstalledAppDBExtendedService , installedAppResourceService resource.InstalledAppResourceService ,
98
+ chartGroupService chartGroup.ChartGroupService , validator * validator.Validate , clusterService cluster.ClusterService ,
99
+ acdServiceClient application.ServiceClient , appStoreDeploymentService service.AppStoreDeploymentService ,
100
+ helmAppClient client.HelmAppClient , argoUserService argo.ArgoUserService ,
96
101
cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler ,
97
102
installedAppRepository repository.InstalledAppRepository ,
98
103
appCrudOperationService app2.AppCrudOperationService ) * InstalledAppRestHandlerImpl {
@@ -103,6 +108,8 @@ func NewInstalledAppRestHandlerImpl(Logger *zap.SugaredLogger, userAuthService u
103
108
enforcerUtil : enforcerUtil ,
104
109
enforcerUtilHelm : enforcerUtilHelm ,
105
110
installedAppService : installedAppService ,
111
+ installedAppResourceService : installedAppResourceService ,
112
+ chartGroupService : chartGroupService ,
106
113
validator : validator ,
107
114
clusterService : clusterService ,
108
115
acdServiceClient : acdServiceClient ,
@@ -371,7 +378,7 @@ func (handler *InstalledAppRestHandlerImpl) DeployBulk(w http.ResponseWriter, r
371
378
return
372
379
}
373
380
}
374
- res , err := handler .installedAppService .DeployBulk (& request )
381
+ res , err := handler .chartGroupService .DeployBulk (& request )
375
382
if err != nil {
376
383
handler .Logger .Errorw ("service err, DeployBulk" , "err" , err , "payload" , request )
377
384
common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
@@ -433,7 +440,7 @@ func (impl *InstalledAppRestHandlerImpl) DefaultComponentInstallation(w http.Res
433
440
return
434
441
}
435
442
// RBAC enforcer ends
436
- isTriggered , err := impl .installedAppService .DeployDefaultChartOnCluster (cluster , userId )
443
+ isTriggered , err := impl .chartGroupService .DeployDefaultChartOnCluster (cluster , userId )
437
444
if err != nil {
438
445
impl .Logger .Errorw ("service err, DefaultComponentInstallation" , "error" , err , "cluster" , cluster )
439
446
common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
@@ -462,7 +469,7 @@ func (handler *InstalledAppRestHandlerImpl) FetchNotesForArgoInstalledApp(w http
462
469
return
463
470
}
464
471
handler .Logger .Infow ("request payload, FetchNotesForArgoInstalledApp, app store" , "installedAppId" , installedAppId , "envId" , envId )
465
- notes , err := handler .installedAppService .FetchChartNotes (installedAppId , envId , token , handler .checkNotesAuth )
472
+ notes , err := handler .installedAppResourceService .FetchChartNotes (installedAppId , envId , token , handler .checkNotesAuth )
466
473
if err != nil {
467
474
handler .Logger .Errorw ("service err, FetchNotesFromdb, app store" , "err" , err , "installedAppId" , installedAppId , "envId" , envId )
468
475
common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
@@ -621,7 +628,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledApp(w htt
621
628
apiError , ok := err .(* util2.ApiError )
622
629
if ok && apiError != nil {
623
630
if apiError .Code == constants .AppDetailResourceTreeNotFound && installedApp .DeploymentAppDeleteRequest == true {
624
- err = handler .installedAppService .MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted (installedAppId , envId )
631
+ // TODO refactoring: should be performed through nats
632
+ err = handler .appStoreDeploymentService .MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted (installedAppId , envId )
625
633
appDeleteErr , appDeleteErrOk := err .(* util2.ApiError )
626
634
if appDeleteErrOk && appDeleteErr != nil {
627
635
handler .Logger .Errorw (appDeleteErr .InternalMessage )
@@ -738,7 +746,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri
738
746
apiError , ok := err .(* util2.ApiError )
739
747
if ok && apiError != nil {
740
748
if apiError .Code == constants .AppDetailResourceTreeNotFound && installedApp .DeploymentAppDeleteRequest == true {
741
- err = handler .installedAppService .MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted (installedAppId , envId )
749
+ // TODO refactoring: should be performed in go routine
750
+ err = handler .appStoreDeploymentService .MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted (installedAppId , envId )
742
751
appDeleteErr , appDeleteErrOk := err .(* util2.ApiError )
743
752
if appDeleteErrOk && appDeleteErr != nil {
744
753
handler .Logger .Errorw (appDeleteErr .InternalMessage )
@@ -825,12 +834,12 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTreeForACDApp(w http.Re
825
834
func (handler * InstalledAppRestHandlerImpl ) fetchResourceTree (w http.ResponseWriter , r * http.Request , resourceTreeAndNotesContainer * bean2.AppDetailsContainer , installedApp repository.InstalledApps , helmReleaseInstallStatus string , status string ) error {
826
835
ctx := r .Context ()
827
836
cn , _ := w .(http.CloseNotifier )
828
- err := handler .installedAppService .FetchResourceTree (ctx , cn , resourceTreeAndNotesContainer , installedApp , helmReleaseInstallStatus , status )
837
+ err := handler .installedAppResourceService .FetchResourceTree (ctx , cn , resourceTreeAndNotesContainer , installedApp , helmReleaseInstallStatus , status )
829
838
return err
830
839
}
831
840
832
841
func (handler * InstalledAppRestHandlerImpl ) fetchResourceTreeWithHibernateForACD (w http.ResponseWriter , r * http.Request , appDetail * bean2.AppDetailContainer ) {
833
842
ctx := r .Context ()
834
843
cn , _ := w .(http.CloseNotifier )
835
- handler .installedAppService .FetchResourceTreeWithHibernateForACD (ctx , cn , appDetail )
844
+ handler .installedAppResourceService .FetchResourceTreeWithHibernateForACD (ctx , cn , appDetail )
836
845
}
0 commit comments