44	"context" 
55	"encoding/json" 
66	"errors" 
7+ 	"github.com/devtron-labs/devtron/api/helm-app/bean" 
8+ 	service2 "github.com/devtron-labs/devtron/api/helm-app/service" 
9+ 	"github.com/devtron-labs/devtron/pkg/appStore/deployment/service" 
710	"net/http" 
811	"strconv" 
912	"strings" 
@@ -14,8 +17,6 @@ import (
1417	openapi2 "github.com/devtron-labs/devtron/api/openapi/openapiClient" 
1518	"github.com/devtron-labs/devtron/api/restHandler/common" 
1619	"github.com/devtron-labs/devtron/internal/util" 
17- 	appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean" 
18- 	appStoreDeploymentCommon "github.com/devtron-labs/devtron/pkg/appStore/deployment/common" 
1920	"github.com/devtron-labs/devtron/pkg/attributes" 
2021	"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" 
2122	"github.com/devtron-labs/devtron/pkg/auth/user" 
@@ -43,31 +44,32 @@ const HELM_APP_ACCESS_COUNTER = "HelmAppAccessCounter"
4344const  HELM_APP_UPDATE_COUNTER  =  "HelmAppUpdateCounter" 
4445
4546type  HelmAppRestHandlerImpl  struct  {
46- 	logger                            * zap.SugaredLogger 
47- 	helmAppService                    HelmAppService 
48- 	enforcer                          casbin.Enforcer 
49- 	clusterService                    cluster.ClusterService 
50- 	enforcerUtil                      rbac.EnforcerUtilHelm 
51- 	appStoreDeploymentCommonService  appStoreDeploymentCommon. AppStoreDeploymentCommonService 
52- 	userAuthService                   user.UserService 
53- 	attributesService                 attributes.AttributesService 
54- 	serverEnvConfig                   * serverEnvConfig.ServerEnvConfig 
47+ 	logger                     * zap.SugaredLogger 
48+ 	helmAppService             service2. HelmAppService 
49+ 	enforcer                   casbin.Enforcer 
50+ 	clusterService             cluster.ClusterService 
51+ 	enforcerUtil               rbac.EnforcerUtilHelm 
52+ 	appStoreDeploymentService  service. AppStoreDeploymentService 
53+ 	userAuthService            user.UserService 
54+ 	attributesService          attributes.AttributesService 
55+ 	serverEnvConfig            * serverEnvConfig.ServerEnvConfig 
5556}
5657
5758func  NewHelmAppRestHandlerImpl (logger  * zap.SugaredLogger ,
58- 	helmAppService  HelmAppService , enforcer  casbin.Enforcer ,
59- 	clusterService  cluster.ClusterService , enforcerUtil  rbac.EnforcerUtilHelm , appStoreDeploymentCommonService  appStoreDeploymentCommon.AppStoreDeploymentCommonService ,
59+ 	helmAppService  service2.HelmAppService , enforcer  casbin.Enforcer ,
60+ 	clusterService  cluster.ClusterService , enforcerUtil  rbac.EnforcerUtilHelm ,
61+ 	appStoreDeploymentService  service.AppStoreDeploymentService ,
6062	userAuthService  user.UserService , attributesService  attributes.AttributesService , serverEnvConfig  * serverEnvConfig.ServerEnvConfig ) * HelmAppRestHandlerImpl  {
6163	return  & HelmAppRestHandlerImpl {
62- 		logger :                           logger ,
63- 		helmAppService :                   helmAppService ,
64- 		enforcer :                         enforcer ,
65- 		clusterService :                   clusterService ,
66- 		enforcerUtil :                     enforcerUtil ,
67- 		appStoreDeploymentCommonService :  appStoreDeploymentCommonService ,
68- 		userAuthService :                  userAuthService ,
69- 		attributesService :                attributesService ,
70- 		serverEnvConfig :                  serverEnvConfig ,
64+ 		logger :                    logger ,
65+ 		helmAppService :            helmAppService ,
66+ 		enforcer :                  enforcer ,
67+ 		clusterService :            clusterService ,
68+ 		enforcerUtil :              enforcerUtil ,
69+ 		appStoreDeploymentService :  appStoreDeploymentService ,
70+ 		userAuthService :           userAuthService ,
71+ 		attributesService :         attributesService ,
72+ 		serverEnvConfig :           serverEnvConfig ,
7173	}
7274}
7375
@@ -118,15 +120,15 @@ func (handler *HelmAppRestHandlerImpl) GetApplicationDetail(w http.ResponseWrite
118120		return 
119121	}
120122
121- 	installedApp , err  :=  handler .appStoreDeploymentCommonService .GetInstalledAppByClusterNamespaceAndName (appIdentifier .ClusterId , appIdentifier .Namespace , appIdentifier .ReleaseName )
123+ 	installedApp , err  :=  handler .appStoreDeploymentService .GetInstalledAppByClusterNamespaceAndName (appIdentifier .ClusterId , appIdentifier .Namespace , appIdentifier .ReleaseName )
122124	if  err  !=  nil  {
123125		common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
124126		return 
125127	}
126128
127- 	res  :=  & AppDetailAndInstalledAppInfo {
129+ 	res  :=  & bean. AppDetailAndInstalledAppInfo {
128130		AppDetail :        appdetail ,
129- 		InstalledAppInfo : convertToInstalledAppInfo (installedApp ),
131+ 		InstalledAppInfo : bean . ConvertToInstalledAppInfo (installedApp ),
130132	}
131133
132134	common .WriteJsonResp (w , err , res , http .StatusOK )
@@ -219,15 +221,15 @@ func (handler *HelmAppRestHandlerImpl) GetReleaseInfo(w http.ResponseWriter, r *
219221		common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
220222		return 
221223	}
222- 
223- 	installedApp , err  :=  handler .appStoreDeploymentCommonService .GetInstalledAppByClusterNamespaceAndName (appIdentifier .ClusterId , appIdentifier .Namespace , appIdentifier .ReleaseName )
224+ 	installedApp , err  :=  handler .appStoreDeploymentService .GetInstalledAppByClusterNamespaceAndName (appIdentifier .ClusterId , appIdentifier .Namespace , appIdentifier .ReleaseName )
224225	if  err  !=  nil  {
225226		common .WriteJsonResp (w , err , nil , http .StatusInternalServerError )
226227		return 
227228	}
228- 	res  :=  & ReleaseAndInstalledAppInfo {
229+ 
230+ 	res  :=  & bean.ReleaseAndInstalledAppInfo {
229231		ReleaseInfo :      releaseInfo ,
230- 		InstalledAppInfo : convertToInstalledAppInfo (installedApp ),
232+ 		InstalledAppInfo : bean . ConvertToInstalledAppInfo (installedApp ),
231233	}
232234
233235	common .WriteJsonResp (w , err , res , http .StatusOK )
@@ -306,7 +308,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter,
306308	// validate if the devtron-operator helm release, block that for deletion 
307309	if  appIdentifier .ReleaseName  ==  handler .serverEnvConfig .DevtronHelmReleaseName  && 
308310		appIdentifier .Namespace  ==  handler .serverEnvConfig .DevtronHelmReleaseNamespace  && 
309- 		appIdentifier .ClusterId  ==  DEFAULT_CLUSTER_ID  {
311+ 		appIdentifier .ClusterId  ==  bean . DEFAULT_CLUSTER_ID  {
310312		common .WriteJsonResp (w , errors .New ("cannot delete this default helm app" ), nil , http .StatusForbidden )
311313		return 
312314	}
@@ -323,7 +325,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter,
323325}
324326
325327func  (handler  * HelmAppRestHandlerImpl ) UpdateApplication (w  http.ResponseWriter , r  * http.Request ) {
326- 	request  :=  & UpdateApplicationRequestDto {}
328+ 	request  :=  & bean. UpdateApplicationRequestDto {}
327329	decoder  :=  json .NewDecoder (r .Body )
328330	err  :=  decoder .Decode (request )
329331	if  err  !=  nil  {
@@ -346,7 +348,7 @@ func (handler *HelmAppRestHandlerImpl) UpdateApplication(w http.ResponseWriter,
346348		return 
347349	}
348350	//RBAC enforcer Ends 
349- 	request .SourceAppType  =  SOURCE_EXTERNAL_HELM_APP 
351+ 	request .SourceAppType  =  bean . SOURCE_EXTERNAL_HELM_APP 
350352	// update application externally 
351353	res , err  :=  handler .helmAppService .UpdateApplication (r .Context (), appIdentifier , request )
352354	if  err  !=  nil  {
@@ -422,57 +424,3 @@ func (handler *HelmAppRestHandlerImpl) SaveHelmAppDetailsViewedTelemetryData(w h
422424	common .WriteJsonResp (w , err , nil , http .StatusOK )
423425
424426}
425- 
426- func  convertToInstalledAppInfo (installedApp  * appStoreBean.InstallAppVersionDTO ) * InstalledAppInfo  {
427- 	if  installedApp  ==  nil  {
428- 		return  nil 
429- 	}
430- 
431- 	chartInfo  :=  installedApp .InstallAppVersionChartDTO 
432- 
433- 	return  & InstalledAppInfo {
434- 		AppId :                 installedApp .AppId ,
435- 		EnvironmentName :       installedApp .EnvironmentName ,
436- 		AppOfferingMode :       installedApp .AppOfferingMode ,
437- 		InstalledAppId :        installedApp .InstalledAppId ,
438- 		InstalledAppVersionId : installedApp .InstalledAppVersionId ,
439- 		AppStoreChartId :       chartInfo .AppStoreChartId ,
440- 		ClusterId :             installedApp .ClusterId ,
441- 		EnvironmentId :         installedApp .EnvironmentId ,
442- 		AppStoreChartRepoName : chartInfo .InstallAppVersionChartRepoDTO .RepoName ,
443- 		AppStoreChartName :     chartInfo .ChartName ,
444- 		TeamId :                installedApp .TeamId ,
445- 		TeamName :              installedApp .TeamName ,
446- 	}
447- }
448- 
449- type  AppDetailAndInstalledAppInfo  struct  {
450- 	InstalledAppInfo  * InstalledAppInfo  `json:"installedAppInfo"` 
451- 	AppDetail         * AppDetail         `json:"appDetail"` 
452- }
453- 
454- type  ReleaseAndInstalledAppInfo  struct  {
455- 	InstalledAppInfo  * InstalledAppInfo  `json:"installedAppInfo"` 
456- 	ReleaseInfo       * ReleaseInfo       `json:"releaseInfo"` 
457- }
458- 
459- type  DeploymentHistoryAndInstalledAppInfo  struct  {
460- 	InstalledAppInfo   * InstalledAppInfo           `json:"installedAppInfo"` 
461- 	DeploymentHistory  []* HelmAppDeploymentDetail  `json:"deploymentHistory"` 
462- }
463- 
464- type  InstalledAppInfo  struct  {
465- 	AppId                  int     `json:"appId"` 
466- 	InstalledAppId         int     `json:"installedAppId"` 
467- 	InstalledAppVersionId  int     `json:"installedAppVersionId"` 
468- 	AppStoreChartId        int     `json:"appStoreChartId"` 
469- 	EnvironmentName        string  `json:"environmentName"` 
470- 	AppOfferingMode        string  `json:"appOfferingMode"` 
471- 	ClusterId              int     `json:"clusterId"` 
472- 	EnvironmentId          int     `json:"environmentId"` 
473- 	AppStoreChartRepoName  string  `json:"appStoreChartRepoName"` 
474- 	AppStoreChartName      string  `json:"appStoreChartName"` 
475- 	TeamId                 int     `json:"teamId"` 
476- 	TeamName               string  `json:"teamName"` 
477- 	DeploymentType         string  `json:"deploymentType"` 
478- }
0 commit comments