@@ -26,6 +26,7 @@ import (
26
26
"github.com/devtron-labs/devtron/api/helm-app/gRPC"
27
27
"github.com/devtron-labs/devtron/api/helm-app/models"
28
28
helmBean "github.com/devtron-labs/devtron/api/helm-app/service/bean"
29
+ "github.com/devtron-labs/devtron/api/helm-app/service/read"
29
30
"github.com/devtron-labs/devtron/internal/constants"
30
31
repository2 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
31
32
"github.com/go-pg/pg"
@@ -82,7 +83,6 @@ type HelmAppService interface {
82
83
UpdateApplicationWithChartInfo (ctx context.Context , clusterId int , request * bean.UpdateApplicationWithChartInfoRequestDto ) (* openapi.UpdateReleaseResponse , error )
83
84
IsReleaseInstalled (ctx context.Context , app * helmBean.AppIdentifier ) (bool , error )
84
85
RollbackRelease (ctx context.Context , app * helmBean.AppIdentifier , version int32 ) (bool , error )
85
- GetClusterConf (clusterId int ) (* gRPC.ClusterConfig , error )
86
86
GetDevtronHelmAppIdentifier () * helmBean.AppIdentifier
87
87
UpdateApplicationWithChartInfoWithExtraValues (ctx context.Context , appIdentifier * helmBean.AppIdentifier , chartRepository * gRPC.ChartRepository , extraValues map [string ]interface {}, extraValuesYamlUrl string , useLatestChartVersion bool ) (* openapi.UpdateReleaseResponse , error )
88
88
TemplateChart (ctx context.Context , templateChartRequest * openapi2.TemplateChartRequest ) (* openapi2.TemplateChartResponse , error )
@@ -109,6 +109,7 @@ type HelmAppServiceImpl struct {
109
109
clusterRepository clusterRepository.ClusterRepository
110
110
K8sUtil * k8s.K8sServiceImpl
111
111
helmReleaseConfig * HelmReleaseConfig
112
+ helmAppReadService read.HelmAppReadService
112
113
}
113
114
114
115
func NewHelmAppServiceImpl (Logger * zap.SugaredLogger , clusterService cluster.ClusterService ,
@@ -118,7 +119,8 @@ func NewHelmAppServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.Clu
118
119
environmentService cluster.EnvironmentService , pipelineRepository pipelineConfig.PipelineRepository ,
119
120
installedAppRepository repository.InstalledAppRepository , appRepository app.AppRepository ,
120
121
clusterRepository clusterRepository.ClusterRepository , K8sUtil * k8s.K8sServiceImpl ,
121
- helmReleaseConfig * HelmReleaseConfig ) * HelmAppServiceImpl {
122
+ helmReleaseConfig * HelmReleaseConfig ,
123
+ helmAppReadService read.HelmAppReadService ) * HelmAppServiceImpl {
122
124
return & HelmAppServiceImpl {
123
125
logger : Logger ,
124
126
clusterService : clusterService ,
@@ -135,6 +137,7 @@ func NewHelmAppServiceImpl(Logger *zap.SugaredLogger, clusterService cluster.Clu
135
137
clusterRepository : clusterRepository ,
136
138
K8sUtil : K8sUtil ,
137
139
helmReleaseConfig : helmReleaseConfig ,
140
+ helmAppReadService : helmAppReadService ,
138
141
}
139
142
}
140
143
@@ -191,7 +194,7 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste
191
194
}
192
195
193
196
func (impl * HelmAppServiceImpl ) HibernateApplication (ctx context.Context , app * helmBean.AppIdentifier , hibernateRequest * openapi.HibernateRequest ) ([]* openapi.HibernateStatus , error ) {
194
- conf , err := impl .GetClusterConf (app .ClusterId )
197
+ conf , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
195
198
if err != nil {
196
199
197
200
impl .logger .Errorw ("HibernateApplication" , "error in getting cluster config" , "err" , err , "clusterId" , app .ClusterId )
@@ -210,7 +213,7 @@ func (impl *HelmAppServiceImpl) HibernateApplication(ctx context.Context, app *h
210
213
211
214
func (impl * HelmAppServiceImpl ) UnHibernateApplication (ctx context.Context , app * helmBean.AppIdentifier , hibernateRequest * openapi.HibernateRequest ) ([]* openapi.HibernateStatus , error ) {
212
215
213
- conf , err := impl .GetClusterConf (app .ClusterId )
216
+ conf , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
214
217
if err != nil {
215
218
impl .logger .Errorw ("UnHibernateApplication" , "error in getting cluster config" , "err" , err , "clusterId" , app .ClusterId )
216
219
return nil , err
@@ -227,27 +230,6 @@ func (impl *HelmAppServiceImpl) UnHibernateApplication(ctx context.Context, app
227
230
return response , nil
228
231
}
229
232
230
- func (impl * HelmAppServiceImpl ) GetClusterConf (clusterId int ) (* gRPC.ClusterConfig , error ) {
231
- cluster , err := impl .clusterService .FindById (clusterId )
232
- if err != nil {
233
- impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
234
- return nil , err
235
- }
236
- config := & gRPC.ClusterConfig {
237
- ApiServerUrl : cluster .ServerUrl ,
238
- Token : cluster .Config [commonBean .BearerToken ],
239
- ClusterId : int32 (cluster .Id ),
240
- ClusterName : cluster .ClusterName ,
241
- InsecureSkipTLSVerify : cluster .InsecureSkipTLSVerify ,
242
- }
243
- if cluster .InsecureSkipTLSVerify == false {
244
- config .KeyData = cluster .Config [commonBean .TlsKey ]
245
- config .CertData = cluster .Config [commonBean .CertData ]
246
- config .CaData = cluster .Config [commonBean .CertificateAuthorityData ]
247
- }
248
- return config , nil
249
- }
250
-
251
233
func (impl * HelmAppServiceImpl ) GetApplicationDetail (ctx context.Context , app * helmBean.AppIdentifier ) (* gRPC.AppDetail , error ) {
252
234
return impl .getApplicationDetail (ctx , app , nil )
253
235
}
@@ -261,7 +243,7 @@ func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Conte
261
243
}
262
244
263
245
func (impl * HelmAppServiceImpl ) getApplicationDetail (ctx context.Context , app * helmBean.AppIdentifier , resourceTreeFilter * gRPC.ResourceTreeFilter ) (* gRPC.AppDetail , error ) {
264
- config , err := impl .GetClusterConf (app .ClusterId )
246
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
265
247
if err != nil {
266
248
impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
267
249
return nil , err
@@ -301,7 +283,7 @@ func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.
301
283
var config * gRPC.ClusterConfig
302
284
var err error
303
285
if clusterId > 0 {
304
- config , err = impl .GetClusterConf (clusterId )
286
+ config , err = impl .helmAppReadService . GetClusterConf (clusterId )
305
287
if err != nil {
306
288
impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
307
289
return nil , err
@@ -317,7 +299,7 @@ func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.
317
299
}
318
300
319
301
func (impl * HelmAppServiceImpl ) getApplicationAndReleaseStatus (ctx context.Context , app * helmBean.AppIdentifier ) (* gRPC.AppStatus , error ) {
320
- config , err := impl .GetClusterConf (app .ClusterId )
302
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
321
303
if err != nil {
322
304
impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
323
305
return nil , err
@@ -336,7 +318,7 @@ func (impl *HelmAppServiceImpl) getApplicationAndReleaseStatus(ctx context.Conte
336
318
}
337
319
338
320
func (impl * HelmAppServiceImpl ) GetDeploymentHistory (ctx context.Context , app * helmBean.AppIdentifier ) (* gRPC.HelmAppDeploymentHistory , error ) {
339
- config , err := impl .GetClusterConf (app .ClusterId )
321
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
340
322
if err != nil {
341
323
impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
342
324
return nil , err
@@ -358,7 +340,7 @@ func (impl *HelmAppServiceImpl) GetDeploymentHistory(ctx context.Context, app *h
358
340
}
359
341
360
342
func (impl * HelmAppServiceImpl ) GetValuesYaml (ctx context.Context , app * helmBean.AppIdentifier ) (* gRPC.ReleaseInfo , error ) {
361
- config , err := impl .GetClusterConf (app .ClusterId )
343
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
362
344
if err != nil {
363
345
impl .logger .Errorw ("error in fetching cluster detail" , "err" , err )
364
346
return nil , err
@@ -373,7 +355,7 @@ func (impl *HelmAppServiceImpl) GetValuesYaml(ctx context.Context, app *helmBean
373
355
}
374
356
375
357
func (impl * HelmAppServiceImpl ) GetDesiredManifest (ctx context.Context , app * helmBean.AppIdentifier , resource * openapi.ResourceIdentifier ) (* openapi.DesiredManifestResponse , error ) {
376
- config , err := impl .GetClusterConf (app .ClusterId )
358
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
377
359
if err != nil {
378
360
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
379
361
return nil , err
@@ -561,7 +543,7 @@ func (impl *HelmAppServiceImpl) DeleteDBLinkedHelmApplication(ctx context.Contex
561
543
}
562
544
563
545
func (impl * HelmAppServiceImpl ) DeleteApplication (ctx context.Context , app * helmBean.AppIdentifier ) (* openapi.UninstallReleaseResponse , error ) {
564
- config , err := impl .GetClusterConf (app .ClusterId )
546
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
565
547
if err != nil {
566
548
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
567
549
return nil , err
@@ -624,7 +606,7 @@ func (impl *HelmAppServiceImpl) checkIfNsExists(namespace string, clusterBean *c
624
606
}
625
607
626
608
func (impl * HelmAppServiceImpl ) UpdateApplication (ctx context.Context , app * helmBean.AppIdentifier , request * bean.UpdateApplicationRequestDto ) (* openapi.UpdateReleaseResponse , error ) {
627
- config , err := impl .GetClusterConf (app .ClusterId )
609
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
628
610
if err != nil {
629
611
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
630
612
return nil , err
@@ -653,7 +635,7 @@ func (impl *HelmAppServiceImpl) UpdateApplication(ctx context.Context, app *helm
653
635
}
654
636
655
637
func (impl * HelmAppServiceImpl ) GetDeploymentDetail (ctx context.Context , app * helmBean.AppIdentifier , version int32 ) (* openapi.HelmAppDeploymentManifestDetail , error ) {
656
- config , err := impl .GetClusterConf (app .ClusterId )
638
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
657
639
if err != nil {
658
640
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
659
641
return nil , err
@@ -683,7 +665,7 @@ func (impl *HelmAppServiceImpl) GetDeploymentDetail(ctx context.Context, app *he
683
665
}
684
666
685
667
func (impl * HelmAppServiceImpl ) InstallRelease (ctx context.Context , clusterId int , installReleaseRequest * gRPC.InstallReleaseRequest ) (* gRPC.InstallReleaseResponse , error ) {
686
- config , err := impl .GetClusterConf (clusterId )
668
+ config , err := impl .helmAppReadService . GetClusterConf (clusterId )
687
669
if err != nil {
688
670
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , clusterId , "err" , err )
689
671
return nil , err
@@ -702,7 +684,7 @@ func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId in
702
684
703
685
func (impl * HelmAppServiceImpl ) UpdateApplicationWithChartInfo (ctx context.Context , clusterId int ,
704
686
request * bean.UpdateApplicationWithChartInfoRequestDto ) (* openapi.UpdateReleaseResponse , error ) {
705
- config , err := impl .GetClusterConf (clusterId )
687
+ config , err := impl .helmAppReadService . GetClusterConf (clusterId )
706
688
if err != nil {
707
689
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , clusterId , "err" , err )
708
690
return nil , err
@@ -724,7 +706,7 @@ func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfo(ctx context.Conte
724
706
}
725
707
726
708
func (impl * HelmAppServiceImpl ) IsReleaseInstalled (ctx context.Context , app * helmBean.AppIdentifier ) (bool , error ) {
727
- config , err := impl .GetClusterConf (app .ClusterId )
709
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
728
710
if err != nil {
729
711
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
730
712
return false , err
@@ -746,7 +728,7 @@ func (impl *HelmAppServiceImpl) IsReleaseInstalled(ctx context.Context, app *hel
746
728
}
747
729
748
730
func (impl * HelmAppServiceImpl ) RollbackRelease (ctx context.Context , app * helmBean.AppIdentifier , version int32 ) (bool , error ) {
749
- config , err := impl .GetClusterConf (app .ClusterId )
731
+ config , err := impl .helmAppReadService . GetClusterConf (app .ClusterId )
750
732
if err != nil {
751
733
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
752
734
return false , err
@@ -979,7 +961,7 @@ func (impl *HelmAppServiceImpl) TemplateChart(ctx context.Context, templateChart
979
961
RegistryCredential : registryCredential ,
980
962
}
981
963
982
- config , err := impl .GetClusterConf (clusterId )
964
+ config , err := impl .helmAppReadService . GetClusterConf (clusterId )
983
965
if err != nil {
984
966
impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , clusterId , "err" , err )
985
967
return nil , err
0 commit comments