Skip to content

Commit e256f1c

Browse files
Ash-expnishant-d
andauthored
chore: code refactoring v1 (#4545)
* chore: Removed unused jira and migration integration (#4498) * removed unsued jira integration * removed test-suite-code * db migration conf removal * chore: removed unused injection * chore: removed dead code * added: migration script --------- Co-authored-by: Ash-exp <[email protected]> * chore: App store dead code cleanup and restructuring (#4497) * moved chart-group in seperate code * removed unused dependency * removed dead code * extracted resource tree * moved notes * resource movement * removed unused code * removed unused dependency * commit methods * extracted status update * chore: clean up unused dead code * updated: EA mode docker file * updated: migration number --------- Co-authored-by: Ash-exp <[email protected]> * moved: const and types to bean * removed: unused const * moved ChartGroup router and rest handler to respective folder --------- Co-authored-by: Nishant <[email protected]>
1 parent a028997 commit e256f1c

Some content is hidden

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

51 files changed

+957
-3443
lines changed

DockerfileEA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com
2121
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts
2222
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/sql scripts/sql
2323
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/casbin scripts/casbin
24-
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON
24+
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.tmpl scripts/argo-assets/APPLICATION_TEMPLATE.tmpl
2525

2626
RUN useradd -ms /bin/bash devtron
2727
RUN chown -R devtron:devtron ./devtron-ea

Wire.go

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
util4 "github.com/devtron-labs/common-lib/utils/k8s"
2828
"github.com/devtron-labs/devtron/api/apiToken"
2929
appStoreRestHandler "github.com/devtron-labs/devtron/api/appStore"
30+
chartGroup2 "github.com/devtron-labs/devtron/api/appStore/chartGroup"
3031
chartProvider "github.com/devtron-labs/devtron/api/appStore/chartProvider"
3132
appStoreDeployment "github.com/devtron-labs/devtron/api/appStore/deployment"
3233
appStoreDiscover "github.com/devtron-labs/devtron/api/appStore/discover"
@@ -64,7 +65,6 @@ import (
6465
eClient "github.com/devtron-labs/devtron/client/events"
6566
"github.com/devtron-labs/devtron/client/gitSensor"
6667
"github.com/devtron-labs/devtron/client/grafana"
67-
jClient "github.com/devtron-labs/devtron/client/jira"
6868
"github.com/devtron-labs/devtron/client/lens"
6969
"github.com/devtron-labs/devtron/client/proxy"
7070
"github.com/devtron-labs/devtron/client/telemetry"
@@ -88,10 +88,11 @@ import (
8888
"github.com/devtron-labs/devtron/pkg/appClone/batch"
8989
"github.com/devtron-labs/devtron/pkg/appStatus"
9090
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
91+
"github.com/devtron-labs/devtron/pkg/appStore/chartGroup"
92+
repository4 "github.com/devtron-labs/devtron/pkg/appStore/chartGroup/repository"
9193
appStoreDeploymentFullMode "github.com/devtron-labs/devtron/pkg/appStore/deployment/fullMode"
92-
repository4 "github.com/devtron-labs/devtron/pkg/appStore/deployment/repository"
9394
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
94-
appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool/gitops"
95+
appStoreDeploymentGitopsTool "github.com/devtron-labs/devtron/pkg/appStore/deployment/tool"
9596
"github.com/devtron-labs/devtron/pkg/appWorkflow"
9697
"github.com/devtron-labs/devtron/pkg/attributes"
9798
"github.com/devtron-labs/devtron/pkg/bulkAction"
@@ -106,7 +107,6 @@ import (
106107
"github.com/devtron-labs/devtron/pkg/generateManifest"
107108
"github.com/devtron-labs/devtron/pkg/git"
108109
"github.com/devtron-labs/devtron/pkg/gitops"
109-
jira2 "github.com/devtron-labs/devtron/pkg/jira"
110110
"github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs"
111111
repository7 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository"
112112
"github.com/devtron-labs/devtron/pkg/notifier"
@@ -118,7 +118,6 @@ import (
118118
"github.com/devtron-labs/devtron/pkg/pipeline/types"
119119
"github.com/devtron-labs/devtron/pkg/plugin"
120120
repository6 "github.com/devtron-labs/devtron/pkg/plugin/repository"
121-
"github.com/devtron-labs/devtron/pkg/projectManagementService/jira"
122121
resourceGroup2 "github.com/devtron-labs/devtron/pkg/resourceGroup"
123122
"github.com/devtron-labs/devtron/pkg/resourceQualifiers"
124123
"github.com/devtron-labs/devtron/pkg/security"
@@ -261,10 +260,7 @@ func InitializeApp() (*App, error) {
261260
wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)),
262261
pipelineConfig.NewMaterialRepositoryImpl,
263262
wire.Bind(new(pipelineConfig.MaterialRepository), new(*pipelineConfig.MaterialRepositoryImpl)),
264-
router.NewMigrateDbRouterImpl,
265-
wire.Bind(new(router.MigrateDbRouter), new(*router.MigrateDbRouterImpl)),
266-
restHandler.NewMigrateDbRestHandlerImpl,
267-
wire.Bind(new(restHandler.MigrateDbRestHandler), new(*restHandler.MigrateDbRestHandlerImpl)),
263+
268264
util.NewChartTemplateServiceImpl,
269265
wire.Bind(new(util.ChartTemplateService), new(*util.ChartTemplateServiceImpl)),
270266
util.NewChartDeploymentServiceImpl,
@@ -332,23 +328,8 @@ func InitializeApp() (*App, error) {
332328
pipeline.NewPropertiesConfigServiceImpl,
333329
wire.Bind(new(pipeline.PropertiesConfigService), new(*pipeline.PropertiesConfigServiceImpl)),
334330

335-
router.NewProjectManagementRouterImpl,
336-
wire.Bind(new(router.ProjectManagementRouter), new(*router.ProjectManagementRouterImpl)),
337-
338-
restHandler.NewJiraRestHandlerImpl,
339-
wire.Bind(new(restHandler.JiraRestHandler), new(*restHandler.JiraRestHandlerImpl)),
340-
341-
jira2.NewProjectManagementServiceImpl,
342-
wire.Bind(new(jira2.ProjectManagementService), new(*jira2.ProjectManagementServiceImpl)),
343-
344-
jira.NewAccountServiceImpl,
345-
wire.Bind(new(jira.AccountService), new(*jira.AccountServiceImpl)),
346-
347331
util.NewHttpClient,
348332

349-
jClient.NewJiraClientImpl,
350-
wire.Bind(new(jClient.JiraClient), new(*jClient.JiraClientImpl)),
351-
352333
eClient.NewEventRESTClientImpl,
353334
wire.Bind(new(eClient.EventClient), new(*eClient.EventRESTClientImpl)),
354335

@@ -357,11 +338,6 @@ func InitializeApp() (*App, error) {
357338
eClient.NewEventSimpleFactoryImpl,
358339
wire.Bind(new(eClient.EventFactory), new(*eClient.EventSimpleFactoryImpl)),
359340

360-
repository.NewJiraAccountRepositoryImpl,
361-
wire.Bind(new(repository.JiraAccountRepository), new(*repository.JiraAccountRepositoryImpl)),
362-
jira.NewAccountValidatorImpl,
363-
wire.Bind(new(jira.AccountValidator), new(*jira.AccountValidatorImpl)),
364-
365341
repository.NewCiArtifactRepositoryImpl,
366342
wire.Bind(new(repository.CiArtifactRepository), new(*repository.CiArtifactRepositoryImpl)),
367343
pipeline.NewWebhookServiceImpl,
@@ -405,15 +381,6 @@ func InitializeApp() (*App, error) {
405381
//ArgoUtil.NewRepositoryService,
406382
//wire.Bind(new(ArgoUtil.RepositoryService), new(ArgoUtil.RepositoryServiceImpl)),
407383

408-
pipelineConfig.NewDbMigrationConfigRepositoryImpl,
409-
wire.Bind(new(pipelineConfig.DbMigrationConfigRepository), new(*pipelineConfig.DbMigrationConfigRepositoryImpl)),
410-
pipeline.NewDbConfigService,
411-
wire.Bind(new(pipeline.DbConfigService), new(*pipeline.DbConfigServiceImpl)),
412-
413-
repository.NewDbConfigRepositoryImpl,
414-
wire.Bind(new(repository.DbConfigRepository), new(*repository.DbConfigRepositoryImpl)),
415-
pipeline.NewDbMogrationService,
416-
wire.Bind(new(pipeline.DbMigrationService), new(*pipeline.DbMigrationServiceImpl)),
417384
//ArgoUtil.NewClusterServiceImpl,
418385
//wire.Bind(new(ArgoUtil.ClusterService), new(ArgoUtil.ClusterServiceImpl)),
419386
pipeline.GetEcrConfig,
@@ -626,23 +593,18 @@ func InitializeApp() (*App, error) {
626593
wire.Bind(new(repository4.ChartGroupReposotory), new(*repository4.ChartGroupReposotoryImpl)),
627594
repository4.NewChartGroupEntriesRepositoryImpl,
628595
wire.Bind(new(repository4.ChartGroupEntriesRepository), new(*repository4.ChartGroupEntriesRepositoryImpl)),
629-
service.NewChartGroupServiceImpl,
630-
wire.Bind(new(service.ChartGroupService), new(*service.ChartGroupServiceImpl)),
631-
restHandler.NewChartGroupRestHandlerImpl,
632-
wire.Bind(new(restHandler.ChartGroupRestHandler), new(*restHandler.ChartGroupRestHandlerImpl)),
633-
router.NewChartGroupRouterImpl,
634-
wire.Bind(new(router.ChartGroupRouter), new(*router.ChartGroupRouterImpl)),
596+
chartGroup.NewChartGroupServiceImpl,
597+
wire.Bind(new(chartGroup.ChartGroupService), new(*chartGroup.ChartGroupServiceImpl)),
598+
chartGroup2.NewChartGroupRestHandlerImpl,
599+
wire.Bind(new(chartGroup2.ChartGroupRestHandler), new(*chartGroup2.ChartGroupRestHandlerImpl)),
600+
chartGroup2.NewChartGroupRouterImpl,
601+
wire.Bind(new(chartGroup2.ChartGroupRouter), new(*chartGroup2.ChartGroupRouterImpl)),
635602
repository4.NewChartGroupDeploymentRepositoryImpl,
636603
wire.Bind(new(repository4.ChartGroupDeploymentRepository), new(*repository4.ChartGroupDeploymentRepositoryImpl)),
637604

638605
commonService.NewCommonServiceImpl,
639606
wire.Bind(new(commonService.CommonService), new(*commonService.CommonServiceImpl)),
640607

641-
router.NewTestSuitRouterImpl,
642-
wire.Bind(new(router.TestSuitRouter), new(*router.TestSuitRouterImpl)),
643-
restHandler.NewTestSuitRestHandlerImpl,
644-
wire.Bind(new(restHandler.TestSuitRestHandler), new(*restHandler.TestSuitRestHandlerImpl)),
645-
646608
router.NewImageScanRouterImpl,
647609
wire.Bind(new(router.ImageScanRouter), new(*router.ImageScanRouterImpl)),
648610
restHandler.NewImageScanRestHandlerImpl,

api/appStore/InstalledAppRestHandler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
util2 "github.com/devtron-labs/devtron/internal/util"
3939
app2 "github.com/devtron-labs/devtron/pkg/app"
4040
appStoreBean "github.com/devtron-labs/devtron/pkg/appStore/bean"
41+
"github.com/devtron-labs/devtron/pkg/appStore/chartGroup"
4142
"github.com/devtron-labs/devtron/pkg/appStore/deployment/repository"
4243
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
4344
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
@@ -325,7 +326,7 @@ func (handler *InstalledAppRestHandlerImpl) DeployBulk(w http.ResponseWriter, r
325326
return
326327
}
327328
decoder := json.NewDecoder(r.Body)
328-
var request appStoreBean.ChartGroupInstallRequest
329+
var request chartGroup.ChartGroupInstallRequest
329330
err = decoder.Decode(&request)
330331
if err != nil {
331332
handler.Logger.Errorw("request err, DeployBulk", "err", err, "payload", request)

api/restHandler/ChartGroupRestHandler.go renamed to api/appStore/chartGroup/ChartGroupRestHandler.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*/
1717

18-
package restHandler
18+
package chartGroup
1919

2020
import (
2121
"encoding/json"
@@ -24,7 +24,7 @@ import (
2424
"strconv"
2525

2626
"github.com/devtron-labs/devtron/api/restHandler/common"
27-
"github.com/devtron-labs/devtron/pkg/appStore/deployment/service"
27+
"github.com/devtron-labs/devtron/pkg/appStore/chartGroup"
2828
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
2929
"github.com/devtron-labs/devtron/pkg/auth/user"
3030
"github.com/gorilla/mux"
@@ -35,14 +35,14 @@ import (
3535
const CHART_GROUP_DELETE_SUCCESS_RESP = "Chart group deleted successfully."
3636

3737
type ChartGroupRestHandlerImpl struct {
38-
ChartGroupService service.ChartGroupService
38+
ChartGroupService chartGroup.ChartGroupService
3939
Logger *zap.SugaredLogger
4040
userAuthService user.UserService
4141
enforcer casbin.Enforcer
4242
validator *validator.Validate
4343
}
4444

45-
func NewChartGroupRestHandlerImpl(ChartGroupService service.ChartGroupService,
45+
func NewChartGroupRestHandlerImpl(ChartGroupService chartGroup.ChartGroupService,
4646
Logger *zap.SugaredLogger, userAuthService user.UserService,
4747
enforcer casbin.Enforcer, validator *validator.Validate) *ChartGroupRestHandlerImpl {
4848
return &ChartGroupRestHandlerImpl{
@@ -72,7 +72,7 @@ func (impl *ChartGroupRestHandlerImpl) CreateChartGroup(w http.ResponseWriter, r
7272
return
7373
}
7474
decoder := json.NewDecoder(r.Body)
75-
var request service.ChartGroupBean
75+
var request chartGroup.ChartGroupBean
7676
err = decoder.Decode(&request)
7777
if err != nil {
7878
impl.Logger.Errorw("request err, CreateChartGroup", "err", err, "payload", request)
@@ -101,7 +101,7 @@ func (impl *ChartGroupRestHandlerImpl) CreateChartGroup(w http.ResponseWriter, r
101101
if err != nil {
102102
impl.Logger.Errorw("service err, CreateChartGroup", "err", err, "payload", request)
103103
statusCode := http.StatusInternalServerError
104-
if service.AppNameAlreadyExistsError == err.Error() {
104+
if chartGroup.AppNameAlreadyExistsError == err.Error() {
105105
statusCode = http.StatusBadRequest
106106
}
107107
common.WriteJsonResp(w, err, nil, statusCode)
@@ -117,7 +117,7 @@ func (impl *ChartGroupRestHandlerImpl) UpdateChartGroup(w http.ResponseWriter, r
117117
return
118118
}
119119
decoder := json.NewDecoder(r.Body)
120-
var request service.ChartGroupBean
120+
var request chartGroup.ChartGroupBean
121121
err = decoder.Decode(&request)
122122
if err != nil {
123123
impl.Logger.Errorw("request err, UpdateChartGroup", "err", err, "payload", request)
@@ -158,7 +158,7 @@ func (impl *ChartGroupRestHandlerImpl) SaveChartGroupEntries(w http.ResponseWrit
158158
return
159159
}
160160
decoder := json.NewDecoder(r.Body)
161-
var request service.ChartGroupBean
161+
var request chartGroup.ChartGroupBean
162162
err = decoder.Decode(&request)
163163
if err != nil {
164164
impl.Logger.Errorw("request err, SaveChartGroupEntries", "err", err, "payload", request)
@@ -326,7 +326,7 @@ func (impl *ChartGroupRestHandlerImpl) DeleteChartGroup(w http.ResponseWriter, r
326326
return
327327
}
328328
decoder := json.NewDecoder(r.Body)
329-
var request service.ChartGroupBean
329+
var request chartGroup.ChartGroupBean
330330
err = decoder.Decode(&request)
331331
if err != nil {
332332
impl.Logger.Errorw("request err, DeleteChartGroup", "err", err, "payload", request)

api/router/ChartGroupRouter.go renamed to api/appStore/chartGroup/ChartGroupRouter.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,25 @@
1515
*
1616
*/
1717

18-
package router
18+
package chartGroup
1919

2020
import (
21-
"github.com/devtron-labs/devtron/api/restHandler"
2221
"github.com/gorilla/mux"
2322
)
2423

2524
type ChartGroupRouterImpl struct {
26-
ChartGroupRestHandler restHandler.ChartGroupRestHandler
25+
ChartGroupRestHandler ChartGroupRestHandler
2726
}
2827
type ChartGroupRouter interface {
29-
initChartGroupRouter(helmRouter *mux.Router)
28+
InitChartGroupRouter(helmRouter *mux.Router)
3029
}
3130

32-
func NewChartGroupRouterImpl(ChartGroupRestHandler restHandler.ChartGroupRestHandler) *ChartGroupRouterImpl {
31+
func NewChartGroupRouterImpl(ChartGroupRestHandler ChartGroupRestHandler) *ChartGroupRouterImpl {
3332
return &ChartGroupRouterImpl{ChartGroupRestHandler: ChartGroupRestHandler}
3433

3534
}
3635

37-
func (impl *ChartGroupRouterImpl) initChartGroupRouter(chartGroupRouter *mux.Router) {
36+
func (impl *ChartGroupRouterImpl) InitChartGroupRouter(chartGroupRouter *mux.Router) {
3837
chartGroupRouter.Path("/").
3938
HandlerFunc(impl.ChartGroupRestHandler.CreateChartGroup).Methods("POST")
4039
chartGroupRouter.Path("/").

api/restHandler/BulkUpdateRestHandler.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type BulkUpdateRestHandlerImpl struct {
5151
bulkUpdateService bulkAction.BulkUpdateService
5252
chartService chart.ChartService
5353
propertiesConfigService pipeline.PropertiesConfigService
54-
dbMigrationService pipeline.DbMigrationService
5554
application application.ServiceClient
5655
userAuthService user.UserService
5756
validator *validator.Validate
@@ -76,7 +75,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg
7675
bulkUpdateService bulkAction.BulkUpdateService,
7776
chartService chart.ChartService,
7877
propertiesConfigService pipeline.PropertiesConfigService,
79-
dbMigrationService pipeline.DbMigrationService,
8078
application application.ServiceClient,
8179
userAuthService user.UserService,
8280
teamService team.TeamService,
@@ -99,7 +97,6 @@ func NewBulkUpdateRestHandlerImpl(pipelineBuilder pipeline.PipelineBuilder, logg
9997
bulkUpdateService: bulkUpdateService,
10098
chartService: chartService,
10199
propertiesConfigService: propertiesConfigService,
102-
dbMigrationService: dbMigrationService,
103100
application: application,
104101
userAuthService: userAuthService,
105102
validator: validator,

api/restHandler/GitProviderRestHandler.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ type GitProviderRestHandlerImpl struct {
4848
dockerRegistryConfig pipeline.DockerRegistryConfig
4949
logger *zap.SugaredLogger
5050
gitRegistryConfig pipeline.GitRegistryConfig
51-
dbConfigService pipeline.DbConfigService
5251
userAuthService user.UserService
5352
validator *validator.Validate
5453
enforcer casbin.Enforcer
@@ -59,14 +58,13 @@ type GitProviderRestHandlerImpl struct {
5958
func NewGitProviderRestHandlerImpl(dockerRegistryConfig pipeline.DockerRegistryConfig,
6059
logger *zap.SugaredLogger,
6160
gitRegistryConfig pipeline.GitRegistryConfig,
62-
dbConfigService pipeline.DbConfigService, userAuthService user.UserService,
61+
userAuthService user.UserService,
6362
validator *validator.Validate, enforcer casbin.Enforcer, teamService team.TeamService,
6463
deleteServiceFullMode delete2.DeleteServiceFullMode) *GitProviderRestHandlerImpl {
6564
return &GitProviderRestHandlerImpl{
6665
dockerRegistryConfig: dockerRegistryConfig,
6766
logger: logger,
6867
gitRegistryConfig: gitRegistryConfig,
69-
dbConfigService: dbConfigService,
7068
userAuthService: userAuthService,
7169
validator: validator,
7270
enforcer: enforcer,

0 commit comments

Comments
 (0)