Skip to content

Commit 90efab1

Browse files
committed
chore: app router and rest handler restructuring
1 parent ad9a8b0 commit 90efab1

Some content is hidden

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

49 files changed

+1362
-1511
lines changed

Wire.go

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,26 @@ import (
4444
"github.com/devtron-labs/devtron/api/k8s"
4545
"github.com/devtron-labs/devtron/api/module"
4646
"github.com/devtron-labs/devtron/api/restHandler"
47-
pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app"
47+
"github.com/devtron-labs/devtron/api/restHandler/app/appInfo"
48+
appList2 "github.com/devtron-labs/devtron/api/restHandler/app/appList"
49+
pipeline3 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline"
50+
pipeline2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure"
51+
"github.com/devtron-labs/devtron/api/restHandler/app/pipeline/history"
52+
status2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/status"
53+
"github.com/devtron-labs/devtron/api/restHandler/app/pipeline/trigger"
54+
"github.com/devtron-labs/devtron/api/restHandler/app/pipeline/webhook"
55+
"github.com/devtron-labs/devtron/api/restHandler/app/workflow"
4856
"github.com/devtron-labs/devtron/api/restHandler/scopedVariable"
4957
"github.com/devtron-labs/devtron/api/router"
58+
app3 "github.com/devtron-labs/devtron/api/router/app"
59+
appInfo2 "github.com/devtron-labs/devtron/api/router/app/appInfo"
60+
"github.com/devtron-labs/devtron/api/router/app/appList"
61+
pipeline5 "github.com/devtron-labs/devtron/api/router/app/pipeline"
62+
pipeline4 "github.com/devtron-labs/devtron/api/router/app/pipeline/configure"
63+
history2 "github.com/devtron-labs/devtron/api/router/app/pipeline/history"
64+
status3 "github.com/devtron-labs/devtron/api/router/app/pipeline/status"
65+
trigger2 "github.com/devtron-labs/devtron/api/router/app/pipeline/trigger"
66+
workflow2 "github.com/devtron-labs/devtron/api/router/app/workflow"
5067
"github.com/devtron-labs/devtron/api/router/pubsub"
5168
"github.com/devtron-labs/devtron/api/server"
5269
"github.com/devtron-labs/devtron/api/sse"
@@ -81,7 +98,6 @@ import (
8198
resourceGroup "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup"
8299
security2 "github.com/devtron-labs/devtron/internal/sql/repository/security"
83100
"github.com/devtron-labs/devtron/internal/util"
84-
"github.com/devtron-labs/devtron/internal/util/ArgoUtil"
85101
"github.com/devtron-labs/devtron/pkg/app"
86102
"github.com/devtron-labs/devtron/pkg/app/status"
87103
"github.com/devtron-labs/devtron/pkg/appClone"
@@ -183,8 +199,8 @@ func InitializeApp() (*App, error) {
183199
wire.Bind(new(session2.ServiceClient), new(*middleware.LoginService)),
184200

185201
sse.NewSSE,
186-
router.NewPipelineTriggerRouter,
187-
wire.Bind(new(router.PipelineTriggerRouter), new(*router.PipelineTriggerRouterImpl)),
202+
trigger2.NewPipelineTriggerRouter,
203+
wire.Bind(new(trigger2.PipelineTriggerRouter), new(*trigger2.PipelineTriggerRouterImpl)),
188204

189205
//---- pprof start ----
190206
restHandler.NewPProfRestHandler,
@@ -194,8 +210,8 @@ func InitializeApp() (*App, error) {
194210
wire.Bind(new(router.PProfRouter), new(*router.PProfRouterImpl)),
195211
//---- pprof end ----
196212

197-
restHandler.NewPipelineRestHandler,
198-
wire.Bind(new(restHandler.PipelineTriggerRestHandler), new(*restHandler.PipelineTriggerRestHandlerImpl)),
213+
trigger.NewPipelineRestHandler,
214+
wire.Bind(new(trigger.PipelineTriggerRestHandler), new(*trigger.PipelineTriggerRestHandlerImpl)),
199215
app.GetAppServiceConfig,
200216
app.NewAppService,
201217
wire.Bind(new(app.AppService), new(*app.AppServiceImpl)),
@@ -249,13 +265,25 @@ func InitializeApp() (*App, error) {
249265
wire.Bind(new(pipeline.CdPipelineConfigService), new(*pipeline.CdPipelineConfigServiceImpl)),
250266
pipeline.NewDevtronAppConfigServiceImpl,
251267
wire.Bind(new(pipeline.DevtronAppConfigService), new(*pipeline.DevtronAppConfigServiceImpl)),
268+
pipeline3.NewDevtronAppAutoCompleteRestHandlerImpl,
269+
wire.Bind(new(pipeline3.DevtronAppAutoCompleteRestHandler), new(*pipeline3.DevtronAppAutoCompleteRestHandlerImpl)),
252270

253271
util5.NewLoggingMiddlewareImpl,
254272
wire.Bind(new(util5.LoggingMiddleware), new(*util5.LoggingMiddlewareImpl)),
255273
pipeline2.NewPipelineRestHandlerImpl,
256274
wire.Bind(new(pipeline2.PipelineConfigRestHandler), new(*pipeline2.PipelineConfigRestHandlerImpl)),
257-
router.NewPipelineRouterImpl,
258-
wire.Bind(new(router.PipelineConfigRouter), new(*router.PipelineConfigRouterImpl)),
275+
276+
pipeline4.NewPipelineRouterImpl,
277+
wire.Bind(new(pipeline4.PipelineConfigRouter), new(*pipeline4.PipelineConfigRouterImpl)),
278+
history2.NewPipelineHistoryRouterImpl,
279+
wire.Bind(new(history2.PipelineHistoryRouter), new(*history2.PipelineHistoryRouterImpl)),
280+
status3.NewPipelineStatusRouterImpl,
281+
wire.Bind(new(status3.PipelineStatusRouter), new(*status3.PipelineStatusRouterImpl)),
282+
pipeline5.NewDevtronAppAutoCompleteRouterImpl,
283+
wire.Bind(new(pipeline5.DevtronAppAutoCompleteRouter), new(*pipeline5.DevtronAppAutoCompleteRouterImpl)),
284+
workflow2.NewAppWorkflowRouterImpl,
285+
wire.Bind(new(workflow2.AppWorkflowRouter), new(*workflow2.AppWorkflowRouterImpl)),
286+
259287
pipeline.NewCiCdPipelineOrchestrator,
260288
wire.Bind(new(pipeline.CiCdPipelineOrchestrator), new(*pipeline.CiCdPipelineOrchestratorImpl)),
261289
pipelineConfig.NewMaterialRepositoryImpl,
@@ -306,10 +334,15 @@ func InitializeApp() (*App, error) {
306334
pipeline.NewGitRegistryConfigImpl,
307335
wire.Bind(new(pipeline.GitRegistryConfig), new(*pipeline.GitRegistryConfigImpl)),
308336

309-
router.NewAppListingRouterImpl,
310-
wire.Bind(new(router.AppListingRouter), new(*router.AppListingRouterImpl)),
311-
restHandler.NewAppListingRestHandlerImpl,
312-
wire.Bind(new(restHandler.AppListingRestHandler), new(*restHandler.AppListingRestHandlerImpl)),
337+
appList.NewAppFilteringRouterImpl,
338+
wire.Bind(new(appList.AppFilteringRouter), new(*appList.AppFilteringRouterImpl)),
339+
appList2.NewAppFilteringRestHandlerImpl,
340+
wire.Bind(new(appList2.AppFilteringRestHandler), new(*appList2.AppFilteringRestHandlerImpl)),
341+
342+
appList.NewAppListingRouterImpl,
343+
wire.Bind(new(appList.AppListingRouter), new(*appList.AppListingRouterImpl)),
344+
appList2.NewAppListingRestHandlerImpl,
345+
wire.Bind(new(appList2.AppListingRestHandler), new(*appList2.AppListingRestHandlerImpl)),
313346
app.NewAppListingServiceImpl,
314347
wire.Bind(new(app.AppListingService), new(*app.AppListingServiceImpl)),
315348
repository.NewAppListingRepositoryImpl,
@@ -364,22 +397,6 @@ func InitializeApp() (*App, error) {
364397

365398
//app.GetConfig,
366399

367-
router.NewCDRouterImpl,
368-
wire.Bind(new(router.CDRouter), new(*router.CDRouterImpl)),
369-
restHandler.NewCDRestHandlerImpl,
370-
wire.Bind(new(restHandler.CDRestHandler), new(*restHandler.CDRestHandlerImpl)),
371-
372-
ArgoUtil.GetArgoConfig,
373-
ArgoUtil.NewArgoSession,
374-
ArgoUtil.NewResourceServiceImpl,
375-
wire.Bind(new(ArgoUtil.ResourceService), new(*ArgoUtil.ResourceServiceImpl)),
376-
//ArgoUtil.NewApplicationServiceImpl,
377-
//wire.Bind(new(ArgoUtil.ApplicationService), new(ArgoUtil.ApplicationServiceImpl)),
378-
//ArgoUtil.NewRepositoryService,
379-
//wire.Bind(new(ArgoUtil.RepositoryService), new(ArgoUtil.RepositoryServiceImpl)),
380-
381-
//ArgoUtil.NewClusterServiceImpl,
382-
//wire.Bind(new(ArgoUtil.ClusterService), new(ArgoUtil.ClusterServiceImpl)),
383400
pipeline.GetEcrConfig,
384401
//otel.NewOtelTracingServiceImpl,
385402
//wire.Bind(new(otel.OtelTracingService), new(*otel.OtelTracingServiceImpl)),
@@ -511,8 +528,8 @@ func InitializeApp() (*App, error) {
511528
appStoreRestHandler.NewAppStoreRouterImpl,
512529
wire.Bind(new(appStoreRestHandler.AppStoreRouter), new(*appStoreRestHandler.AppStoreRouterImpl)),
513530

514-
restHandler.NewAppWorkflowRestHandlerImpl,
515-
wire.Bind(new(restHandler.AppWorkflowRestHandler), new(*restHandler.AppWorkflowRestHandlerImpl)),
531+
workflow.NewAppWorkflowRestHandlerImpl,
532+
wire.Bind(new(workflow.AppWorkflowRestHandler), new(*workflow.AppWorkflowRestHandlerImpl)),
516533

517534
appWorkflow.NewAppWorkflowServiceImpl,
518535
wire.Bind(new(appWorkflow.AppWorkflowService), new(*appWorkflow.AppWorkflowServiceImpl)),
@@ -709,13 +726,15 @@ func InitializeApp() (*App, error) {
709726
wire.Bind(new(repository.WebhookEventDataRepository), new(*repository.WebhookEventDataRepositoryImpl)),
710727
pipeline.NewWebhookEventDataConfigImpl,
711728
wire.Bind(new(pipeline.WebhookEventDataConfig), new(*pipeline.WebhookEventDataConfigImpl)),
712-
restHandler.NewWebhookDataRestHandlerImpl,
713-
wire.Bind(new(restHandler.WebhookDataRestHandler), new(*restHandler.WebhookDataRestHandlerImpl)),
729+
webhook.NewWebhookDataRestHandlerImpl,
730+
wire.Bind(new(webhook.WebhookDataRestHandler), new(*webhook.WebhookDataRestHandlerImpl)),
714731

715-
router.NewAppRouterImpl,
716-
wire.Bind(new(router.AppRouter), new(*router.AppRouterImpl)),
717-
restHandler.NewAppRestHandlerImpl,
718-
wire.Bind(new(restHandler.AppRestHandler), new(*restHandler.AppRestHandlerImpl)),
732+
app3.NewAppRouterImpl,
733+
wire.Bind(new(app3.AppRouter), new(*app3.AppRouterImpl)),
734+
appInfo2.NewAppInfoRouterImpl,
735+
wire.Bind(new(appInfo2.AppInfoRouter), new(*appInfo2.AppInfoRouterImpl)),
736+
appInfo.NewAppInfoRestHandlerImpl,
737+
wire.Bind(new(appInfo.AppInfoRestHandler), new(*appInfo.AppInfoRestHandlerImpl)),
719738

720739
app.NewAppCrudOperationServiceImpl,
721740
wire.Bind(new(app.AppCrudOperationService), new(*app.AppCrudOperationServiceImpl)),
@@ -734,8 +753,8 @@ func InitializeApp() (*App, error) {
734753
// util2.NewGoJsonSchemaCustomFormatChecker,
735754

736755
//history starts
737-
restHandler.NewPipelineHistoryRestHandlerImpl,
738-
wire.Bind(new(restHandler.PipelineHistoryRestHandler), new(*restHandler.PipelineHistoryRestHandlerImpl)),
756+
history.NewPipelineHistoryRestHandlerImpl,
757+
wire.Bind(new(history.PipelineHistoryRestHandler), new(*history.PipelineHistoryRestHandlerImpl)),
739758

740759
repository3.NewConfigMapHistoryRepositoryImpl,
741760
wire.Bind(new(repository3.ConfigMapHistoryRepository), new(*repository3.ConfigMapHistoryRepositoryImpl)),
@@ -824,8 +843,8 @@ func InitializeApp() (*App, error) {
824843
cron.NewCiTriggerCronImpl,
825844
wire.Bind(new(cron.CiTriggerCron), new(*cron.CiTriggerCronImpl)),
826845

827-
restHandler.NewPipelineStatusTimelineRestHandlerImpl,
828-
wire.Bind(new(restHandler.PipelineStatusTimelineRestHandler), new(*restHandler.PipelineStatusTimelineRestHandlerImpl)),
846+
status2.NewPipelineStatusTimelineRestHandlerImpl,
847+
wire.Bind(new(status2.PipelineStatusTimelineRestHandler), new(*status2.PipelineStatusTimelineRestHandlerImpl)),
829848

830849
status.NewPipelineStatusTimelineServiceImpl,
831850
wire.Bind(new(status.PipelineStatusTimelineService), new(*status.PipelineStatusTimelineServiceImpl)),

api/restHandler/CDRestHandler.go

Lines changed: 0 additions & 73 deletions
This file was deleted.

api/restHandler/CoreAppRestHandler.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25+
app2 "github.com/devtron-labs/devtron/api/restHandler/app/pipeline/configure"
2526
"net/http"
2627
"strconv"
2728
"strings"
2829
"time"
2930

3031
appBean "github.com/devtron-labs/devtron/api/appbean"
31-
app2 "github.com/devtron-labs/devtron/api/restHandler/app"
3232
"github.com/devtron-labs/devtron/api/restHandler/common"
3333
"github.com/devtron-labs/devtron/internal/sql/models"
3434
"github.com/devtron-labs/devtron/internal/sql/repository"
@@ -63,7 +63,6 @@ const (
6363
APP_DELETE_FAILED_RESP = "App deletion failed, please try deleting from Devtron UI"
6464
APP_CREATE_SUCCESSFUL_RESP = "App created successfully."
6565
APP_WORKFLOW_CREATE_SUCCESSFUL_RESP = "App workflow created successfully."
66-
WORKFLOW_NAME_EMPTY = ""
6766
)
6867

6968
type CoreAppRestHandler interface {

api/restHandler/ExternalCiRestHandler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package restHandler
1919

2020
import (
2121
"encoding/json"
22+
util3 "github.com/devtron-labs/devtron/api/util"
2223
"net/http"
2324
"strconv"
2425

@@ -63,7 +64,7 @@ func NewExternalCiRestHandlerImpl(logger *zap.SugaredLogger, webhookService pipe
6364
}
6465

6566
func (impl ExternalCiRestHandlerImpl) HandleExternalCiWebhook(w http.ResponseWriter, r *http.Request) {
66-
setupResponse(&w, r)
67+
util3.SetupCorsOriginHeader(&w)
6768
vars := mux.Vars(r)
6869
token := r.Header.Get("api-token")
6970
userId, err := impl.userService.GetLoggedInUser(r)

api/restHandler/PipelineStatusTimelineRestHandler.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)