Skip to content

Commit 562938c

Browse files
iamayushmAsh-exp
andauthored
feat: migrate external argo cd application (#6303)
* wip:deployment config old data migration code * updating repo url get usage * comments * adding comments * wip: adding repo name in deployment config struct * migration files * migration update * feat: updated the target revision * review changes * nil handling * dev testing bug fixes * fixes * value file name fix * fixes * repo url function update * git repo url handing using code * fixing import cycle * feat: dynamic chart loaction and valuesfile path * CRUD operations * repo clone and env override create flow * wip: self review changes * feat: trigger flows updated * self review changes * refactoring * self review fix: env override create * skipping checks * feat: Skip GitOps config CRUD ACD operation if argo module is not installed * handling for IsGitOpsConfigured * feat: release mode data adaptor * validation api * deployment status changes and application filter logic change * self review changes * delete acd app handling * adding route * modifying validate link request * pipeline crud operation * dev testing fix * wip: release config data type fix * fixing check * updated wire gen * added api /environment-variables * added releaseMode validation * fix: isGitOpsEnable flag * updated EnvironmentVariableList response * updated git repo validations * updated migration number * fix: skip pipeline create validation * panic handler for cd pipeline creation * updated wire dep * fix: cd trigger panic fix * fix: validation migrate cd pipeline api * updated ValidateGitOpsRepoUrl request for custom gitops logic * fix: git clone logic for validate migration request * fix: updated API key * chart name handling for migrate release * fix: chart validation * fix: chart validation * fix: pipeline creation * feat: is gitops repo configured flag updated * wip: trigger fix * feat: filter external argo app list * read service for circular import * fix nil poniter panic * fix: empty argo app list * fix empty app name * updated dep of DeploymentConfigService instead of DeploymentConfigReadService in ArgoApplicationService * minor refactorings * replaced release app name from util function * validation and flag if config is for external helm release * fix migrated from flag * fix: resource tree api with scoop * fix: error handling for GetResourceTree * fixing set chart location function * updating config type * fix: scoop argo_cd GetResourceTree * fix: updated validation error * fix: updated BuildDeployedAppName references * fix: common wire set * updating chart location while delete * fix user id * common function for url already present * removing duplicate logic for pipeline filter * fix: nil checker issues * updated global api * pg no rows handling * manual sync mode fix for trigger/deployment statys * fix: resource tree * fix: panic handling * fix default namespace * wip * fix: pipeline delete flow * fix: delete apllication object * fix: delete application object * chore: refactored AppDetailsReadService * added: vlaidation for link external release * review comment incorporated * fix: pointer datatype * added: EnforcedPolicyViolation validation * fix app clone * make fix * fix: workflow_execution_stage cloumn * added gitops adapter * helm deployment status fix * updated deployment config queries * fix: generate manifest diff * wire gen updated * updated feature flag name * updated env_gen.md file * feat: argocd resource tree support * fix: nil handling updated * fix: context handling * review changes * chore: deployment config refactorings * fix: on-board argocd issues * updated updateArgoAppDeleteStatus func * review changes * make fix * delete argo app error handling fixes * payload changes * argo app listing api updated * updated wire_gen files * chore: Argocd dependabot fixes (#6402) * version matched with enterprise * vulnerability fix * argocd dependabot fixes * argo workflow dependabot fixes * fix: link request * updated migration script * fix: GetDeploymentConfigMinForAppAndEnv for app stage api * fix: helm app gitops target revision * fix: cd pipeline create blocked if argo module not installed * setting repo url in new deployment config also * default branch (backward compatibility) if branch is not passed * updated target revision * fix: release config target revision * updated not deployed status to degraded * go mod tidy * fix: app delete flow * fix: git commit ref not found * fix: git commit ref not found * fix: gitops branch pull error * fix enum * fix: removed unused import * chore: func renamed * updating chart location when base version is changed * chart location update in deployment config * chart env override fix * wip: fixed pg no rows * wip: bug fixes * fix empty cluster url * namespace fix * listing api fix * wip: installed app query fix * fix for argo module not installed * wip: adding chart loaction * renaming * wip: head validation * deployment app type change fix * chart location heal * wip: validation for linked pipeline in app change api * fix deployment change api * migration update * migration file rename --------- Co-authored-by: Ash-exp <[email protected]>
1 parent 9327397 commit 562938c

File tree

325 files changed

+40741
-7653
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

325 files changed

+40741
-7653
lines changed

Wire.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ import (
102102
appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow"
103103
"github.com/devtron-labs/devtron/internal/sql/repository/bulkUpdate"
104104
"github.com/devtron-labs/devtron/internal/sql/repository/chartConfig"
105-
"github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig"
106105
dockerRegistryRepository "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry"
107106
"github.com/devtron-labs/devtron/internal/sql/repository/helper"
108107
repository8 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging"
109108
"github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig"
110109
resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup"
111110
"github.com/devtron-labs/devtron/internal/util"
112111
"github.com/devtron-labs/devtron/pkg/app"
112+
read4 "github.com/devtron-labs/devtron/pkg/app/appDetails/read"
113113
"github.com/devtron-labs/devtron/pkg/app/dbMigration"
114114
"github.com/devtron-labs/devtron/pkg/app/status"
115115
"github.com/devtron-labs/devtron/pkg/appClone"
@@ -128,6 +128,7 @@ import (
128128
"github.com/devtron-labs/devtron/pkg/bulkAction/service"
129129
"github.com/devtron-labs/devtron/pkg/chart"
130130
"github.com/devtron-labs/devtron/pkg/chart/gitOpsConfig"
131+
read2 "github.com/devtron-labs/devtron/pkg/chart/read"
131132
chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository"
132133
"github.com/devtron-labs/devtron/pkg/commonService"
133134
"github.com/devtron-labs/devtron/pkg/config"
@@ -357,6 +358,8 @@ func InitializeApp() (*App, error) {
357358
wire.Bind(new(gitOpsConfig.DevtronAppGitOpConfigService), new(*gitOpsConfig.DevtronAppGitOpConfigServiceImpl)),
358359
chart.NewChartServiceImpl,
359360
wire.Bind(new(chart.ChartService), new(*chart.ChartServiceImpl)),
361+
read2.NewChartReadServiceImpl,
362+
wire.Bind(new(read2.ChartReadService), new(*read2.ChartReadServiceImpl)),
360363
service.NewBulkUpdateServiceImpl,
361364
wire.Bind(new(service.BulkUpdateService), new(*service.BulkUpdateServiceImpl)),
362365

@@ -375,6 +378,10 @@ func InitializeApp() (*App, error) {
375378
wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)),
376379
appList2.NewAppListingRestHandlerImpl,
377380
wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)),
381+
382+
read4.NewAppDetailsReadServiceImpl,
383+
wire.Bind(new(read4.AppDetailsReadService), new(*read4.AppDetailsReadServiceImpl)),
384+
378385
app.NewAppListingServiceImpl,
379386
wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)),
380387
repository.NewAppListingRepositoryImpl,
@@ -622,6 +629,7 @@ func InitializeApp() (*App, error) {
622629
repository9.NewClusterInstalledAppsRepositoryImpl,
623630
wire.Bind(new(repository9.ClusterInstalledAppsRepository), new(*repository9.ClusterInstalledAppsRepositoryImpl)),
624631

632+
commonService.NewCommonBaseServiceImpl,
625633
commonService.NewCommonServiceImpl,
626634
wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)),
627635

@@ -659,8 +667,8 @@ func InitializeApp() (*App, error) {
659667

660668
router.NewCommonRouterImpl,
661669
wire.Bind(new(router.CommonRouter), new(*router.CommonRouterImpl)),
662-
restHandler.NewCommonRestHanlderImpl,
663-
wire.Bind(new(restHandler.CommonRestHanlder), new(*restHandler.CommonRestHanlderImpl)),
670+
restHandler.NewCommonRestHandlerImpl,
671+
wire.Bind(new(restHandler.CommonRestHandler), new(*restHandler.CommonRestHandlerImpl)),
664672

665673
router.NewScopedVariableRouterImpl,
666674
wire.Bind(new(router.ScopedVariableRouter), new(*router.ScopedVariableRouterImpl)),
@@ -941,11 +949,7 @@ func InitializeApp() (*App, error) {
941949
cel.NewCELServiceImpl,
942950
wire.Bind(new(cel.EvaluatorService), new(*cel.EvaluatorServiceImpl)),
943951

944-
deploymentConfig.NewRepositoryImpl,
945-
wire.Bind(new(deploymentConfig.Repository), new(*deploymentConfig.RepositoryImpl)),
946-
947-
common.NewDeploymentConfigServiceImpl,
948-
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),
952+
common.WireSet,
949953

950954
repoCredsK8sClient.NewRepositoryCredsK8sClientImpl,
951955
wire.Bind(new(repoCredsK8sClient.RepositoryCredsK8sClient), new(*repoCredsK8sClient.RepositoryCredsK8sClientImpl)),

WiringNilCheck.go

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ func skipUnnecessaryFieldsForCheck(fieldName, valName string) bool {
114114
"modulecronserviceimpl": {"cron"},
115115
"oteltracingserviceimpl": {"traceprovider"},
116116
"terminalaccessrepositoryimpl": {"templatescache"},
117+
"grpcapiclientimpl": {"serviceclient"},
118+
"serverenvconfig": {"errorencounteredongettingdevtronhelmrelease"},
117119
}
118120
if _, ok := fieldAndValName[valName]; ok {
119121
for _, ignoreFieldName := range fieldAndValName[valName] {

api/argoApplication/ArgoApplicationRestHandler.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package argoApplication
1818

1919
import (
20+
"context"
2021
"errors"
2122
"github.com/devtron-labs/devtron/api/restHandler/common"
2223
"github.com/devtron-labs/devtron/pkg/argoApplication"
@@ -89,6 +90,9 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
8990
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
9091
return
9192
}
93+
ctx := r.Context()
94+
ctx = context.WithValue(ctx, "token", token)
95+
9296
var err error
9397
v := r.URL.Query()
9498
resourceName := v.Get("name")
@@ -104,7 +108,7 @@ func (handler *ArgoApplicationRestHandlerImpl) GetApplicationDetail(w http.Respo
104108
return
105109
}
106110
}
107-
resp, err := handler.readService.GetAppDetail(resourceName, namespace, clusterId)
111+
resp, err := handler.readService.GetAppDetailEA(ctx, resourceName, namespace, clusterId)
108112
if err != nil {
109113
handler.logger.Errorw("error in getting argo application app detail", "err", err, "resourceName", resourceName, "clusterId", clusterId)
110114
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)

api/argoApplication/wire_argoApplication.go

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var ArgoApplicationWireSetFull = wire.NewSet(
3030
config.NewArgoApplicationConfigServiceImpl,
3131
wire.Bind(new(config.ArgoApplicationConfigService), new(*config.ArgoApplicationConfigServiceImpl)),
3232

33+
argoApplication.NewArgoApplicationServiceImpl,
3334
argoApplication.NewArgoApplicationServiceExtendedServiceImpl,
3435
wire.Bind(new(argoApplication.ArgoApplicationService), new(*argoApplication.ArgoApplicationServiceExtendedImpl)),
3536

api/bean/AppView/AppView.go

+13
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,16 @@ type LinkOuts struct {
294294
Link string `json:"link,omitempty"`
295295
Description string `json:"description,omitempty"`
296296
}
297+
298+
type AppStages struct {
299+
AppId int `json:"app_id,omitempty" sql:"app_id"`
300+
CiTemplateId int `json:"ci_template_id,omitempty" sql:"ci_template_id"`
301+
CiPipelineId int `json:"ci_pipeline_id,omitempty" sql:"ci_pipeline_id"`
302+
ChartId int `json:"chart_id,omitempty" sql:"chart_id"`
303+
ChartGitRepoUrl string `json:"chart_git_repo_url,omitempty" sql:"chart_git_repo_url"`
304+
PipelineId int `json:"pipeline_id,omitempty" sql:"pipeline_id"`
305+
YamlStatus int `json:"yaml_status,omitempty" sql:"yaml_status"`
306+
YamlReviewed bool `json:"yaml_reviewed,omitempty" sql:"yaml_reviewed"`
307+
DeploymentConfigRepoURL string `json:"deployment_config_repo_url" sql:"-"`
308+
GitMaterialExists int `json:"-" sql:"-"`
309+
}

api/bean/gitOps/GitOpsConfig.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,15 @@ type GitOpsConfigDto struct {
4242
IsTLSKeyDataPresent bool `json:"isTLSKeyDataPresent"`
4343

4444
// TODO refactoring: create different struct for internal fields
45-
GitRepoName string `json:"-"`
46-
UserEmailId string `json:"-"`
47-
Description string `json:"-"`
48-
UserId int32 `json:"-"`
45+
GitRepoName string `json:"-"`
46+
TargetRevision string `json:"-"`
47+
UserEmailId string `json:"-"`
48+
Description string `json:"-"`
49+
UserId int32 `json:"-"`
50+
}
51+
52+
func (dto GitOpsConfigDto) GetHostUrl() string {
53+
return dto.Host
4954
}
5055

5156
type GitRepoRequestDto struct {
@@ -80,5 +85,5 @@ func IsGitOpsRepoNotConfigured(gitRepoUrl string) bool {
8085
}
8186

8287
func IsGitOpsRepoConfigured(gitRepoUrl string) bool {
83-
return len(gitRepoUrl) != 0 || gitRepoUrl != GIT_REPO_NOT_CONFIGURED
88+
return !IsGitOpsRepoNotConfigured(gitRepoUrl)
8489
}

api/helm-app/HelmAppRestHandler.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/EAMode"
2727
"github.com/devtron-labs/devtron/pkg/argoApplication"
2828
"github.com/devtron-labs/devtron/pkg/argoApplication/helper"
29+
clusterBean "github.com/devtron-labs/devtron/pkg/cluster/bean"
2930
clientErrors "github.com/devtron-labs/devtron/pkg/errors"
3031
"github.com/devtron-labs/devtron/pkg/fluxApplication"
3132
bean2 "github.com/devtron-labs/devtron/pkg/k8s/application/bean"
@@ -467,7 +468,7 @@ func (handler *HelmAppRestHandlerImpl) DeleteApplication(w http.ResponseWriter,
467468
// validate if the devtron-operator helm release, block that for deletion
468469
if appIdentifier.ReleaseName == handler.serverEnvConfig.DevtronHelmReleaseName &&
469470
appIdentifier.Namespace == handler.serverEnvConfig.DevtronHelmReleaseNamespace &&
470-
appIdentifier.ClusterId == bean.DEFAULT_CLUSTER_ID {
471+
appIdentifier.ClusterId == clusterBean.DefaultClusterId {
471472
common.WriteJsonResp(w, errors.New("cannot delete this default helm app"), nil, http.StatusForbidden)
472473
return
473474
}

api/helm-app/bean/bean.go

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
)
2424

2525
const (
26-
DEFAULT_CLUSTER_ID = 1
2726
SOURCE_DEVTRON_APP SourceAppType = "devtron-app"
2827
SOURCE_HELM_APP SourceAppType = "helm-app"
2928
SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app"

api/k8s/application/k8sApplicationRestHandler.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
253253
}
254254

255255
token := r.Header.Get("token")
256+
ctx := r.Context()
257+
ctx = context.WithValue(ctx, "token", token)
256258
var k8sAppDetail AppView.AppDetailContainer
257259
var resourceTreeResponse *gRPC.ResourceTreeResponse
258260
var clusterId int
@@ -276,7 +278,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
276278
return
277279
}
278280
//RBAC enforcer Ends
279-
appDetail, err := handler.helmAppService.GetApplicationDetail(r.Context(), appIdentifier)
281+
appDetail, err := handler.helmAppService.GetApplicationDetail(ctx, appIdentifier)
280282
if err != nil {
281283
apiError := clientErrors.ConvertToApiError(err)
282284
if apiError != nil {
@@ -303,7 +305,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response
303305
}
304306
//RBAC enforcer Ends
305307

306-
appDetail, err := handler.argoApplicationReadService.GetAppDetail(appIdentifier.AppName, appIdentifier.Namespace, appIdentifier.ClusterId)
308+
appDetail, err := handler.argoApplicationReadService.GetAppDetailEA(r.Context(), appIdentifier.AppName, appIdentifier.Namespace, appIdentifier.ClusterId)
307309
if err != nil {
308310
apiError := clientErrors.ConvertToApiError(err)
309311
if apiError != nil {

api/module/ModuleRestHandler.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package module
1919
import (
2020
"encoding/json"
2121
"errors"
22+
"github.com/devtron-labs/devtron/pkg/module/bean"
2223
"net/http"
2324

2425
"github.com/devtron-labs/devtron/api/restHandler/common"
@@ -135,7 +136,7 @@ func (impl ModuleRestHandlerImpl) HandleModuleAction(w http.ResponseWriter, r *h
135136

136137
// decode request
137138
decoder := json.NewDecoder(r.Body)
138-
var moduleActionRequestDto *module.ModuleActionRequestDto
139+
var moduleActionRequestDto *bean.ModuleActionRequestDto
139140
err = decoder.Decode(&moduleActionRequestDto)
140141
if err != nil {
141142
impl.logger.Errorw("error in decoding request in HandleModuleAction", "err", err)
@@ -184,7 +185,7 @@ func (impl ModuleRestHandlerImpl) EnableModule(w http.ResponseWriter, r *http.Re
184185
}
185186
// decode request
186187
decoder := json.NewDecoder(r.Body)
187-
var moduleEnableRequestDto module.ModuleEnableRequestDto
188+
var moduleEnableRequestDto bean.ModuleEnableRequestDto
188189
err = decoder.Decode(&moduleEnableRequestDto)
189190
if err != nil {
190191
impl.logger.Errorw("error in decoding request in ModuleEnableRequestDto", "err", err)

api/module/wire_module.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package module
1818

1919
import (
2020
"github.com/devtron-labs/devtron/pkg/module"
21+
"github.com/devtron-labs/devtron/pkg/module/bean"
22+
"github.com/devtron-labs/devtron/pkg/module/read"
2123
moduleRepo "github.com/devtron-labs/devtron/pkg/module/repo"
2224
moduleDataStore "github.com/devtron-labs/devtron/pkg/module/store"
2325
"github.com/google/wire"
@@ -28,9 +30,11 @@ var ModuleWireSet = wire.NewSet(
2830
wire.Bind(new(module.ModuleActionAuditLogRepository), new(*module.ModuleActionAuditLogRepositoryImpl)),
2931
moduleRepo.NewModuleRepositoryImpl,
3032
wire.Bind(new(moduleRepo.ModuleRepository), new(*moduleRepo.ModuleRepositoryImpl)),
33+
read.NewModuleReadServiceImpl,
34+
wire.Bind(new(read.ModuleReadService), new(*read.ModuleReadServiceImpl)),
3135
moduleRepo.NewModuleResourceStatusRepositoryImpl,
3236
wire.Bind(new(moduleRepo.ModuleResourceStatusRepository), new(*moduleRepo.ModuleResourceStatusRepositoryImpl)),
33-
module.ParseModuleEnvConfig,
37+
bean.ParseModuleEnvConfig,
3438
moduleDataStore.InitModuleDataStore,
3539
module.NewModuleServiceHelperImpl,
3640
wire.Bind(new(module.ModuleServiceHelper), new(*module.ModuleServiceHelperImpl)),

api/restHandler/CommonRestHanlder.go

+23-6
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,29 @@ import (
2525
"go.uber.org/zap"
2626
)
2727

28-
type CommonRestHanlder interface {
28+
type CommonRestHandler interface {
2929
GlobalChecklist(w http.ResponseWriter, r *http.Request)
30+
EnvironmentVariableList(w http.ResponseWriter, r *http.Request)
3031
}
3132

32-
type CommonRestHanlderImpl struct {
33+
type CommonRestHandlerImpl struct {
3334
logger *zap.SugaredLogger
3435
userAuthService user.UserService
3536
commonService commonService.CommonService
3637
}
3738

38-
func NewCommonRestHanlderImpl(
39+
func NewCommonRestHandlerImpl(
3940
logger *zap.SugaredLogger,
4041
userAuthService user.UserService,
41-
commonService commonService.CommonService) *CommonRestHanlderImpl {
42-
return &CommonRestHanlderImpl{
42+
commonService commonService.CommonService) *CommonRestHandlerImpl {
43+
return &CommonRestHandlerImpl{
4344
logger: logger,
4445
userAuthService: userAuthService,
4546
commonService: commonService,
4647
}
4748
}
4849

49-
func (impl CommonRestHanlderImpl) GlobalChecklist(w http.ResponseWriter, r *http.Request) {
50+
func (impl CommonRestHandlerImpl) GlobalChecklist(w http.ResponseWriter, r *http.Request) {
5051
userId, err := impl.userAuthService.GetLoggedInUser(r)
5152
if userId == 0 || err != nil {
5253
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
@@ -61,3 +62,19 @@ func (impl CommonRestHanlderImpl) GlobalChecklist(w http.ResponseWriter, r *http
6162

6263
common.WriteJsonResp(w, err, res, http.StatusOK)
6364
}
65+
66+
func (impl CommonRestHandlerImpl) EnvironmentVariableList(w http.ResponseWriter, r *http.Request) {
67+
userId, err := impl.userAuthService.GetLoggedInUser(r)
68+
if userId == 0 || err != nil {
69+
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
70+
return
71+
}
72+
// TODO: ADD RBAC (if required)
73+
res, err := impl.commonService.EnvironmentVariableList()
74+
if err != nil {
75+
impl.logger.Errorw("service err, EnvironmentVariableList", "err", err)
76+
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
77+
return
78+
}
79+
common.WriteJsonResp(w, err, res, http.StatusOK)
80+
}

api/restHandler/CoreAppRestHandler.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider"
3030
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read"
3131
pipelineBean "github.com/devtron-labs/devtron/pkg/build/pipeline/bean"
32+
bean3 "github.com/devtron-labs/devtron/pkg/chart/bean"
33+
read5 "github.com/devtron-labs/devtron/pkg/chart/read"
3234
"github.com/devtron-labs/devtron/pkg/cluster/environment/repository"
3335
read3 "github.com/devtron-labs/devtron/pkg/team/read"
3436
"net/http"
@@ -101,6 +103,7 @@ type CoreAppRestHandlerImpl struct {
101103
pipelineStageService pipeline.PipelineStageService
102104
ciPipelineRepository pipelineConfig.CiPipelineRepository
103105
teamReadService read3.TeamReadService
106+
chartReadService read5.ChartReadService
104107
}
105108

106109
func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.UserService, validator *validator.Validate, enforcerUtil rbac.EnforcerUtil,
@@ -112,7 +115,8 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
112115
pipelineStageService pipeline.PipelineStageService, ciPipelineRepository pipelineConfig.CiPipelineRepository,
113116
gitProviderReadService read.GitProviderReadService,
114117
gitMaterialReadService read2.GitMaterialReadService,
115-
teamReadService read3.TeamReadService) *CoreAppRestHandlerImpl {
118+
teamReadService read3.TeamReadService,
119+
chartReadService read5.ChartReadService) *CoreAppRestHandlerImpl {
116120
handler := &CoreAppRestHandlerImpl{
117121
logger: logger,
118122
userAuthService: userAuthService,
@@ -136,6 +140,7 @@ func NewCoreAppRestHandlerImpl(logger *zap.SugaredLogger, userAuthService user.U
136140
pipelineStageService: pipelineStageService,
137141
ciPipelineRepository: ciPipelineRepository,
138142
teamReadService: teamReadService,
143+
chartReadService: chartReadService,
139144
}
140145
return handler
141146
}
@@ -551,7 +556,7 @@ func (handler CoreAppRestHandlerImpl) buildAppEnvironmentDeploymentTemplate(appI
551556
return nil, err, http.StatusBadRequest
552557
}
553558

554-
appDeploymentTemplate, err := handler.chartService.FindLatestChartForAppByAppId(appId)
559+
appDeploymentTemplate, err := handler.chartReadService.FindLatestChartForAppByAppId(appId)
555560
if err != nil {
556561
if err != pg.ErrNoRows {
557562
handler.logger.Errorw("service err, GetDeploymentTemplate in GetAppAllDetail", "err", err, "appId", appId, "envId", envId)
@@ -1365,7 +1370,7 @@ func (handler CoreAppRestHandlerImpl) createDockerConfig(appId int, dockerConfig
13651370
func (handler CoreAppRestHandlerImpl) createDeploymentTemplate(ctx context.Context, appId int, deploymentTemplate *appBean.DeploymentTemplate, userId int32) (error, int) {
13661371
handler.logger.Infow("Create App - creating deployment template", "appId", appId, "DeploymentStrategy", deploymentTemplate)
13671372

1368-
createDeploymentTemplateRequest := chart.TemplateRequest{
1373+
createDeploymentTemplateRequest := bean3.TemplateRequest{
13691374
AppId: appId,
13701375
ChartRefId: deploymentTemplate.ChartRefId,
13711376
IsAppMetricsEnabled: deploymentTemplate.ShowAppMetrics,
@@ -1839,7 +1844,7 @@ func (handler CoreAppRestHandlerImpl) createEnvDeploymentTemplate(appId int, use
18391844
chartEntry, err := handler.chartRepo.FindChartByAppIdAndRefId(appId, chartRefId)
18401845
if err != nil {
18411846
if pg.ErrNoRows == err {
1842-
templateRequest := chart.TemplateRequest{
1847+
templateRequest := bean3.TemplateRequest{
18431848
AppId: appId,
18441849
ChartRefId: chartRefId,
18451850
ValuesOverride: []byte("{}"),

0 commit comments

Comments
 (0)