@@ -36,17 +36,6 @@ import (
3636 "time"
3737)
3838
39- const (
40- DEFAULT_CLUSTER = "default_cluster"
41- DEFAULT_CLUSTER_ID = 1
42- API_CALLER_DEVTRON_APP ApiCallerAppType = "devtron-app"
43- API_CALLER_HELM_APP ApiCallerAppType = "helm-app"
44- API_CALLER_EXTERNAL_HELM_APP ApiCallerAppType = "external-helm-app"
45- API_CALLER_UNKNOWN ApiCallerAppType = "unknown"
46- )
47-
48- type ApiCallerAppType string
49-
5039type HelmAppService interface {
5140 ListHelmApplications (ctx context.Context , clusterIds []int , w http.ResponseWriter , token string , helmAuth func (token string , object string ) bool )
5241 GetApplicationDetail (ctx context.Context , app * AppIdentifier ) (* AppDetail , error )
@@ -60,18 +49,18 @@ type HelmAppService interface {
6049 GetValuesYaml (ctx context.Context , app * AppIdentifier ) (* ReleaseInfo , error )
6150 GetDesiredManifest (ctx context.Context , app * AppIdentifier , resource * openapi.ResourceIdentifier ) (* openapi.DesiredManifestResponse , error )
6251 DeleteApplication (ctx context.Context , app * AppIdentifier ) (* openapi.UninstallReleaseResponse , error )
63- UpdateApplication (ctx context.Context , app * AppIdentifier , request * openapi. UpdateReleaseRequest , apiCallerAppType ApiCallerAppType ) (* openapi.UpdateReleaseResponse , error )
52+ UpdateApplication (ctx context.Context , app * AppIdentifier , request * UpdateApplicationRequestDto ) (* openapi.UpdateReleaseResponse , error )
6453 GetDeploymentDetail (ctx context.Context , app * AppIdentifier , version int32 ) (* openapi.HelmAppDeploymentManifestDetail , error )
6554 InstallRelease (ctx context.Context , clusterId int , installReleaseRequest * InstallReleaseRequest ) (* InstallReleaseResponse , error )
66- UpdateApplicationWithChartInfo (ctx context.Context , clusterId int , updateReleaseRequest * InstallReleaseRequest , apiCallerAppType ApiCallerAppType ) (* openapi.UpdateReleaseResponse , error )
55+ UpdateApplicationWithChartInfo (ctx context.Context , clusterId int , request * UpdateApplicationWithChartInfoRequestDto ) (* openapi.UpdateReleaseResponse , error )
6756 IsReleaseInstalled (ctx context.Context , app * AppIdentifier ) (bool , error )
6857 RollbackRelease (ctx context.Context , app * AppIdentifier , version int32 ) (bool , error )
6958 GetClusterConf (clusterId int ) (* ClusterConfig , error )
7059 GetDevtronHelmAppIdentifier () * AppIdentifier
7160 UpdateApplicationWithChartInfoWithExtraValues (ctx context.Context , appIdentifier * AppIdentifier , chartRepository * ChartRepository , extraValues map [string ]interface {}, extraValuesYamlUrl string , useLatestChartVersion bool ) (* openapi.UpdateReleaseResponse , error )
7261 TemplateChart (ctx context.Context , templateChartRequest * openapi2.TemplateChartRequest ) (* openapi2.TemplateChartResponse , error )
7362 GetNotes (ctx context.Context , request * InstallReleaseRequest ) (string , error )
74- GetRevisionHistoryMaxValue (appType ApiCallerAppType ) int32
63+ GetRevisionHistoryMaxValue (appType SourceAppType ) int32
7564}
7665
7766type HelmAppServiceImpl struct {
@@ -439,7 +428,7 @@ func (impl *HelmAppServiceImpl) DeleteApplication(ctx context.Context, app *AppI
439428 return response , nil
440429}
441430
442- func (impl * HelmAppServiceImpl ) UpdateApplication (ctx context.Context , app * AppIdentifier , request * openapi. UpdateReleaseRequest , apiCallerAppType ApiCallerAppType ) (* openapi.UpdateReleaseResponse , error ) {
431+ func (impl * HelmAppServiceImpl ) UpdateApplication (ctx context.Context , app * AppIdentifier , request * UpdateApplicationRequestDto ) (* openapi.UpdateReleaseResponse , error ) {
443432 config , err := impl .GetClusterConf (app .ClusterId )
444433 if err != nil {
445434 impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , app .ClusterId , "err" , err )
@@ -453,7 +442,7 @@ func (impl *HelmAppServiceImpl) UpdateApplication(ctx context.Context, app *AppI
453442 ReleaseNamespace : app .Namespace ,
454443 },
455444 ValuesYaml : request .GetValuesYaml (),
456- HistoryMax : impl .GetRevisionHistoryMaxValue (apiCallerAppType ),
445+ HistoryMax : impl .GetRevisionHistoryMaxValue (request . SourceAppType ),
457446 }
458447
459448 updateApplicationResponse , err := impl .helmAppClient .UpdateApplication (ctx , req )
@@ -517,16 +506,16 @@ func (impl *HelmAppServiceImpl) InstallRelease(ctx context.Context, clusterId in
517506}
518507
519508func (impl * HelmAppServiceImpl ) UpdateApplicationWithChartInfo (ctx context.Context , clusterId int ,
520- updateReleaseRequest * InstallReleaseRequest , apiCallerAppType ApiCallerAppType ) (* openapi.UpdateReleaseResponse , error ) {
509+ request * UpdateApplicationWithChartInfoRequestDto ) (* openapi.UpdateReleaseResponse , error ) {
521510 config , err := impl .GetClusterConf (clusterId )
522511 if err != nil {
523512 impl .logger .Errorw ("error in fetching cluster detail" , "clusterId" , clusterId , "err" , err )
524513 return nil , err
525514 }
526- updateReleaseRequest .HistoryMax = impl .GetRevisionHistoryMaxValue (apiCallerAppType )
527- updateReleaseRequest .ReleaseIdentifier .ClusterConfig = config
515+ request .HistoryMax = impl .GetRevisionHistoryMaxValue (request . SourceAppType )
516+ request .ReleaseIdentifier .ClusterConfig = config
528517
529- updateReleaseResponse , err := impl .helmAppClient .UpdateApplicationWithChartInfo (ctx , updateReleaseRequest )
518+ updateReleaseResponse , err := impl .helmAppClient .UpdateApplicationWithChartInfo (ctx , request . InstallReleaseRequest )
530519 if err != nil {
531520 impl .logger .Errorw ("error in installing release" , "err" , err )
532521 return nil , err
@@ -668,20 +657,24 @@ func (impl *HelmAppServiceImpl) UpdateApplicationWithChartInfoWithExtraValues(ct
668657 }
669658
670659 // update in helm
671- updateReleaseRequest := & InstallReleaseRequest {
672- ReleaseIdentifier : & ReleaseIdentifier {
673- ReleaseName : appIdentifier .ReleaseName ,
674- ReleaseNamespace : appIdentifier .Namespace ,
660+
661+ updateReleaseRequest := & UpdateApplicationWithChartInfoRequestDto {
662+ InstallReleaseRequest : & InstallReleaseRequest {
663+ ReleaseIdentifier : & ReleaseIdentifier {
664+ ReleaseName : appIdentifier .ReleaseName ,
665+ ReleaseNamespace : appIdentifier .Namespace ,
666+ },
667+ ChartName : releaseInfo .DeployedAppDetail .ChartName ,
668+ ValuesYaml : string (mergedValuesYamlByteArr ),
669+ ChartRepository : chartRepository ,
675670 },
676- ChartName : releaseInfo .DeployedAppDetail .ChartName ,
677- ValuesYaml : string (mergedValuesYamlByteArr ),
678- ChartRepository : chartRepository ,
671+ SourceAppType : SOURCE_UNKNOWN ,
679672 }
680673 if ! useLatestChartVersion {
681674 updateReleaseRequest .ChartVersion = releaseInfo .DeployedAppDetail .ChartVersion
682675 }
683676
684- updateResponse , err := impl .UpdateApplicationWithChartInfo (ctx , appIdentifier .ClusterId , updateReleaseRequest , API_CALLER_UNKNOWN )
677+ updateResponse , err := impl .UpdateApplicationWithChartInfo (ctx , appIdentifier .ClusterId , updateReleaseRequest )
685678 if err != nil {
686679 impl .logger .Errorw ("error in upgrading release" , "err" , err )
687680 return nil , err
@@ -885,13 +878,13 @@ func (impl *HelmAppServiceImpl) appListRespProtoTransformer(deployedApps *Deploy
885878 return appList
886879}
887880
888- func (impl * HelmAppServiceImpl ) GetRevisionHistoryMaxValue (appType ApiCallerAppType ) int32 {
881+ func (impl * HelmAppServiceImpl ) GetRevisionHistoryMaxValue (appType SourceAppType ) int32 {
889882 switch appType {
890- case API_CALLER_DEVTRON_APP :
883+ case SOURCE_DEVTRON_APP :
891884 return int32 (impl .helmReleaseConfig .RevisionHistoryLimitDevtronApp )
892- case API_CALLER_HELM_APP :
885+ case SOURCE_HELM_APP :
893886 return int32 (impl .helmReleaseConfig .RevisionHistoryLimitHelmApp )
894- case API_CALLER_EXTERNAL_HELM_APP :
887+ case SOURCE_EXTERNAL_HELM_APP :
895888 return int32 (impl .helmReleaseConfig .RevisionHistoryLimitExternalHelmApp )
896889 default :
897890 return 0
0 commit comments