From 390dea2ec63ead5b5375e093971ddead4a688df9 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 11:00:08 +0530 Subject: [PATCH 01/23] wip --- api/appStore/InstalledAppRestHandler.go | 2 +- api/bean/{ => AppView}/AppView.go | 2 +- api/helm-app/gRPC/applicationClient.go | 13 + api/helm-app/gRPC/applist.pb.go | 293 +++++++++--------- api/helm-app/gRPC/applist.proto | 1 + api/helm-app/gRPC/applist_grpc.pb.go | 36 +++ api/helm-app/service/HelmAppService.go | 4 +- api/helm-app/service/HelmAppService_ent.go | 10 + .../application/k8sApplicationRestHandler.go | 8 +- .../app/appList/AppListingRestHandler.go | 32 +- cmd/external-app/wire_gen.go | 2 +- .../sql/repository/AppListingRepository.go | 92 +++--- internal/sql/repository/LinkoutsRepository.go | 8 +- .../repository/mocks/AppListingRepository.go | 3 +- pkg/app/AppListingService.go | 124 ++++---- pkg/app/AppListingService_ent.go | 9 + pkg/app/AppListingViewBuilder.go | 20 +- pkg/app/mocks/AppListingService.go | 2 +- pkg/appClone/AppCloneService.go | 13 +- .../service/EAMode/InstalledAppDBService.go | 2 +- .../FullMode/resource/ResourceTreeService.go | 14 +- pkg/bean/app.go | 2 +- pkg/cluster/ClusterDescriptionService.go | 2 +- .../DeploymentTemplateService_test.go | 4 +- pkg/genericNotes/GenericNoteService.go | 24 +- .../tests/GenericNoteService_test.go | 2 +- pkg/k8s/K8sCommonService.go | 6 +- .../mocks/K8sApplicationService.go | 2 +- wire_gen.go | 2 +- 29 files changed, 411 insertions(+), 323 deletions(-) rename api/bean/{ => AppView}/AppView.go (99%) create mode 100644 api/helm-app/service/HelmAppService_ent.go create mode 100644 pkg/app/AppListingService_ent.go diff --git a/api/appStore/InstalledAppRestHandler.go b/api/appStore/InstalledAppRestHandler.go index 873e1b2494..e2595d0562 100644 --- a/api/appStore/InstalledAppRestHandler.go +++ b/api/appStore/InstalledAppRestHandler.go @@ -21,6 +21,7 @@ import ( "encoding/json" "errors" "fmt" + bean2 "github.com/devtron-labs/devtron/api/bean/AppView" client "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/deploymentTypeChange" @@ -35,7 +36,6 @@ import ( "strings" "time" - bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/api/restHandler/common" "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/client/cron" diff --git a/api/bean/AppView.go b/api/bean/AppView/AppView.go similarity index 99% rename from api/bean/AppView.go rename to api/bean/AppView/AppView.go index 61fbe04f47..d82191cba0 100644 --- a/api/bean/AppView.go +++ b/api/bean/AppView/AppView.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package bean +package AppView import ( "encoding/json" diff --git a/api/helm-app/gRPC/applicationClient.go b/api/helm-app/gRPC/applicationClient.go index ae2efe2922..3ff4ccbe17 100644 --- a/api/helm-app/gRPC/applicationClient.go +++ b/api/helm-app/gRPC/applicationClient.go @@ -34,6 +34,7 @@ type HelmAppClient interface { GetAppDetail(ctx context.Context, in *AppDetailRequest) (*AppDetail, error) GetResourceTreeForExternalResources(ctx context.Context, in *ExternalResourceTreeRequest) (*ResourceTreeResponse, error) GetAppStatus(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) + GetAppStatusV2(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) UnHibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) GetDeploymentHistory(ctx context.Context, in *AppDetailRequest) (*HelmAppDeploymentHistory, error) @@ -164,6 +165,18 @@ func (impl *HelmAppClientImpl) GetAppStatus(ctx context.Context, in *AppDetailRe return appStatus, nil } +func (impl *HelmAppClientImpl) GetAppStatusV2(ctx context.Context, in *AppDetailRequest) (*AppStatus, error) { + applicationClient, err := impl.getApplicationClient() + if err != nil { + return nil, err + } + appStatus, err := applicationClient.GetAppStatus(ctx, in) + if err != nil { + return nil, err + } + return appStatus, nil +} + func (impl *HelmAppClientImpl) Hibernate(ctx context.Context, in *HibernateRequest) (*HibernateResponse, error) { applicationClient, err := impl.getApplicationClient() if err != nil { diff --git a/api/helm-app/gRPC/applist.pb.go b/api/helm-app/gRPC/applist.pb.go index 9b2bd2ce39..b7524a9f1e 100644 --- a/api/helm-app/gRPC/applist.pb.go +++ b/api/helm-app/gRPC/applist.pb.go @@ -4830,7 +4830,7 @@ var file_api_helm_app_gRPC_applist_proto_rawDesc = []byte{ 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x52, 0x4f, 0x58, 0x59, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x53, 0x48, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x49, 0x52, 0x45, 0x43, - 0x54, 0x10, 0x02, 0x32, 0xa6, 0x0d, 0x0a, 0x12, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x54, 0x10, 0x02, 0x32, 0xd9, 0x0d, 0x0a, 0x12, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x0f, 0x2e, 0x41, 0x70, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, @@ -4845,102 +4845,105 @@ var file_api_helm_app_gRPC_applist_proto_rawDesc = []byte{ 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x41, - 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x09, 0x48, 0x69, - 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, - 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x36, 0x0a, 0x0b, 0x55, 0x6e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, - 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x44, - 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x22, 0x00, - 0x12, 0x32, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x59, 0x61, 0x6d, - 0x6c, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, 0x73, 0x69, 0x72, - 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x2e, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x44, 0x65, 0x73, - 0x69, 0x72, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x10, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, - 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x19, - 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x55, - 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, + 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x0e, 0x47, 0x65, + 0x74, 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x56, 0x32, 0x12, 0x11, 0x2e, 0x41, + 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x0a, 0x2e, 0x41, 0x70, 0x70, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x00, 0x12, 0x34, 0x0a, + 0x09, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x48, 0x69, 0x62, + 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, + 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x0b, 0x55, 0x6e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, + 0x74, 0x65, 0x12, 0x11, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x48, 0x69, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x14, 0x47, + 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, + 0x6f, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x41, 0x70, 0x70, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, + 0x79, 0x22, 0x00, 0x12, 0x32, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x59, 0x61, 0x6d, 0x6c, 0x12, 0x11, 0x2e, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, + 0x73, 0x69, 0x72, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x2e, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, + 0x44, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x10, 0x55, 0x6e, 0x69, + 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x12, 0x2e, + 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x1a, 0x19, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, + 0x0a, 0x0e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x12, 0x16, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, + 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x70, + 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, + 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x49, 0x6e, + 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x1b, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x68, 0x61, 0x72, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x4c, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x19, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, - 0x0a, 0x0e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x1b, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x68, 0x61, 0x72, 0x74, 0x49, 0x6e, - 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, - 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, - 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x12, 0x49, 0x73, 0x52, 0x65, 0x6c, 0x65, 0x61, - 0x73, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x12, 0x2e, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, - 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0d, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, - 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, - 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x54, - 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x11, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, - 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x42, 0x75, 0x6c, 0x6b, 0x12, 0x1a, 0x2e, 0x42, 0x75, - 0x6c, 0x6b, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x42, 0x75, 0x6c, 0x6b, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, - 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, 0x73, 0x74, 0x6f, - 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1a, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, - 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x39, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x49, 0x6e, - 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x1d, 0x55, 0x70, - 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, - 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x55, 0x70, - 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, - 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, - 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x1a, 0x14, 0x2e, 0x4f, 0x43, 0x49, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x6f, 0x72, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x45, 0x78, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x3b, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x46, 0x6c, 0x75, 0x78, 0x41, 0x70, 0x70, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x12, 0x15, 0x2e, 0x46, 0x6c, 0x75, 0x78, 0x41, 0x70, 0x70, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x46, 0x6c, - 0x75, 0x78, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x12, 0x3d, 0x0a, - 0x11, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x73, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x12, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, - 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x42, 0x31, 0x5a, 0x2f, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x65, 0x76, 0x74, 0x72, - 0x6f, 0x6e, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x6c, 0x69, 0x6e, 0x6b, - 0x2f, 0x62, 0x65, 0x61, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x67, 0x52, 0x50, 0x43, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x12, 0x49, 0x73, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x65, 0x64, 0x12, 0x12, + 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, + 0x65, 0x72, 0x1a, 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x52, 0x6f, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x52, 0x6f, 0x6c, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0d, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, + 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, + 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x16, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x11, 0x54, 0x65, 0x6d, + 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x42, 0x75, 0x6c, 0x6b, 0x12, 0x1a, + 0x2e, 0x42, 0x75, 0x6c, 0x6b, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x42, 0x75, 0x6c, + 0x6b, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1d, 0x49, 0x6e, 0x73, 0x74, + 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, 0x69, 0x74, 0x68, 0x43, 0x75, + 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x19, 0x2e, 0x48, 0x65, 0x6c, 0x6d, + 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x48, 0x65, 0x6c, 0x6d, 0x49, 0x6e, 0x73, 0x74, 0x61, + 0x6c, 0x6c, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x39, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x16, + 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x43, 0x68, 0x61, 0x72, 0x74, 0x4e, 0x6f, + 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, + 0x1d, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x57, + 0x69, 0x74, 0x68, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x43, 0x68, 0x61, 0x72, 0x74, 0x12, 0x16, + 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, + 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x42, 0x0a, 0x13, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x43, 0x49, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x43, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x1a, 0x14, 0x2e, + 0x4f, 0x43, 0x49, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x23, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x46, 0x6f, 0x72, 0x45, 0x78, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x1c, 0x2e, 0x45, + 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, + 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x46, 0x6c, 0x75, 0x78, 0x41, 0x70, + 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x15, 0x2e, 0x46, 0x6c, 0x75, 0x78, 0x41, 0x70, + 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, + 0x2e, 0x46, 0x6c, 0x75, 0x78, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, + 0x12, 0x3d, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x44, 0x65, + 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x12, 0x2e, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x49, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x1a, 0x12, 0x2e, 0x44, 0x65, 0x70, 0x6c, + 0x6f, 0x79, 0x65, 0x64, 0x41, 0x70, 0x70, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0x00, 0x42, + 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x65, + 0x76, 0x74, 0x72, 0x6f, 0x6e, 0x2d, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x6c, + 0x69, 0x6e, 0x6b, 0x2f, 0x62, 0x65, 0x61, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x67, 0x52, + 0x50, 0x43, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -5089,54 +5092,56 @@ var file_api_helm_app_gRPC_applist_proto_depIdxs = []int32{ 2, // 61: ApplicationService.ListFluxApplications:input_type -> AppListRequest 13, // 62: ApplicationService.GetAppDetail:input_type -> AppDetailRequest 13, // 63: ApplicationService.GetAppStatus:input_type -> AppDetailRequest - 26, // 64: ApplicationService.Hibernate:input_type -> HibernateRequest - 26, // 65: ApplicationService.UnHibernate:input_type -> HibernateRequest - 13, // 66: ApplicationService.GetDeploymentHistory:input_type -> AppDetailRequest - 13, // 67: ApplicationService.GetValuesYaml:input_type -> AppDetailRequest - 33, // 68: ApplicationService.GetDesiredManifest:input_type -> ObjectRequest - 36, // 69: ApplicationService.UninstallRelease:input_type -> ReleaseIdentifier - 37, // 70: ApplicationService.UpgradeRelease:input_type -> UpgradeReleaseRequest - 39, // 71: ApplicationService.GetDeploymentDetail:input_type -> DeploymentDetailRequest - 42, // 72: ApplicationService.InstallRelease:input_type -> InstallReleaseRequest - 42, // 73: ApplicationService.UpgradeReleaseWithChartInfo:input_type -> InstallReleaseRequest - 36, // 74: ApplicationService.IsReleaseInstalled:input_type -> ReleaseIdentifier - 46, // 75: ApplicationService.RollbackRelease:input_type -> RollbackReleaseRequest - 42, // 76: ApplicationService.TemplateChart:input_type -> InstallReleaseRequest - 43, // 77: ApplicationService.TemplateChartBulk:input_type -> BulkInstallReleaseRequest - 49, // 78: ApplicationService.InstallReleaseWithCustomChart:input_type -> HelmInstallCustomRequest - 42, // 79: ApplicationService.GetNotes:input_type -> InstallReleaseRequest - 37, // 80: ApplicationService.UpgradeReleaseWithCustomChart:input_type -> UpgradeReleaseRequest - 57, // 81: ApplicationService.ValidateOCIRegistry:input_type -> RegistryCredential - 3, // 82: ApplicationService.GetResourceTreeForExternalResources:input_type -> ExternalResourceTreeRequest - 7, // 83: ApplicationService.GetFluxAppDetail:input_type -> FluxAppDetailRequest - 36, // 84: ApplicationService.GetReleaseDetails:input_type -> ReleaseIdentifier - 10, // 85: ApplicationService.ListApplications:output_type -> DeployedAppList - 5, // 86: ApplicationService.ListFluxApplications:output_type -> FluxApplicationList - 14, // 87: ApplicationService.GetAppDetail:output_type -> AppDetail - 15, // 88: ApplicationService.GetAppStatus:output_type -> AppStatus - 29, // 89: ApplicationService.Hibernate:output_type -> HibernateResponse - 29, // 90: ApplicationService.UnHibernate:output_type -> HibernateResponse - 31, // 91: ApplicationService.GetDeploymentHistory:output_type -> HelmAppDeploymentHistory - 32, // 92: ApplicationService.GetValuesYaml:output_type -> ReleaseInfo - 34, // 93: ApplicationService.GetDesiredManifest:output_type -> DesiredManifestResponse - 35, // 94: ApplicationService.UninstallRelease:output_type -> UninstallReleaseResponse - 38, // 95: ApplicationService.UpgradeRelease:output_type -> UpgradeReleaseResponse - 40, // 96: ApplicationService.GetDeploymentDetail:output_type -> DeploymentDetailResponse - 44, // 97: ApplicationService.InstallRelease:output_type -> InstallReleaseResponse - 38, // 98: ApplicationService.UpgradeReleaseWithChartInfo:output_type -> UpgradeReleaseResponse - 45, // 99: ApplicationService.IsReleaseInstalled:output_type -> BooleanResponse - 45, // 100: ApplicationService.RollbackRelease:output_type -> BooleanResponse - 47, // 101: ApplicationService.TemplateChart:output_type -> TemplateChartResponse - 48, // 102: ApplicationService.TemplateChartBulk:output_type -> BulkTemplateChartResponse - 50, // 103: ApplicationService.InstallReleaseWithCustomChart:output_type -> HelmInstallCustomResponse - 56, // 104: ApplicationService.GetNotes:output_type -> ChartNotesResponse - 38, // 105: ApplicationService.UpgradeReleaseWithCustomChart:output_type -> UpgradeReleaseResponse - 61, // 106: ApplicationService.ValidateOCIRegistry:output_type -> OCIRegistryResponse - 18, // 107: ApplicationService.GetResourceTreeForExternalResources:output_type -> ResourceTreeResponse - 8, // 108: ApplicationService.GetFluxAppDetail:output_type -> FluxAppDetail - 11, // 109: ApplicationService.GetReleaseDetails:output_type -> DeployedAppDetail - 85, // [85:110] is the sub-list for method output_type - 60, // [60:85] is the sub-list for method input_type + 13, // 64: ApplicationService.GetAppStatusV2:input_type -> AppDetailRequest + 26, // 65: ApplicationService.Hibernate:input_type -> HibernateRequest + 26, // 66: ApplicationService.UnHibernate:input_type -> HibernateRequest + 13, // 67: ApplicationService.GetDeploymentHistory:input_type -> AppDetailRequest + 13, // 68: ApplicationService.GetValuesYaml:input_type -> AppDetailRequest + 33, // 69: ApplicationService.GetDesiredManifest:input_type -> ObjectRequest + 36, // 70: ApplicationService.UninstallRelease:input_type -> ReleaseIdentifier + 37, // 71: ApplicationService.UpgradeRelease:input_type -> UpgradeReleaseRequest + 39, // 72: ApplicationService.GetDeploymentDetail:input_type -> DeploymentDetailRequest + 42, // 73: ApplicationService.InstallRelease:input_type -> InstallReleaseRequest + 42, // 74: ApplicationService.UpgradeReleaseWithChartInfo:input_type -> InstallReleaseRequest + 36, // 75: ApplicationService.IsReleaseInstalled:input_type -> ReleaseIdentifier + 46, // 76: ApplicationService.RollbackRelease:input_type -> RollbackReleaseRequest + 42, // 77: ApplicationService.TemplateChart:input_type -> InstallReleaseRequest + 43, // 78: ApplicationService.TemplateChartBulk:input_type -> BulkInstallReleaseRequest + 49, // 79: ApplicationService.InstallReleaseWithCustomChart:input_type -> HelmInstallCustomRequest + 42, // 80: ApplicationService.GetNotes:input_type -> InstallReleaseRequest + 37, // 81: ApplicationService.UpgradeReleaseWithCustomChart:input_type -> UpgradeReleaseRequest + 57, // 82: ApplicationService.ValidateOCIRegistry:input_type -> RegistryCredential + 3, // 83: ApplicationService.GetResourceTreeForExternalResources:input_type -> ExternalResourceTreeRequest + 7, // 84: ApplicationService.GetFluxAppDetail:input_type -> FluxAppDetailRequest + 36, // 85: ApplicationService.GetReleaseDetails:input_type -> ReleaseIdentifier + 10, // 86: ApplicationService.ListApplications:output_type -> DeployedAppList + 5, // 87: ApplicationService.ListFluxApplications:output_type -> FluxApplicationList + 14, // 88: ApplicationService.GetAppDetail:output_type -> AppDetail + 15, // 89: ApplicationService.GetAppStatus:output_type -> AppStatus + 15, // 90: ApplicationService.GetAppStatusV2:output_type -> AppStatus + 29, // 91: ApplicationService.Hibernate:output_type -> HibernateResponse + 29, // 92: ApplicationService.UnHibernate:output_type -> HibernateResponse + 31, // 93: ApplicationService.GetDeploymentHistory:output_type -> HelmAppDeploymentHistory + 32, // 94: ApplicationService.GetValuesYaml:output_type -> ReleaseInfo + 34, // 95: ApplicationService.GetDesiredManifest:output_type -> DesiredManifestResponse + 35, // 96: ApplicationService.UninstallRelease:output_type -> UninstallReleaseResponse + 38, // 97: ApplicationService.UpgradeRelease:output_type -> UpgradeReleaseResponse + 40, // 98: ApplicationService.GetDeploymentDetail:output_type -> DeploymentDetailResponse + 44, // 99: ApplicationService.InstallRelease:output_type -> InstallReleaseResponse + 38, // 100: ApplicationService.UpgradeReleaseWithChartInfo:output_type -> UpgradeReleaseResponse + 45, // 101: ApplicationService.IsReleaseInstalled:output_type -> BooleanResponse + 45, // 102: ApplicationService.RollbackRelease:output_type -> BooleanResponse + 47, // 103: ApplicationService.TemplateChart:output_type -> TemplateChartResponse + 48, // 104: ApplicationService.TemplateChartBulk:output_type -> BulkTemplateChartResponse + 50, // 105: ApplicationService.InstallReleaseWithCustomChart:output_type -> HelmInstallCustomResponse + 56, // 106: ApplicationService.GetNotes:output_type -> ChartNotesResponse + 38, // 107: ApplicationService.UpgradeReleaseWithCustomChart:output_type -> UpgradeReleaseResponse + 61, // 108: ApplicationService.ValidateOCIRegistry:output_type -> OCIRegistryResponse + 18, // 109: ApplicationService.GetResourceTreeForExternalResources:output_type -> ResourceTreeResponse + 8, // 110: ApplicationService.GetFluxAppDetail:output_type -> FluxAppDetail + 11, // 111: ApplicationService.GetReleaseDetails:output_type -> DeployedAppDetail + 86, // [86:112] is the sub-list for method output_type + 60, // [60:86] is the sub-list for method input_type 60, // [60:60] is the sub-list for extension type_name 60, // [60:60] is the sub-list for extension extendee 0, // [0:60] is the sub-list for field type_name diff --git a/api/helm-app/gRPC/applist.proto b/api/helm-app/gRPC/applist.proto index 8bb8de371f..249d84624d 100644 --- a/api/helm-app/gRPC/applist.proto +++ b/api/helm-app/gRPC/applist.proto @@ -24,6 +24,7 @@ service ApplicationService { rpc ListFluxApplications(AppListRequest) returns (stream FluxApplicationList){} rpc GetAppDetail(AppDetailRequest) returns (AppDetail){} rpc GetAppStatus(AppDetailRequest) returns (AppStatus){} + rpc GetAppStatusV2(AppDetailRequest) returns (AppStatus){} rpc Hibernate(HibernateRequest) returns (HibernateResponse){} rpc UnHibernate(HibernateRequest) returns (HibernateResponse){} rpc GetDeploymentHistory(AppDetailRequest) returns (HelmAppDeploymentHistory){} diff --git a/api/helm-app/gRPC/applist_grpc.pb.go b/api/helm-app/gRPC/applist_grpc.pb.go index fabade6bcb..517352337e 100644 --- a/api/helm-app/gRPC/applist_grpc.pb.go +++ b/api/helm-app/gRPC/applist_grpc.pb.go @@ -26,6 +26,7 @@ type ApplicationServiceClient interface { ListFluxApplications(ctx context.Context, in *AppListRequest, opts ...grpc.CallOption) (ApplicationService_ListFluxApplicationsClient, error) GetAppDetail(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppDetail, error) GetAppStatus(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppStatus, error) + GetAppStatusV2(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppStatus, error) Hibernate(ctx context.Context, in *HibernateRequest, opts ...grpc.CallOption) (*HibernateResponse, error) UnHibernate(ctx context.Context, in *HibernateRequest, opts ...grpc.CallOption) (*HibernateResponse, error) GetDeploymentHistory(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*HelmAppDeploymentHistory, error) @@ -139,6 +140,15 @@ func (c *applicationServiceClient) GetAppStatus(ctx context.Context, in *AppDeta return out, nil } +func (c *applicationServiceClient) GetAppStatusV2(ctx context.Context, in *AppDetailRequest, opts ...grpc.CallOption) (*AppStatus, error) { + out := new(AppStatus) + err := c.cc.Invoke(ctx, "/ApplicationService/GetAppStatusV2", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *applicationServiceClient) Hibernate(ctx context.Context, in *HibernateRequest, opts ...grpc.CallOption) (*HibernateResponse, error) { out := new(HibernateResponse) err := c.cc.Invoke(ctx, "/ApplicationService/Hibernate", in, out, opts...) @@ -336,6 +346,7 @@ type ApplicationServiceServer interface { ListFluxApplications(*AppListRequest, ApplicationService_ListFluxApplicationsServer) error GetAppDetail(context.Context, *AppDetailRequest) (*AppDetail, error) GetAppStatus(context.Context, *AppDetailRequest) (*AppStatus, error) + GetAppStatusV2(context.Context, *AppDetailRequest) (*AppStatus, error) Hibernate(context.Context, *HibernateRequest) (*HibernateResponse, error) UnHibernate(context.Context, *HibernateRequest) (*HibernateResponse, error) GetDeploymentHistory(context.Context, *AppDetailRequest) (*HelmAppDeploymentHistory, error) @@ -376,6 +387,9 @@ func (UnimplementedApplicationServiceServer) GetAppDetail(context.Context, *AppD func (UnimplementedApplicationServiceServer) GetAppStatus(context.Context, *AppDetailRequest) (*AppStatus, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAppStatus not implemented") } +func (UnimplementedApplicationServiceServer) GetAppStatusV2(context.Context, *AppDetailRequest) (*AppStatus, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetAppStatusV2 not implemented") +} func (UnimplementedApplicationServiceServer) Hibernate(context.Context, *HibernateRequest) (*HibernateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Hibernate not implemented") } @@ -530,6 +544,24 @@ func _ApplicationService_GetAppStatus_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _ApplicationService_GetAppStatusV2_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AppDetailRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ApplicationServiceServer).GetAppStatusV2(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ApplicationService/GetAppStatusV2", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ApplicationServiceServer).GetAppStatusV2(ctx, req.(*AppDetailRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _ApplicationService_Hibernate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(HibernateRequest) if err := dec(in); err != nil { @@ -923,6 +955,10 @@ var ApplicationService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetAppStatus", Handler: _ApplicationService_GetAppStatus_Handler, }, + { + MethodName: "GetAppStatusV2", + Handler: _ApplicationService_GetAppStatusV2_Handler, + }, { MethodName: "Hibernate", Handler: _ApplicationService_Hibernate_Handler, diff --git a/api/helm-app/service/HelmAppService.go b/api/helm-app/service/HelmAppService.go index 198078b32b..d62036d322 100644 --- a/api/helm-app/service/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -94,6 +94,8 @@ type HelmAppService interface { GetRevisionHistoryMaxValue(appType bean.SourceAppType) int32 GetResourceTreeForExternalResources(ctx context.Context, clusterId int, clusterConfig *gRPC.ClusterConfig, resources []*gRPC.ExternalResourceDetail) (*gRPC.ResourceTreeResponse, error) CheckIfNsExistsForClusterIds(clusterIdToNsMap map[int]string) error + + GetAppStatusV2(ctx context.Context, req *gRPC.AppDetailRequest, clusterId int) (*gRPC.AppStatus, error) } type HelmAppServiceImpl struct { @@ -175,7 +177,7 @@ func (impl *HelmAppServiceImpl) ListHelmApplications(ctx context.Context, cluste http.StatusInternalServerError) return } - + // get helm apps which are created using cd_pipelines newCtx, span := otel.Tracer("pipelineRepository").Start(ctx, "GetAppAndEnvDetailsForDeploymentAppTypePipeline") start = time.Now() diff --git a/api/helm-app/service/HelmAppService_ent.go b/api/helm-app/service/HelmAppService_ent.go new file mode 100644 index 0000000000..9e14356328 --- /dev/null +++ b/api/helm-app/service/HelmAppService_ent.go @@ -0,0 +1,10 @@ +package service + +import ( + "context" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" +) + +func (impl *HelmAppServiceImpl) GetAppStatusV2(ctx context.Context, req *gRPC.AppDetailRequest, clusterId int) (*gRPC.AppStatus, error) { + return nil, nil +} diff --git a/api/k8s/application/k8sApplicationRestHandler.go b/api/k8s/application/k8sApplicationRestHandler.go index f8f2e8f9b8..c445266842 100644 --- a/api/k8s/application/k8sApplicationRestHandler.go +++ b/api/k8s/application/k8sApplicationRestHandler.go @@ -27,7 +27,7 @@ import ( util3 "github.com/devtron-labs/common-lib/utils/k8s" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/connector" "github.com/devtron-labs/devtron/api/helm-app/gRPC" client "github.com/devtron-labs/devtron/api/helm-app/service" @@ -253,7 +253,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response } token := r.Header.Get("token") - var k8sAppDetail bean.AppDetailContainer + var k8sAppDetail AppView.AppDetailContainer var resourceTreeResponse *gRPC.ResourceTreeResponse var clusterId int var namespace string @@ -344,8 +344,8 @@ func (handler *K8sApplicationRestHandlerImpl) GetHostUrlsByBatch(w http.Response resourceTreeResponse = appDetail.ResourceTreeResponse } - k8sAppDetail = bean.AppDetailContainer{ - DeploymentDetailContainer: bean.DeploymentDetailContainer{ + k8sAppDetail = AppView.AppDetailContainer{ + DeploymentDetailContainer: AppView.DeploymentDetailContainer{ ClusterId: clusterId, Namespace: namespace, }, diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index f5d3926067..071143de7f 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -26,7 +26,7 @@ import ( k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8s/health" k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/service/read" "github.com/devtron-labs/devtron/api/restHandler/common" @@ -225,7 +225,7 @@ func (handler AppListingRestHandlerImpl) FetchJobs(w http.ResponseWriter, r *htt if len(validAppIds) == 0 { handler.logger.Infow("user doesn't have access to any app", "userId", userId) - common.WriteJsonResp(w, err, bean.JobContainerResponse{}, http.StatusOK) + common.WriteJsonResp(w, err, AppView.JobContainerResponse{}, http.StatusOK) return } } @@ -258,7 +258,7 @@ func (handler AppListingRestHandlerImpl) FetchJobs(w http.ResponseWriter, r *htt jobs = jobs[offset:] } } - jobContainerResponse := bean.JobContainerResponse{ + jobContainerResponse := AppView.JobContainerResponse{ JobContainers: jobs, JobCount: jobsCount, } @@ -347,7 +347,7 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV2(w http.Respons if len(validAppIds) == 0 { handler.logger.Infow("user doesn't have access to any app", "userId", userId) - common.WriteJsonResp(w, err, bean.AppContainerResponse{}, http.StatusOK) + common.WriteJsonResp(w, err, AppView.AppContainerResponse{}, http.StatusOK) return } } @@ -402,20 +402,20 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV2(w http.Respons common.WriteJsonResp(w, err, "", http.StatusInternalServerError) } - appContainerResponse := bean.AppContainerResponse{ + appContainerResponse := AppView.AppContainerResponse{ AppContainers: apps, AppCount: appsCount, } if fetchAppListingRequest.DeploymentGroupId > 0 { - var ciMaterialDTOs []bean.CiMaterialDTO + var ciMaterialDTOs []AppView.CiMaterialDTO for _, ci := range dg.CiMaterialDTOs { - ciMaterialDTOs = append(ciMaterialDTOs, bean.CiMaterialDTO{ + ciMaterialDTOs = append(ciMaterialDTOs, AppView.CiMaterialDTO{ Name: ci.Name, SourceValue: ci.SourceValue, SourceType: ci.SourceType, }) } - appContainerResponse.DeploymentGroupDTO = bean.DeploymentGroupDTO{ + appContainerResponse.DeploymentGroupDTO = AppView.DeploymentGroupDTO{ Id: dg.Id, Name: dg.Name, AppCount: dg.AppCount, @@ -487,7 +487,7 @@ func (handler AppListingRestHandlerImpl) FetchOverviewAppsByEnvironment(w http.R // enforce rbac in batch rbacResult := handler.enforcer.EnforceInBatch(token, casbin.ResourceApplications, casbin.ActionGet, rbacObjects) // filter out rbac passed apps - resp.Apps = make([]*bean.AppEnvironmentContainer, 0) + resp.Apps = make([]*AppView.AppEnvironmentContainer, 0) for _, appBean := range appContainers { rbacObject := rbacObjectsWithAppId[appBean.AppId] if rbacResult[rbacObject] { @@ -767,7 +767,7 @@ func (handler AppListingRestHandlerImpl) RedirectToLinkouts(w http.ResponseWrite } http.Redirect(w, r, link, http.StatusOK) } -func (handler AppListingRestHandlerImpl) fetchResourceTreeFromInstallAppService(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer bean.AppDetailsContainer, installedApps repository.InstalledApps, deploymentConfig *bean4.DeploymentConfig) (bean.AppDetailsContainer, error) { +func (handler AppListingRestHandlerImpl) fetchResourceTreeFromInstallAppService(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer AppView.AppDetailsContainer, installedApps repository.InstalledApps, deploymentConfig *bean4.DeploymentConfig) (AppView.AppDetailsContainer, error) { rctx := r.Context() cn, _ := w.(http.CloseNotifier) err := handler.installedAppResourceService.FetchResourceTree(rctx, cn, &resourceTreeAndNotesContainer, installedApps, deploymentConfig, "", "") @@ -798,7 +798,7 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite return } } - var appDetail bean.AppDetailContainer + var appDetail AppView.AppDetailContainer var appId, envId int envId, err := strconv.Atoi(envIdParam) if err != nil { @@ -846,7 +846,7 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite //this is external app case where app_name is a unique identifier, and we want to fetch resource based on display_name handler.installedAppService.ChangeAppNameToDisplayNameForInstalledApp(installedApp) } - resourceTreeAndNotesContainer := bean.AppDetailsContainer{} + resourceTreeAndNotesContainer := AppView.AppDetailsContainer{} resourceTreeAndNotesContainer, err = handler.fetchResourceTreeFromInstallAppService(w, r, resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig) if err != nil { common.WriteJsonResp(w, fmt.Errorf("error in fetching resource tree"), nil, http.StatusInternalServerError) @@ -903,8 +903,8 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite common.WriteJsonResp(w, nil, result, http.StatusOK) } -func (handler AppListingRestHandlerImpl) getAppDetails(ctx context.Context, appIdParam, installedAppIdParam string, envId int) (bean.AppDetailContainer, error, int) { - var appDetail bean.AppDetailContainer +func (handler AppListingRestHandlerImpl) getAppDetails(ctx context.Context, appIdParam, installedAppIdParam string, envId int) (AppView.AppDetailContainer, error, int) { + var appDetail AppView.AppDetailContainer if appIdParam != "" { appId, err := strconv.Atoi(appIdParam) if err != nil { @@ -1050,8 +1050,8 @@ func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter resourceTree["serverVersion"] = version.String() } } - k8sAppDetail := bean.AppDetailContainer{ - DeploymentDetailContainer: bean.DeploymentDetailContainer{ + k8sAppDetail := AppView.AppDetailContainer{ + DeploymentDetailContainer: AppView.DeploymentDetailContainer{ ClusterId: cdPipeline.Environment.ClusterId, Namespace: cdPipeline.Environment.Namespace, }, diff --git a/cmd/external-app/wire_gen.go b/cmd/external-app/wire_gen.go index 77c39763a1..15b9eae6d0 100644 --- a/cmd/external-app/wire_gen.go +++ b/cmd/external-app/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run github.com/google/wire/cmd/wire +//go:generate go run -mod=mod github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 0260679f34..cb5584beef 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -23,6 +23,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/bean/gitOps" "github.com/devtron-labs/devtron/internal/middleware" appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" @@ -33,30 +34,29 @@ import ( "strings" "time" - "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/go-pg/pg" "go.uber.org/zap" ) type AppListingRepository interface { - FetchJobs(appIds []int, statuses []string, environmentIds []int, sortOrder string) ([]*bean.JobListingContainer, error) - FetchOverviewCiPipelines(jobId int) ([]*bean.JobListingContainer, error) - FetchJobsLastSucceededOn(ciPipelineIDs []int) ([]*bean.CiPipelineLastSucceededTime, error) - FetchAppDetail(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) + FetchJobs(appIds []int, statuses []string, environmentIds []int, sortOrder string) ([]*AppView.JobListingContainer, error) + FetchOverviewCiPipelines(jobId int) ([]*AppView.JobListingContainer, error) + FetchJobsLastSucceededOn(ciPipelineIDs []int) ([]*AppView.CiPipelineLastSucceededTime, error) + FetchAppDetail(ctx context.Context, appId int, envId int) (AppView.AppDetailContainer, error) - FetchAppTriggerView(appId int) ([]bean.TriggerView, error) - FetchAppStageStatus(appId int, appType int) ([]bean.AppStageStatus, error) + FetchAppTriggerView(appId int) ([]AppView.TriggerView, error) + FetchAppStageStatus(appId int, appType int) ([]AppView.AppStageStatus, error) // Not in used PrometheusApiByEnvId(id int) (*string, error) - FetchOtherEnvironment(appId int) ([]*bean.Environment, error) - FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error) - DeploymentDetailByArtifactId(ciArtifactId int, envId int) (bean.DeploymentDetailContainer, error) + FetchOtherEnvironment(appId int) ([]*AppView.Environment, error) + FetchMinDetailOtherEnvironment(appId int) ([]*AppView.Environment, error) + DeploymentDetailByArtifactId(ciArtifactId int, envId int) (AppView.DeploymentDetailContainer, error) FindAppCount(isProd bool) (int, error) - FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*bean.AppEnvironmentContainer, int, error) - FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*bean.AppEnvironmentContainer, error) + FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*AppView.AppEnvironmentContainer, int, error) + FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*AppView.AppEnvironmentContainer, error) FetchLastDeployedImage(appId, envId int) (*LastDeployed, error) } @@ -111,8 +111,8 @@ func NewAppListingRepositoryImpl( } } -func (impl AppListingRepositoryImpl) FetchJobs(appIds []int, statuses []string, environmentIds []int, sortOrder string) ([]*bean.JobListingContainer, error) { - var jobContainers []*bean.JobListingContainer +func (impl AppListingRepositoryImpl) FetchJobs(appIds []int, statuses []string, environmentIds []int, sortOrder string) ([]*AppView.JobListingContainer, error) { + var jobContainers []*AppView.JobListingContainer if len(appIds) == 0 { return jobContainers, nil } @@ -132,8 +132,8 @@ func (impl AppListingRepositoryImpl) FetchJobs(appIds []int, statuses []string, return jobContainers, nil } -func (impl AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*bean.JobListingContainer, error) { - var jobContainers []*bean.JobListingContainer +func (impl AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*AppView.JobListingContainer, error) { + var jobContainers []*AppView.JobListingContainer jobsQuery := impl.appListingRepositoryQueryBuilder.OverviewCiPipelineQuery() impl.Logger.Debugw("basic app detail query: ", jobsQuery) _, appsErr := impl.dbConnection.Query(&jobContainers, jobsQuery, jobId) @@ -149,7 +149,7 @@ func (impl AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*bea return jobContainers, nil } -func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*bean.AppEnvironmentContainer, error) { +func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*AppView.AppEnvironmentContainer, error) { query := " SELECT a.id as app_id,a.app_name,aps.status as app_status, ld.last_deployed_time " + " FROM app a " + " INNER JOIN pipeline p ON p.app_id = a.id and p.deleted = false and p.environment_id = ? " + @@ -165,7 +165,7 @@ func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit if offset > 0 { query += fmt.Sprintf("OFFSET %v", offset) } - var envContainers []*bean.AppEnvironmentContainer + var envContainers []*AppView.AppEnvironmentContainer _, err := impl.dbConnection.Query(&envContainers, query, envId, envId) return envContainers, err } @@ -191,8 +191,8 @@ func (impl AppListingRepositoryImpl) FetchLastDeployedImage(appId, envId int) (* return nil, err } -func (impl AppListingRepositoryImpl) FetchJobsLastSucceededOn(CiPipelineIDs []int) ([]*bean.CiPipelineLastSucceededTime, error) { - var lastSucceededTimeArray []*bean.CiPipelineLastSucceededTime +func (impl AppListingRepositoryImpl) FetchJobsLastSucceededOn(CiPipelineIDs []int) ([]*AppView.CiPipelineLastSucceededTime, error) { + var lastSucceededTimeArray []*AppView.CiPipelineLastSucceededTime if len(CiPipelineIDs) == 0 { return lastSucceededTimeArray, nil } @@ -218,13 +218,13 @@ func getRequiredAppIdsInSequence(appIds []int) []int { return resIDs } -func (impl AppListingRepositoryImpl) FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*bean.AppEnvironmentContainer, int, error) { +func (impl AppListingRepositoryImpl) FetchAppsByEnvironmentV2(appListingFilter helper.AppListingFilter) ([]*AppView.AppEnvironmentContainer, int, error) { impl.Logger.Debugw("reached at FetchAppsByEnvironment ", "appListingFilter", appListingFilter) - var appEnvArr []*bean.AppEnvironmentContainer + var appEnvArr []*AppView.AppEnvironmentContainer appsSize := 0 lastDeployedTimeMap := make(map[int]string) - var appEnvContainer []*bean.AppEnvironmentContainer - var lastDeployedTimeDTO = make([]*bean.AppEnvironmentContainer, 0) + var appEnvContainer []*AppView.AppEnvironmentContainer + var lastDeployedTimeDTO = make([]*AppView.AppEnvironmentContainer, 0) if string(appListingFilter.SortBy) == helper.LastDeployedSortBy { @@ -257,7 +257,7 @@ func (impl AppListingRepositoryImpl) FetchAppsByEnvironmentV2(appListingFilter h } else { // to get all the appIds in appEnvs allowed for user and filtered by the appListing filter and sorted by name - appIdCountDtos := make([]*bean.AppEnvironmentContainer, 0) + appIdCountDtos := make([]*AppView.AppEnvironmentContainer, 0) appIdCountQuery, appIdCountQueryParams := impl.appListingRepositoryQueryBuilder.GetAppIdsQueryWithPaginationForAppNameSearch(appListingFilter) impl.Logger.Debug("GetAppIdsQueryWithPaginationForAppNameSearch query ", appIdCountQuery) start := time.Now() @@ -351,10 +351,10 @@ func (impl AppListingRepositoryImpl) getEnvironmentNameFromPipelineId(pipelineID } // DeploymentDetailsByAppIdAndEnvId It will return the deployment detail of any cd pipeline which is latest triggered for Environment of any App -func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx context.Context, appId int, envId int) (bean.DeploymentDetailContainer, error) { +func (impl AppListingRepositoryImpl) deploymentDetailsByAppIdAndEnvId(ctx context.Context, appId int, envId int) (AppView.DeploymentDetailContainer, error) { _, span := otel.Tracer("orchestrator").Start(ctx, "DeploymentDetailsByAppIdAndEnvId") defer span.End() - var deploymentDetail bean.DeploymentDetailContainer + var deploymentDetail AppView.DeploymentDetailContainer query := "SELECT" + " a.app_name," + " env.environment_name," + @@ -459,9 +459,9 @@ func parseMaterialInfo(materialInfo string, source string) (json.RawMessage, err return mInfo, err } -func (impl AppListingRepositoryImpl) FetchAppDetail(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) { +func (impl AppListingRepositoryImpl) FetchAppDetail(ctx context.Context, appId int, envId int) (AppView.AppDetailContainer, error) { impl.Logger.Debugf("reached at AppListingRepository:") - var appDetailContainer bean.AppDetailContainer + var appDetailContainer AppView.AppDetailContainer newCtx, span := otel.Tracer("orchestrator").Start(ctx, "DeploymentDetailsByAppIdAndEnvId") defer span.End() // Fetch deployment detail of cd pipeline latest triggered within env of any App. @@ -496,10 +496,10 @@ func (impl AppListingRepositoryImpl) PrometheusApiByEnvId(id int) (*string, erro return &prometheusEndpoint, nil } -func (impl AppListingRepositoryImpl) FetchAppTriggerView(appId int) ([]bean.TriggerView, error) { +func (impl AppListingRepositoryImpl) FetchAppTriggerView(appId int) ([]AppView.TriggerView, error) { impl.Logger.Debug("reached at FetchAppTriggerView:") - var triggerView []bean.TriggerView - var triggerViewResponse []bean.TriggerView + var triggerView []AppView.TriggerView + var triggerViewResponse []AppView.TriggerView query := "" + " SELECT cp.id as ci_pipeline_id,cp.name as ci_pipeline_name,p.id as cd_pipeline_id," + " p.pipeline_name as cd_pipeline_name, a.app_name, env.environment_name" + @@ -518,7 +518,7 @@ func (impl AppListingRepositoryImpl) FetchAppTriggerView(appId int) ([]bean.Trig for _, item := range triggerView { if item.CdPipelineId > 0 { - var tView bean.TriggerView + var tView AppView.TriggerView statusQuery := "SELECT p.id as cd_pipeline_id, pco.created_on as last_deployed_time," + " u.email_id as last_deployed_by, pco.pipeline_release_counter as release_version," + " cia.material_info as material_info_json_string, cia.data_source, evt.reason as status" + @@ -563,9 +563,9 @@ func (impl AppListingRepositoryImpl) FetchAppTriggerView(appId int) ([]bean.Trig return triggerViewResponse, nil } -func (impl AppListingRepositoryImpl) FetchAppStageStatus(appId int, appType int) ([]bean.AppStageStatus, error) { +func (impl AppListingRepositoryImpl) FetchAppStageStatus(appId int, appType int) ([]AppView.AppStageStatus, error) { impl.Logger.Debug("reached at AppListingRepository:") - var appStageStatus []bean.AppStageStatus + var appStageStatus []AppView.AppStageStatus var stages struct { AppId int `json:"app_id,omitempty"` @@ -638,12 +638,12 @@ func (impl AppListingRepositoryImpl) FetchAppStageStatus(appId int, appType int) return appStageStatus, nil } -func (impl AppListingRepositoryImpl) makeAppStageChartEnvConfigStatus(stage int, stageName string, status bool) bean.AppStageStatus { - return bean.AppStageStatus{Stage: stage, StageName: stageName, Status: status, Required: true} +func (impl AppListingRepositoryImpl) makeAppStageChartEnvConfigStatus(stage int, stageName string, status bool) AppView.AppStageStatus { + return AppView.AppStageStatus{Stage: stage, StageName: stageName, Status: status, Required: true} } -func (impl AppListingRepositoryImpl) makeAppStageStatus(stage int, stageName string, id int, isRequired bool) bean.AppStageStatus { - return bean.AppStageStatus{ +func (impl AppListingRepositoryImpl) makeAppStageStatus(stage int, stageName string, id int, isRequired bool) AppView.AppStageStatus { + return AppView.AppStageStatus{ Stage: stage, StageName: stageName, Status: func() bool { @@ -657,9 +657,9 @@ func (impl AppListingRepositoryImpl) makeAppStageStatus(stage int, stageName str } } -func (impl AppListingRepositoryImpl) FetchOtherEnvironment(appId int) ([]*bean.Environment, error) { +func (impl AppListingRepositoryImpl) FetchOtherEnvironment(appId int) ([]*AppView.Environment, error) { // other environment tab - var otherEnvironments []*bean.Environment + var otherEnvironments []*AppView.Environment //TODO: remove infra metrics from query as it is not being used from here query := `select pcwr.pipeline_id, pcwr.last_deployed, pcwr.latest_cd_workflow_runner_id, pcwr.environment_id, pcwr.deployment_app_delete_request, e.cluster_id, e.environment_name, e.default as prod, e.description, ca.image as last_deployed_image, @@ -686,9 +686,9 @@ func (impl AppListingRepositoryImpl) FetchOtherEnvironment(appId int) ([]*bean.E return otherEnvironments, nil } -func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error) { +func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) ([]*AppView.Environment, error) { impl.Logger.Debug("reached at FetchMinDetailOtherEnvironment:") - var otherEnvironments []*bean.Environment + var otherEnvironments []*AppView.Environment //TODO: remove infra metrics from query as it is not being used from here query := `SELECT p.environment_id,env.environment_name,env.description,env.is_virtual_environment, env.cluster_id, env.default as prod, p.deployment_app_delete_request, env_app_m.app_metrics,env_app_m.infra_metrics from @@ -704,9 +704,9 @@ func (impl AppListingRepositoryImpl) FetchMinDetailOtherEnvironment(appId int) ( return otherEnvironments, nil } -func (impl AppListingRepositoryImpl) DeploymentDetailByArtifactId(ciArtifactId int, envId int) (bean.DeploymentDetailContainer, error) { +func (impl AppListingRepositoryImpl) DeploymentDetailByArtifactId(ciArtifactId int, envId int) (AppView.DeploymentDetailContainer, error) { impl.Logger.Debug("reached at AppListingRepository:") - var deploymentDetail bean.DeploymentDetailContainer + var deploymentDetail AppView.DeploymentDetailContainer query := "SELECT env.id AS environment_id, env.environment_name, env.default, pco.created_on as last_deployed_time, pco.updated_by as last_deployed_by_id, a.app_name" + " FROM pipeline_config_override pco" + " INNER JOIN pipeline p on p.id = pco.pipeline_id" + @@ -740,7 +740,7 @@ func (impl AppListingRepositoryImpl) FindAppCount(isProd bool) (int, error) { return count, nil } -func (impl AppListingRepositoryImpl) extractEnvironmentNameFromId(jobContainers []*bean.JobListingContainer) ([]*bean.JobListingContainer, error) { +func (impl AppListingRepositoryImpl) extractEnvironmentNameFromId(jobContainers []*AppView.JobListingContainer) ([]*AppView.JobListingContainer, error) { var envIds []*int for _, job := range jobContainers { if job.EnvironmentId != 0 { diff --git a/internal/sql/repository/LinkoutsRepository.go b/internal/sql/repository/LinkoutsRepository.go index d02bfe145d..4629d8f6a8 100644 --- a/internal/sql/repository/LinkoutsRepository.go +++ b/internal/sql/repository/LinkoutsRepository.go @@ -17,7 +17,7 @@ package repository import ( - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/pkg/sql" "github.com/go-pg/pg" "go.uber.org/zap" @@ -29,7 +29,7 @@ type LinkoutsRepository interface { GetAll() ([]LinkoutsModel, error) Update(model *LinkoutsModel) (*LinkoutsModel, error) FetchLinkoutsByAppIdAndEnvId(appId int, envId int) ([]LinkoutsModel, error) - FetchLinkoutById(Id int) (bean.LinkOuts, error) + FetchLinkoutById(Id int) (AppView.LinkOuts, error) } type LinkoutsRepositoryImpl struct { @@ -89,8 +89,8 @@ func (impl LinkoutsRepositoryImpl) FetchLinkoutsByAppIdAndEnvId(appId int, envId return models, err } -func (impl LinkoutsRepositoryImpl) FetchLinkoutById(Id int) (bean.LinkOuts, error) { - var linkout bean.LinkOuts +func (impl LinkoutsRepositoryImpl) FetchLinkoutById(Id int) (AppView.LinkOuts, error) { + var linkout AppView.LinkOuts query := "" + " SELECT l.id, l.name , l.link, a.app_name, e.environment_name as env_name" + " from app_env_linkouts l" + diff --git a/internal/sql/repository/mocks/AppListingRepository.go b/internal/sql/repository/mocks/AppListingRepository.go index 719eefbe6d..393aecca88 100644 --- a/internal/sql/repository/mocks/AppListingRepository.go +++ b/internal/sql/repository/mocks/AppListingRepository.go @@ -4,8 +4,7 @@ package mocks import ( context "context" - - bean "github.com/devtron-labs/devtron/api/bean" + bean "github.com/devtron-labs/devtron/api/bean/AppView" helper "github.com/devtron-labs/devtron/internal/sql/repository/helper" diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index b64d4b0b02..c6cbe47178 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "github.com/devtron-labs/common-lib/utils/k8s/health" + "github.com/devtron-labs/devtron/api/bean/AppView" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" @@ -54,25 +55,25 @@ import ( ) type AppListingService interface { - FetchJobs(fetchJobListingRequest FetchAppListingRequest) ([]*bean.JobContainer, error) - FetchOverviewCiPipelines(jobId int) ([]*bean.JobListingContainer, error) - BuildAppListingResponseV2(fetchAppListingRequest FetchAppListingRequest, envContainers []*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error) + FetchJobs(fetchJobListingRequest FetchAppListingRequest) ([]*AppView.JobContainer, error) + FetchOverviewCiPipelines(jobId int) ([]*AppView.JobListingContainer, error) + BuildAppListingResponseV2(fetchAppListingRequest FetchAppListingRequest, envContainers []*AppView.AppEnvironmentContainer) ([]*AppView.AppContainer, error) FetchAllDevtronManagedApps() ([]AppNameTypeIdContainer, error) - FetchAppDetails(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) + FetchAppDetails(ctx context.Context, appId int, envId int) (AppView.AppDetailContainer, error) //------------------ - FetchAppTriggerView(appId int) ([]bean.TriggerView, error) - FetchAppStageStatus(appId int, appType int) ([]bean.AppStageStatus, error) + FetchAppTriggerView(appId int) ([]AppView.TriggerView, error) + FetchAppStageStatus(appId int, appType int) ([]AppView.AppStageStatus, error) - FetchOtherEnvironment(ctx context.Context, appId int) ([]*bean.Environment, error) - FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error) + FetchOtherEnvironment(ctx context.Context, appId int) ([]*AppView.Environment, error) + FetchMinDetailOtherEnvironment(appId int) ([]*AppView.Environment, error) RedirectToLinkouts(Id int, appId int, envId int, podName string, containerName string) (string, error) ISLastReleaseStopType(appId, envId int) (bool, error) ISLastReleaseStopTypeV2(pipelineIds []int) (map[int]bool, error) GetReleaseCount(appId, envId int) (int, error) - FetchAppsByEnvironmentV2(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*bean.AppEnvironmentContainer, int, error) + FetchAppsByEnvironmentV2(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*AppView.AppEnvironmentContainer, int, error) FetchOverviewAppsByEnvironment(envId, limit, offset int) (*OverviewAppsByEnvironmentBean, error) } @@ -185,17 +186,17 @@ const AcdInvalidAppErr = "invalid acd app name and env" const NotDeployed = "Not Deployed" type OverviewAppsByEnvironmentBean struct { - EnvironmentId int `json:"environmentId"` - EnvironmentName string `json:"environmentName"` - Namespace string `json:"namespace"` - ClusterName string `json:"clusterName"` - ClusterId int `json:"clusterId"` - Type string `json:"environmentType"` - Description string `json:"description"` - AppCount int `json:"appCount"` - Apps []*bean.AppEnvironmentContainer `json:"apps"` - CreatedOn string `json:"createdOn"` - CreatedBy string `json:"createdBy"` + EnvironmentId int `json:"environmentId"` + EnvironmentName string `json:"environmentName"` + Namespace string `json:"namespace"` + ClusterName string `json:"clusterName"` + ClusterId int `json:"clusterId"` + Type string `json:"environmentType"` + Description string `json:"description"` + AppCount int `json:"appCount"` + Apps []*AppView.AppEnvironmentContainer `json:"apps"` + CreatedOn string `json:"createdOn"` + CreatedBy string `json:"createdBy"` } const ( @@ -240,6 +241,12 @@ func (impl AppListingServiceImpl) FetchOverviewAppsByEnvironment(envId, limit, o return resp, err } + err = impl.updateAppStatusForHelmTypePipelines(envContainers) + if err != nil { + impl.Logger.Errorw("err, updateAppStatusForHelmTypePipelines", "err", err) + return resp, err + } + artifactIds := make([]int, 0) for _, envContainer := range envContainers { lastDeployed, err := impl.appListingRepository.FetchLastDeployedImage(envContainer.AppId, envId) @@ -319,7 +326,7 @@ func (impl AppListingServiceImpl) FetchAllDevtronManagedApps() ([]AppNameTypeIdC } return apps, nil } -func (impl AppListingServiceImpl) FetchJobs(fetchJobListingRequest FetchAppListingRequest) ([]*bean.JobContainer, error) { +func (impl AppListingServiceImpl) FetchJobs(fetchJobListingRequest FetchAppListingRequest) ([]*AppView.JobContainer, error) { jobListingFilter := helper.AppListingFilter{ Teams: fetchJobListingRequest.Teams, @@ -335,12 +342,12 @@ func (impl AppListingServiceImpl) FetchJobs(fetchJobListingRequest FetchAppListi appIds, err := impl.appRepository.FetchAppIdsWithFilter(jobListingFilter) if err != nil { impl.Logger.Errorw("error in fetching app ids list", "error", err, jobListingFilter) - return []*bean.JobContainer{}, err + return []*AppView.JobContainer{}, err } jobListingContainers, err := impl.appListingRepository.FetchJobs(appIds, jobListingFilter.AppStatuses, jobListingFilter.Environments, string(jobListingFilter.SortOrder)) if err != nil { impl.Logger.Errorw("error in fetching job list", "error", err, jobListingFilter) - return []*bean.JobContainer{}, err + return []*AppView.JobContainer{}, err } CiPipelineIDs := GetCIPipelineIDs(jobListingContainers) JobsLastSucceededOnTime, err := impl.appListingRepository.FetchJobsLastSucceededOn(CiPipelineIDs) @@ -348,19 +355,19 @@ func (impl AppListingServiceImpl) FetchJobs(fetchJobListingRequest FetchAppListi return jobContainers, nil } -func (impl AppListingServiceImpl) FetchOverviewCiPipelines(jobId int) ([]*bean.JobListingContainer, error) { +func (impl AppListingServiceImpl) FetchOverviewCiPipelines(jobId int) ([]*AppView.JobListingContainer, error) { jobCiContainers, err := impl.appListingRepository.FetchOverviewCiPipelines(jobId) if err != nil { impl.Logger.Errorw("error in fetching job container", "error", err, jobId) - return []*bean.JobListingContainer{}, err + return []*AppView.JobListingContainer{}, err } return jobCiContainers, nil } -func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*bean.AppEnvironmentContainer, int, error) { +func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingRequest FetchAppListingRequest, w http.ResponseWriter, r *http.Request, token string) ([]*AppView.AppEnvironmentContainer, int, error) { impl.Logger.Debug("reached at FetchAppsByEnvironment:") if len(fetchAppListingRequest.Namespaces) != 0 && len(fetchAppListingRequest.Environments) == 0 { - return []*bean.AppEnvironmentContainer{}, 0, nil + return []*AppView.AppEnvironmentContainer{}, 0, nil } appListingFilter := helper.AppListingFilter{ Environments: fetchAppListingRequest.Environments, @@ -380,17 +387,17 @@ func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingReques span.End() if err != nil { impl.Logger.Errorw("error in fetching app list", "error", err, "filter", appListingFilter) - return []*bean.AppEnvironmentContainer{}, appSize, err + return []*AppView.AppEnvironmentContainer{}, appSize, err } - envContainersMap := make(map[int][]*bean.AppEnvironmentContainer) + envContainersMap := make(map[int][]*AppView.AppEnvironmentContainer) envIds := make([]int, 0) envsSet := make(map[int]bool) for _, container := range envContainers { if container.EnvironmentId != 0 { if _, ok := envContainersMap[container.EnvironmentId]; !ok { - envContainersMap[container.EnvironmentId] = make([]*bean.AppEnvironmentContainer, 0) + envContainersMap[container.EnvironmentId] = make([]*AppView.AppEnvironmentContainer, 0) } envContainersMap[container.EnvironmentId] = append(envContainersMap[container.EnvironmentId], container) if _, ok := envsSet[container.EnvironmentId]; !ok { @@ -402,7 +409,7 @@ func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingReques envClusterInfos, err := impl.environmentRepository.FindEnvClusterInfosByIds(envIds) if err != nil { impl.Logger.Errorw("error in envClusterInfos list", "error", err, "envIds", envIds) - return []*bean.AppEnvironmentContainer{}, appSize, err + return []*AppView.AppEnvironmentContainer{}, appSize, err } for _, info := range envClusterInfos { for _, container := range envContainersMap[info.Id] { @@ -411,6 +418,11 @@ func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingReques container.EnvironmentName = info.Name } } + err = impl.updateAppStatusForHelmTypePipelines(envContainers) + if err != nil { + impl.Logger.Errorw("error, UpdateAppStatusForHelmTypePipelines", "err", err) + return []*AppView.AppEnvironmentContainer{}, appSize, err + } return envContainers, appSize, nil } @@ -477,20 +489,20 @@ func (impl AppListingServiceImpl) GetReleaseCount(appId, envId int) (int, error) } } -func (impl AppListingServiceImpl) BuildAppListingResponseV2(fetchAppListingRequest FetchAppListingRequest, envContainers []*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error) { +func (impl AppListingServiceImpl) BuildAppListingResponseV2(fetchAppListingRequest FetchAppListingRequest, envContainers []*AppView.AppEnvironmentContainer) ([]*AppView.AppContainer, error) { start := time.Now() appEnvMapping, err := impl.fetchACDAppStatusV2(fetchAppListingRequest, envContainers) middleware.AppListingDuration.WithLabelValues("fetchACDAppStatus", "devtron").Observe(time.Since(start).Seconds()) if err != nil { impl.Logger.Errorw("error in fetching app statuses", "error", err) - return []*bean.AppContainer{}, err + return []*AppView.AppContainer{}, err } start = time.Now() appContainerResponses, err := impl.appListingViewBuilder.BuildView(fetchAppListingRequest, appEnvMapping) middleware.AppListingDuration.WithLabelValues("buildView", "devtron").Observe(time.Since(start).Seconds()) return appContainerResponses, err } -func GetCIPipelineIDs(jobContainers []*bean.JobListingContainer) []int { +func GetCIPipelineIDs(jobContainers []*AppView.JobListingContainer) []int { var ciPipelineIDs []int for _, jobContainer := range jobContainers { @@ -498,8 +510,8 @@ func GetCIPipelineIDs(jobContainers []*bean.JobListingContainer) []int { } return ciPipelineIDs } -func BuildJobListingResponse(jobContainers []*bean.JobListingContainer, JobsLastSucceededOnTime []*bean.CiPipelineLastSucceededTime) []*bean.JobContainer { - jobContainersMapping := make(map[int]bean.JobContainer) +func BuildJobListingResponse(jobContainers []*AppView.JobListingContainer, JobsLastSucceededOnTime []*AppView.CiPipelineLastSucceededTime) []*AppView.JobContainer { + jobContainersMapping := make(map[int]AppView.JobContainer) var appIds []int lastSucceededTimeMapping := make(map[int]time.Time) @@ -512,7 +524,7 @@ func BuildJobListingResponse(jobContainers []*bean.JobListingContainer, JobsLast val, ok := jobContainersMapping[jobContainer.JobId] if !ok { appIds = append(appIds, jobContainer.JobId) - val = bean.JobContainer{} + val = AppView.JobContainer{} val.JobId = jobContainer.JobId val.JobName = jobContainer.JobName val.JobActualName = jobContainer.JobActualName @@ -520,11 +532,11 @@ func BuildJobListingResponse(jobContainers []*bean.JobListingContainer, JobsLast } if len(val.JobCiPipelines) == 0 { - val.JobCiPipelines = make([]bean.JobCIPipeline, 0) + val.JobCiPipelines = make([]AppView.JobCIPipeline, 0) } if jobContainer.CiPipelineID != 0 { - ciPipelineObj := bean.JobCIPipeline{ + ciPipelineObj := AppView.JobCIPipeline{ CiPipelineId: jobContainer.CiPipelineID, CiPipelineName: jobContainer.CiPipelineName, Status: jobContainer.Status, @@ -544,7 +556,7 @@ func BuildJobListingResponse(jobContainers []*bean.JobListingContainer, JobsLast } - result := make([]*bean.JobContainer, 0) + result := make([]*AppView.JobContainer, 0) for _, appId := range appIds { val := jobContainersMapping[appId] result = append(result, &val) @@ -553,8 +565,8 @@ func BuildJobListingResponse(jobContainers []*bean.JobListingContainer, JobsLast return result } -func (impl AppListingServiceImpl) fetchACDAppStatus(fetchAppListingRequest FetchAppListingRequest, existingAppEnvContainers []*bean.AppEnvironmentContainer) (map[string][]*bean.AppEnvironmentContainer, error) { - appEnvMapping := make(map[string][]*bean.AppEnvironmentContainer) +func (impl AppListingServiceImpl) fetchACDAppStatus(fetchAppListingRequest FetchAppListingRequest, existingAppEnvContainers []*AppView.AppEnvironmentContainer) (map[string][]*AppView.AppEnvironmentContainer, error) { + appEnvMapping := make(map[string][]*AppView.AppEnvironmentContainer) var appNames []string var appIds []int var pipelineIds []int @@ -640,7 +652,7 @@ func (impl AppListingServiceImpl) fetchACDAppStatus(fetchAppListingRequest Fetch for _, env := range existingAppEnvContainers { appKey := strconv.Itoa(env.AppId) + "_" + env.AppName if _, ok := appEnvMapping[appKey]; !ok { - var appEnvContainers []*bean.AppEnvironmentContainer + var appEnvContainers []*AppView.AppEnvironmentContainer appEnvMapping[appKey] = appEnvContainers } @@ -737,8 +749,8 @@ func (impl AppListingServiceImpl) fetchACDAppStatus(fetchAppListingRequest Fetch return appEnvMapping, nil } -func (impl AppListingServiceImpl) fetchACDAppStatusV2(fetchAppListingRequest FetchAppListingRequest, existingAppEnvContainers []*bean.AppEnvironmentContainer) (map[string][]*bean.AppEnvironmentContainer, error) { - appEnvMapping := make(map[string][]*bean.AppEnvironmentContainer) +func (impl AppListingServiceImpl) fetchACDAppStatusV2(fetchAppListingRequest FetchAppListingRequest, existingAppEnvContainers []*AppView.AppEnvironmentContainer) (map[string][]*AppView.AppEnvironmentContainer, error) { + appEnvMapping := make(map[string][]*AppView.AppEnvironmentContainer) for _, env := range existingAppEnvContainers { appKey := strconv.Itoa(env.AppId) + "_" + env.AppName appEnvMapping[appKey] = append(appEnvMapping[appKey], env) @@ -746,11 +758,11 @@ func (impl AppListingServiceImpl) fetchACDAppStatusV2(fetchAppListingRequest Fet return appEnvMapping, nil } -func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int, envId int) (bean.AppDetailContainer, error) { +func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int, envId int) (AppView.AppDetailContainer, error) { appDetailContainer, err := impl.appListingRepository.FetchAppDetail(ctx, appId, envId) if err != nil { impl.Logger.Errorw("error in fetching app detail", "error", err) - return bean.AppDetailContainer{}, err + return AppView.AppDetailContainer{}, err } appDetailContainer.AppId = appId @@ -759,7 +771,7 @@ func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int environment, err := impl.environmentRepository.FindById(envId) if err != nil { impl.Logger.Errorw("error in fetching env details, FetchAppDetails service", "error", err) - return bean.AppDetailContainer{}, err + return AppView.AppDetailContainer{}, err } appDetailContainer, err = impl.setIpAccessProvidedData(ctx, appDetailContainer, appDetailContainer.ClusterId, environment.IsVirtualEnvironment) if err != nil { @@ -769,7 +781,7 @@ func (impl AppListingServiceImpl) FetchAppDetails(ctx context.Context, appId int return appDetailContainer, nil } -func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, appDetailContainer bean.AppDetailContainer, clusterId int, isVirtualEnv bool) (bean.AppDetailContainer, error) { +func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, appDetailContainer AppView.AppDetailContainer, clusterId int, isVirtualEnv bool) (AppView.AppDetailContainer, error) { ciPipelineId := appDetailContainer.CiPipelineId if ciPipelineId > 0 { _, span := otel.Tracer("orchestrator").Start(ctx, "ciPipelineRepository.FindWithMinDataByCiPipelineId") @@ -777,7 +789,7 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a span.End() if err != nil && err != pg.ErrNoRows { impl.Logger.Errorw("error in fetching ciPipeline", "ciPipelineId", ciPipelineId, "error", err) - return bean.AppDetailContainer{}, err + return AppView.AppDetailContainer{}, err } if ciPipeline != nil && ciPipeline.CiTemplate != nil && len(*ciPipeline.CiTemplate.DockerRegistryId) > 0 { @@ -790,7 +802,7 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a dockerRegistryId, err := impl.ciPipelineConfigReadService.GetDockerRegistryIdForCiPipeline(ciPipelineId, artifact) if err != nil { impl.Logger.Errorw("error in fetching docker registry id", "ciPipelineId", ciPipelineId, "error", err) - return bean.AppDetailContainer{}, err + return AppView.AppDetailContainer{}, err } if dockerRegistryId == nil { @@ -806,7 +818,7 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a span.End() if err != nil { impl.Logger.Errorw("error in checking if docker registry ips access provided", "dockerRegistryId", dockerRegistryId, "clusterId", clusterId, "error", err) - return bean.AppDetailContainer{}, err + return AppView.AppDetailContainer{}, err } appDetailContainer.IpsAccessProvided = ipsAccessProvided } @@ -814,11 +826,11 @@ func (impl AppListingServiceImpl) setIpAccessProvidedData(ctx context.Context, a return appDetailContainer, nil } -func (impl AppListingServiceImpl) FetchAppTriggerView(appId int) ([]bean.TriggerView, error) { +func (impl AppListingServiceImpl) FetchAppTriggerView(appId int) ([]AppView.TriggerView, error) { return impl.appListingRepository.FetchAppTriggerView(appId) } -func (impl AppListingServiceImpl) FetchAppStageStatus(appId int, appType int) ([]bean.AppStageStatus, error) { +func (impl AppListingServiceImpl) FetchAppStageStatus(appId int, appType int) ([]AppView.AppStageStatus, error) { appStageStatuses, err := impl.appListingRepository.FetchAppStageStatus(appId, appType) return appStageStatuses, err } @@ -866,7 +878,7 @@ func (impl AppListingServiceImpl) generateArtifactIDCommitMap(artifactIds []int) return ciArtifactAndGitCommitsMap, nil } -func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, appId int) ([]*bean.Environment, error) { +func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, appId int) ([]*AppView.Environment, error) { newCtx, span := otel.Tracer("appListingRepository").Start(ctx, "FetchOtherEnvironment") envs, err := impl.appListingRepository.FetchOtherEnvironment(appId) span.End() @@ -929,7 +941,7 @@ func (impl AppListingServiceImpl) FetchOtherEnvironment(ctx context.Context, app return envs, nil } -func (impl AppListingServiceImpl) FetchMinDetailOtherEnvironment(appId int) ([]*bean.Environment, error) { +func (impl AppListingServiceImpl) FetchMinDetailOtherEnvironment(appId int) ([]*AppView.Environment, error) { envs, err := impl.appListingRepository.FetchMinDetailOtherEnvironment(appId) if err != nil && !util.IsErrNoRows(err) { impl.Logger.Errorw("err", err) diff --git a/pkg/app/AppListingService_ent.go b/pkg/app/AppListingService_ent.go new file mode 100644 index 0000000000..c3d1caf4ec --- /dev/null +++ b/pkg/app/AppListingService_ent.go @@ -0,0 +1,9 @@ +package app + +import ( + "github.com/devtron-labs/devtron/api/bean/AppView" +) + +func (impl AppListingServiceImpl) updateAppStatusForHelmTypePipelines(envContainers []*AppView.AppEnvironmentContainer) error { + return nil +} diff --git a/pkg/app/AppListingViewBuilder.go b/pkg/app/AppListingViewBuilder.go index 0209e475ba..e8f32eafcc 100644 --- a/pkg/app/AppListingViewBuilder.go +++ b/pkg/app/AppListingViewBuilder.go @@ -18,7 +18,7 @@ package app import ( "errors" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "go.uber.org/zap" "sort" @@ -27,7 +27,7 @@ import ( ) type AppListingViewBuilder interface { - BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error) + BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*AppView.AppEnvironmentContainer) ([]*AppView.AppContainer, error) } type AppListingViewBuilderImpl struct { @@ -40,9 +40,9 @@ func NewAppListingViewBuilderImpl(Logger *zap.SugaredLogger) *AppListingViewBuil } } -func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*bean.AppEnvironmentContainer) ([]*bean.AppContainer, error) { +func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchAppListingRequest, appEnvMap map[string][]*AppView.AppEnvironmentContainer) ([]*AppView.AppContainer, error) { // filter status - filteredAppEnvMap := map[string][]*bean.AppEnvironmentContainer{} + filteredAppEnvMap := map[string][]*AppView.AppEnvironmentContainer{} for k, v := range appEnvMap { for _, e := range v { if e.Deleted { @@ -51,7 +51,7 @@ func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchApp } if !impl.filterStatus(fetchAppListingRequest, e.Status) { if _, ok := filteredAppEnvMap[k]; !ok { - var envs []*bean.AppEnvironmentContainer + var envs []*AppView.AppEnvironmentContainer filteredAppEnvMap[k] = envs } filteredAppEnvMap[k] = append(filteredAppEnvMap[k], e) @@ -59,19 +59,19 @@ func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchApp } } - var appContainersResponses []*bean.AppContainer + var appContainersResponses []*AppView.AppContainer for k, v := range filteredAppEnvMap { appIdAndName := strings.Split(k, "_") if len(appIdAndName) != 2 { - return []*bean.AppContainer{}, errors.New("invalid format for app id and name. It should be in format _") + return []*AppView.AppContainer{}, errors.New("invalid format for app id and name. It should be in format _") } appId, err := strconv.Atoi(appIdAndName[0]) if err != nil { impl.Logger.Error("err", err) - return []*bean.AppContainer{}, nil + return []*AppView.AppContainer{}, nil } appName := appIdAndName[1] - defaultEnv := bean.AppEnvironmentContainer{} + defaultEnv := AppView.AppEnvironmentContainer{} projectId := 0 for _, env := range v { projectId = env.TeamId @@ -85,7 +85,7 @@ func (impl *AppListingViewBuilderImpl) BuildView(fetchAppListingRequest FetchApp return v[i].LastDeployedTime >= v[j].LastDeployedTime }) - appContainerResponse := &bean.AppContainer{ + appContainerResponse := &AppView.AppContainer{ AppId: appId, AppName: appName, AppEnvironmentContainer: v, diff --git a/pkg/app/mocks/AppListingService.go b/pkg/app/mocks/AppListingService.go index b1d31db242..b321294fa1 100644 --- a/pkg/app/mocks/AppListingService.go +++ b/pkg/app/mocks/AppListingService.go @@ -3,7 +3,7 @@ package mocks import ( - bean "github.com/devtron-labs/devtron/api/bean" + bean "github.com/devtron-labs/devtron/api/bean/AppView" app "github.com/devtron-labs/devtron/pkg/app" context "context" diff --git a/pkg/appClone/AppCloneService.go b/pkg/appClone/AppCloneService.go index 322be8c9f0..4daee21c85 100644 --- a/pkg/appClone/AppCloneService.go +++ b/pkg/appClone/AppCloneService.go @@ -20,6 +20,7 @@ import ( "context" "fmt" bean2 "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/internal/constants" app2 "github.com/devtron-labs/devtron/internal/sql/repository/app" appWorkflow2 "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" @@ -95,12 +96,12 @@ func NewAppCloneServiceImpl(logger *zap.SugaredLogger, } type CloneRequest struct { - RefAppId int `json:"refAppId"` - Name string `json:"name"` - ProjectId int `json:"projectId"` - AppLabels []*bean.Label `json:"labels,omitempty" validate:"dive"` - Description *bean2.GenericNoteResponseBean `json:"description"` - AppType helper.AppType `json:"appType"` + RefAppId int `json:"refAppId"` + Name string `json:"name"` + ProjectId int `json:"projectId"` + AppLabels []*bean.Label `json:"labels,omitempty" validate:"dive"` + Description *AppView.GenericNoteResponseBean `json:"description"` + AppType helper.AppType `json:"appType"` } type CreateWorkflowMappingDto struct { diff --git a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go index 5f591fa1d5..621668ae55 100644 --- a/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go +++ b/pkg/appStore/installedApp/service/EAMode/InstalledAppDBService.go @@ -17,6 +17,7 @@ package EAMode import ( + bean2 "github.com/devtron-labs/devtron/api/bean/AppView" helmBean "github.com/devtron-labs/devtron/api/helm-app/service/bean" "github.com/devtron-labs/devtron/internal/sql/repository/helper" util4 "github.com/devtron-labs/devtron/pkg/appStore/util" @@ -29,7 +30,6 @@ import ( "time" "github.com/Pallinder/go-randomdata" - bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/util" diff --git a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 69cea7de60..0e48146a48 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -24,7 +24,7 @@ import ( k8s2 "github.com/devtron-labs/common-lib/utils/k8s" "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/service" "github.com/devtron-labs/devtron/api/helm-app/service/read" @@ -54,8 +54,8 @@ import ( ) type InstalledAppResourceService interface { - FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer - FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean2.DeploymentConfig, helmReleaseInstallStatus string, status string) error + FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *AppView.AppDetailContainer) AppView.AppDetailContainer + FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *AppView.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean2.DeploymentConfig, helmReleaseInstallStatus string, status string) error FetchChartNotes(installedAppId int, envId int, token string, checkNotesAuth func(token string, appName string, envId int) bool) (string, error) } @@ -111,7 +111,7 @@ func NewInstalledAppResourceServiceImpl(logger *zap.SugaredLogger, } } -func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *bean.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean2.DeploymentConfig, helmReleaseInstallStatus string, status string) error { +func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Context, cn http.CloseNotifier, appDetailsContainer *AppView.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean2.DeploymentConfig, helmReleaseInstallStatus string, status string) error { var err error var resourceTree map[string]interface{} deploymentAppName := util2.BuildDeployedAppName(installedApp.App.AppName, installedApp.Environment.Name) @@ -188,7 +188,7 @@ func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Cont return err } -func (impl *InstalledAppResourceServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *bean.AppDetailContainer) bean.AppDetailContainer { +func (impl *InstalledAppResourceServiceImpl) FetchResourceTreeWithHibernateForACD(rctx context.Context, cn http.CloseNotifier, appDetail *AppView.AppDetailContainer) AppView.AppDetailContainer { ctx, cancel := context.WithCancel(rctx) if cn != nil { go func(done <-chan struct{}, closed <-chan bool) { @@ -270,8 +270,8 @@ func (impl *InstalledAppResourceServiceImpl) fetchResourceTreeForACD(rctx contex } }() impl.logger.Debugf("application %s in environment %s had status %+v\n", appId, envId, resp) - k8sAppDetail := bean.AppDetailContainer{ - DeploymentDetailContainer: bean.DeploymentDetailContainer{ + k8sAppDetail := AppView.AppDetailContainer{ + DeploymentDetailContainer: AppView.DeploymentDetailContainer{ ClusterId: clusterId, Namespace: namespace, }, diff --git a/pkg/bean/app.go b/pkg/bean/app.go index bf5cacf847..74c5db98dd 100644 --- a/pkg/bean/app.go +++ b/pkg/bean/app.go @@ -18,7 +18,7 @@ package bean import ( "encoding/json" - bean2 "github.com/devtron-labs/devtron/api/bean" + bean2 "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/internal/sql/constants" repository3 "github.com/devtron-labs/devtron/internal/sql/repository" "github.com/devtron-labs/devtron/internal/sql/repository/appWorkflow" diff --git a/pkg/cluster/ClusterDescriptionService.go b/pkg/cluster/ClusterDescriptionService.go index 995884e6fa..10e00136b1 100644 --- a/pkg/cluster/ClusterDescriptionService.go +++ b/pkg/cluster/ClusterDescriptionService.go @@ -17,9 +17,9 @@ package cluster import ( + apiBean "github.com/devtron-labs/devtron/api/bean/AppView" "time" - apiBean "github.com/devtron-labs/devtron/api/bean" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/cluster/repository" "github.com/go-pg/pg" diff --git a/pkg/generateManifest/DeploymentTemplateService_test.go b/pkg/generateManifest/DeploymentTemplateService_test.go index f157a91c44..08af2bd343 100644 --- a/pkg/generateManifest/DeploymentTemplateService_test.go +++ b/pkg/generateManifest/DeploymentTemplateService_test.go @@ -20,7 +20,7 @@ import ( "context" "errors" "github.com/devtron-labs/common-lib/utils/k8s" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" client "github.com/devtron-labs/devtron/api/helm-app/gRPC" mocks4 "github.com/devtron-labs/devtron/api/helm-app/mocks" "github.com/devtron-labs/devtron/internal/sql/repository" @@ -70,7 +70,7 @@ func TestDeploymentTemplateServiceImpl_FetchDeploymentsWithChartRefs(t *testing. LatestAppChartRef: 2, LatestEnvChartRef: 2, } - publishedOnEnvs := []*bean.Environment{ + publishedOnEnvs := []*AppView.Environment{ { ChartRefId: 2, EnvironmentId: 1, diff --git a/pkg/genericNotes/GenericNoteService.go b/pkg/genericNotes/GenericNoteService.go index 7845a964aa..33193fa6bb 100644 --- a/pkg/genericNotes/GenericNoteService.go +++ b/pkg/genericNotes/GenericNoteService.go @@ -18,9 +18,9 @@ package genericNotes import ( "fmt" + "github.com/devtron-labs/devtron/api/bean/AppView" "time" - "github.com/devtron-labs/devtron/api/bean" repository2 "github.com/devtron-labs/devtron/pkg/auth/user/repository" "github.com/devtron-labs/devtron/pkg/genericNotes/repository" "github.com/go-pg/pg" @@ -28,9 +28,9 @@ import ( ) type GenericNoteService interface { - Save(tx *pg.Tx, bean *repository.GenericNote, userId int32) (*bean.GenericNoteResponseBean, error) - Update(bean *repository.GenericNote, userId int32) (*bean.GenericNoteResponseBean, error) - GetGenericNotesForAppIds(appIds []int) (map[int]*bean.GenericNoteResponseBean, error) + Save(tx *pg.Tx, bean *repository.GenericNote, userId int32) (*AppView.GenericNoteResponseBean, error) + Update(bean *repository.GenericNote, userId int32) (*AppView.GenericNoteResponseBean, error) + GetGenericNotesForAppIds(appIds []int) (map[int]*AppView.GenericNoteResponseBean, error) } type GenericNoteServiceImpl struct { @@ -50,7 +50,7 @@ func NewGenericNoteServiceImpl(genericNoteRepository repository.GenericNoteRepos return genericNoteService } -func (impl *GenericNoteServiceImpl) Save(tx *pg.Tx, req *repository.GenericNote, userId int32) (*bean.GenericNoteResponseBean, error) { +func (impl *GenericNoteServiceImpl) Save(tx *pg.Tx, req *repository.GenericNote, userId int32) (*AppView.GenericNoteResponseBean, error) { existingModel, err := impl.genericNoteRepository.FindByIdentifier(req.Identifier, req.IdentifierType) if err != nil && err != pg.ErrNoRows { impl.logger.Error("error in finding generic note by identifier and identifier type", "err", err, "identifier", req.Identifier, "identifierType", req.IdentifierType) @@ -88,7 +88,7 @@ func (impl *GenericNoteServiceImpl) Save(tx *pg.Tx, req *repository.GenericNote, return nil, err } - return &bean.GenericNoteResponseBean{ + return &AppView.GenericNoteResponseBean{ Id: req.Id, Description: req.Description, UpdatedBy: user.EmailId, @@ -96,7 +96,7 @@ func (impl *GenericNoteServiceImpl) Save(tx *pg.Tx, req *repository.GenericNote, }, err } -func (impl *GenericNoteServiceImpl) Update(req *repository.GenericNote, userId int32) (*bean.GenericNoteResponseBean, error) { +func (impl *GenericNoteServiceImpl) Update(req *repository.GenericNote, userId int32) (*AppView.GenericNoteResponseBean, error) { tx, err := impl.genericNoteRepository.StartTx() defer func() { err = impl.genericNoteRepository.RollbackTx(tx) @@ -161,7 +161,7 @@ func (impl *GenericNoteServiceImpl) Update(req *repository.GenericNote, userId i impl.logger.Errorw("error in committing db transaction in genericNote service", "err", err) return nil, err } - return &bean.GenericNoteResponseBean{ + return &AppView.GenericNoteResponseBean{ Id: model.Id, Description: model.Description, UpdatedBy: user.EmailId, @@ -169,8 +169,8 @@ func (impl *GenericNoteServiceImpl) Update(req *repository.GenericNote, userId i }, err } -func (impl *GenericNoteServiceImpl) GetGenericNotesForAppIds(appIds []int) (map[int]*bean.GenericNoteResponseBean, error) { - appIdsToNoteMap := make(map[int]*bean.GenericNoteResponseBean) +func (impl *GenericNoteServiceImpl) GetGenericNotesForAppIds(appIds []int) (map[int]*AppView.GenericNoteResponseBean, error) { + appIdsToNoteMap := make(map[int]*AppView.GenericNoteResponseBean) //get notes saved in generic note table notes, err := impl.genericNoteRepository.GetGenericNotesForAppIds(appIds) if err != nil { @@ -179,7 +179,7 @@ func (impl *GenericNoteServiceImpl) GetGenericNotesForAppIds(appIds []int) (map[ } for _, note := range notes { - appIdsToNoteMap[note.Identifier] = &bean.GenericNoteResponseBean{ + appIdsToNoteMap[note.Identifier] = &AppView.GenericNoteResponseBean{ Id: note.Id, Description: note.Description, UpdatedOn: note.UpdatedOn, @@ -224,7 +224,7 @@ func (impl *GenericNoteServiceImpl) GetGenericNotesForAppIds(appIds []int) (map[ //set the email ids in the response objects for _, desc := range descriptions { - appIdsToNoteMap[desc.Identifier] = &bean.GenericNoteResponseBean{ + appIdsToNoteMap[desc.Identifier] = &AppView.GenericNoteResponseBean{ Id: desc.Id, Description: desc.Description, UpdatedBy: usersMap[desc.UpdatedBy], diff --git a/pkg/genericNotes/tests/GenericNoteService_test.go b/pkg/genericNotes/tests/GenericNoteService_test.go index dd0654c5b5..5a3c37964b 100644 --- a/pkg/genericNotes/tests/GenericNoteService_test.go +++ b/pkg/genericNotes/tests/GenericNoteService_test.go @@ -18,9 +18,9 @@ package tests import ( "errors" + bean2 "github.com/devtron-labs/devtron/api/bean/AppView" "testing" - bean2 "github.com/devtron-labs/devtron/api/bean" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/auth/user/repository" mocks2 "github.com/devtron-labs/devtron/pkg/auth/user/repository/mocks" diff --git a/pkg/k8s/K8sCommonService.go b/pkg/k8s/K8sCommonService.go index c717614562..0c3a2a9401 100644 --- a/pkg/k8s/K8sCommonService.go +++ b/pkg/k8s/K8sCommonService.go @@ -22,7 +22,7 @@ import ( "github.com/caarlos0/env" "github.com/devtron-labs/common-lib/utils/k8s" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" - "github.com/devtron-labs/devtron/api/bean" + "github.com/devtron-labs/devtron/api/bean/AppView" helmBean "github.com/devtron-labs/devtron/api/helm-app/service/bean" internalUtil "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/argoApplication/read/config" @@ -57,7 +57,7 @@ type K8sCommonService interface { ListEvents(ctx context.Context, request *bean5.ResourceRequestBean) (*k8s.EventsResponse, error) GetRestConfigByClusterId(ctx context.Context, clusterId int) (*rest.Config, error, *bean2.ClusterBean) GetManifestsByBatch(ctx context.Context, request []bean5.ResourceRequestBean) ([]bean5.BatchResourceResponse, error) - FilterK8sResources(ctx context.Context, resourceTreeInf map[string]interface{}, appDetail bean.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []bean5.ResourceRequestBean + FilterK8sResources(ctx context.Context, resourceTreeInf map[string]interface{}, appDetail AppView.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []bean5.ResourceRequestBean RotatePods(ctx context.Context, request *bean5.RotatePodRequest) (*bean5.RotatePodResponse, error) GetCoreClientByClusterId(clusterId int) (*kubernetes.Clientset, *clientV1.CoreV1Client, error) GetCoreClientByClusterIdForExternalArgoApps(req *bean4.EphemeralContainerRequest) (*kubernetes.Clientset, *clientV1.CoreV1Client, error) @@ -243,7 +243,7 @@ func (impl *K8sCommonServiceImpl) ListEvents(ctx context.Context, request *bean5 } -func (impl *K8sCommonServiceImpl) FilterK8sResources(ctx context.Context, resourceTree map[string]interface{}, appDetail bean.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []bean5.ResourceRequestBean { +func (impl *K8sCommonServiceImpl) FilterK8sResources(ctx context.Context, resourceTree map[string]interface{}, appDetail AppView.AppDetailContainer, appId string, kindsToBeFiltered []string, externalArgoAppName string) []bean5.ResourceRequestBean { validRequests := make([]bean5.ResourceRequestBean, 0) kindsToBeFilteredMap := util.ConvertStringSliceToMap(kindsToBeFiltered) resourceTreeNodes, ok := resourceTree["nodes"] diff --git a/pkg/k8s/application/mocks/K8sApplicationService.go b/pkg/k8s/application/mocks/K8sApplicationService.go index f67919d9b0..63fd278f5e 100644 --- a/pkg/k8s/application/mocks/K8sApplicationService.go +++ b/pkg/k8s/application/mocks/K8sApplicationService.go @@ -4,7 +4,7 @@ package mocks import ( "github.com/devtron-labs/common-lib/utils/k8s" - bean "github.com/devtron-labs/devtron/api/bean" + bean "github.com/devtron-labs/devtron/api/bean/AppView" helmBean "github.com/devtron-labs/devtron/api/helm-app/service/bean" bean3 "github.com/devtron-labs/devtron/pkg/cluster/bean" bean2 "github.com/devtron-labs/devtron/pkg/k8s/application/bean" diff --git a/wire_gen.go b/wire_gen.go index a24773b0de..97b21efbcd 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -1,6 +1,6 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run github.com/google/wire/cmd/wire +//go:generate go run -mod=mod github.com/google/wire/cmd/wire //go:build !wireinject // +build !wireinject From 12f01f2c3b6545cd52b138bc534a0b7e02749e89 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 11:18:01 +0530 Subject: [PATCH 02/23] wip --- api/helm-app/gRPC/applicationClient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/helm-app/gRPC/applicationClient.go b/api/helm-app/gRPC/applicationClient.go index 3ff4ccbe17..bd0fc342ea 100644 --- a/api/helm-app/gRPC/applicationClient.go +++ b/api/helm-app/gRPC/applicationClient.go @@ -170,7 +170,7 @@ func (impl *HelmAppClientImpl) GetAppStatusV2(ctx context.Context, in *AppDetail if err != nil { return nil, err } - appStatus, err := applicationClient.GetAppStatus(ctx, in) + appStatus, err := applicationClient.GetAppStatusV2(ctx, in) if err != nil { return nil, err } From 0baf4e74534f35bbfaa4f735cacf04b3011153b4 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 12:52:51 +0530 Subject: [PATCH 03/23] created resourceTree service --- .../app/appList/AppListingRestHandler.go | 31 ++- pkg/app/AppListingService.go | 11 +- .../resourceTree/ResourceTreeService.go | 204 ++++++++++++++++++ .../status/resourceTree/wire_resourceTree.go | 8 + .../deployedApp/status/wire_status.go | 10 + .../deployedApp/wire_deployedApp.go | 2 + wire_gen.go | 86 ++++---- 7 files changed, 306 insertions(+), 46 deletions(-) create mode 100644 pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go create mode 100644 pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go create mode 100644 pkg/deployment/deployedApp/status/wire_status.go diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 071143de7f..c491ff9b98 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -53,6 +53,7 @@ import ( common2 "github.com/devtron-labs/devtron/pkg/deployment/common" bean3 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" bean4 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" + "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status/resourceTree" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/generateManifest" "github.com/devtron-labs/devtron/pkg/genericNotes" @@ -112,6 +113,7 @@ type AppListingRestHandlerImpl struct { deploymentTemplateService generateManifest.DeploymentTemplateService deploymentConfigService common2.DeploymentConfigService argoApplicationService argoApplication2.ArgoApplicationService + resourceTreeService resourceTree.Service } type AppStatus struct { @@ -146,7 +148,7 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient, deploymentTemplateService generateManifest.DeploymentTemplateService, deploymentConfigService common2.DeploymentConfigService, argoApplicationService argoApplication2.ArgoApplicationService, -) *AppListingRestHandlerImpl { + resourceTreeService resourceTree.Service) *AppListingRestHandlerImpl { appListingHandler := &AppListingRestHandlerImpl{ application: application, appListingService: appListingService, @@ -170,6 +172,7 @@ func NewAppListingRestHandlerImpl(application application.ServiceClient, deploymentTemplateService: deploymentTemplateService, deploymentConfigService: deploymentConfigService, argoApplicationService: argoApplicationService, + resourceTreeService: resourceTreeService, } return appListingHandler } @@ -568,7 +571,18 @@ func (handler AppListingRestHandlerImpl) FetchResourceTree(w http.ResponseWriter common.WriteJsonResp(w, fmt.Errorf("error in getting deployment config for env"), nil, http.StatusInternalServerError) return } - resourceTree, err := handler.fetchResourceTree(w, r, appId, envId, cdPipeline, envDeploymentConfig) + ctx, cancel := context.WithCancel(r.Context()) + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + defer cancel() + resourceTree, err := handler.resourceTreeService.FetchResourceTree(ctx, appId, envId, cdPipeline, envDeploymentConfig) if err != nil { handler.logger.Errorw("error in fetching resource tree", "err", err, "appId", appId, "envId", envId) handler.handleResourceTreeErrAndDeletePipelineIfNeeded(w, err, cdPipeline, envDeploymentConfig) @@ -877,7 +891,18 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite common.WriteJsonResp(w, fmt.Errorf("error in getting deployment config for env"), nil, http.StatusInternalServerError) return } - resourceTree, err = handler.fetchResourceTree(w, r, appId, envId, cdPipeline, envDeploymentConfig) + ctx, cancel := context.WithCancel(r.Context()) + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + defer cancel() + resourceTree, err = handler.resourceTreeService.FetchResourceTree(ctx, appId, envId, cdPipeline, envDeploymentConfig) } _, ok := resourceTree["nodes"] if !ok { diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index c6cbe47178..8876874ceb 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -25,6 +25,7 @@ import ( "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow" + argoApplication2 "github.com/devtron-labs/devtron/pkg/argoApplication" userrepository "github.com/devtron-labs/devtron/pkg/auth/user/repository" ciConfig "github.com/devtron-labs/devtron/pkg/build/pipeline/read" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" @@ -32,6 +33,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/read" "github.com/devtron-labs/devtron/pkg/dockerRegistry" + "github.com/devtron-labs/devtron/pkg/k8s" "github.com/devtron-labs/devtron/pkg/pipeline/constants" util2 "github.com/devtron-labs/devtron/util" errors2 "github.com/juju/errors" @@ -147,6 +149,9 @@ type AppListingServiceImpl struct { ciArtifactRepository repository.CiArtifactRepository envConfigOverrideReadService read.EnvConfigOverrideService ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService + + argoApplicationService argoApplication2.ArgoApplicationService + k8sCommonService k8s.K8sCommonService } func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository repository.AppListingRepository, @@ -158,7 +163,9 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService, userRepository userrepository.UserRepository, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, ciArtifactRepository repository.CiArtifactRepository, envConfigOverrideReadService read.EnvConfigOverrideService, - ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService) *AppListingServiceImpl { + ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService, + argoApplicationService argoApplication2.ArgoApplicationService, + k8sCommonService k8s.K8sCommonService) *AppListingServiceImpl { serviceImpl := &AppListingServiceImpl{ Logger: Logger, appListingRepository: appListingRepository, @@ -178,6 +185,8 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re ciArtifactRepository: ciArtifactRepository, envConfigOverrideReadService: envConfigOverrideReadService, ciPipelineConfigReadService: ciPipelineConfigReadService, + argoApplicationService: argoApplicationService, + k8sCommonService: k8sCommonService, } return serviceImpl } diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go new file mode 100644 index 0000000000..b30dc651d9 --- /dev/null +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -0,0 +1,204 @@ +package resourceTree + +import ( + "context" + "fmt" + "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" + "github.com/argoproj/gitops-engine/pkg/health" + k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" + k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" + "github.com/devtron-labs/devtron/api/bean/AppView" + "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/service/read" + argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" + "github.com/devtron-labs/devtron/client/cron" + "github.com/devtron-labs/devtron/internal/constants" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + "github.com/devtron-labs/devtron/internal/util" + "github.com/devtron-labs/devtron/pkg/app" + "github.com/devtron-labs/devtron/pkg/appStatus" + argoApplication2 "github.com/devtron-labs/devtron/pkg/argoApplication" + bean3 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" + "github.com/devtron-labs/devtron/pkg/k8s" + application2 "github.com/devtron-labs/devtron/pkg/k8s/application" + util2 "github.com/devtron-labs/devtron/util" + "go.uber.org/zap" + "strconv" + "time" +) + +type Service interface { + FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, + deploymentConfig *bean3.DeploymentConfig) (map[string]interface{}, error) +} + +type ServiceImpl struct { + logger *zap.SugaredLogger + appListingService app.AppListingService + appStatusService appStatus.AppStatusService + argoApplicationService argoApplication2.ArgoApplicationService + cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler + helmAppClient gRPC.HelmAppClient + helmAppReadService read.HelmAppReadService + k8sApplicationService application2.K8sApplicationService + k8sCommonService k8s.K8sCommonService +} + +func NewServiceImpl(logger *zap.SugaredLogger, + appListingService app.AppListingService, + appStatusService appStatus.AppStatusService, + argoApplicationService argoApplication2.ArgoApplicationService, + cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, + helmAppClient gRPC.HelmAppClient, + helmAppReadService read.HelmAppReadService, + k8sApplicationService application2.K8sApplicationService, + k8sCommonService k8s.K8sCommonService) *ServiceImpl { + serviceImpl := &ServiceImpl{ + logger: logger, + appListingService: appListingService, + appStatusService: appStatusService, + argoApplicationService: argoApplicationService, + cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, + helmAppClient: helmAppClient, + helmAppReadService: helmAppReadService, + k8sApplicationService: k8sApplicationService, + k8sCommonService: k8sCommonService, + } + return serviceImpl +} + +func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, + deploymentConfig *bean3.DeploymentConfig) (map[string]interface{}, error) { + var resourceTree map[string]interface{} + if !cdPipeline.DeploymentAppCreated { + impl.logger.Infow("deployment for this pipeline does not exist", "pipelineId", cdPipeline.Id) + return resourceTree, nil + } + + if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsAcdApp(deploymentConfig.DeploymentAppType) { + // RBAC enforcer Ends + query := &application.ResourcesQuery{ + ApplicationName: &cdPipeline.DeploymentAppName, + } + start := time.Now() + resp, err := impl.argoApplicationService.ResourceTree(ctx, query) + elapsed := time.Since(start) + impl.logger.Debugw("FetchAppDetailsV2, time elapsed in fetching application for environment ", "elapsed", elapsed, "appId", appId, "envId", envId) + if err != nil { + impl.logger.Errorw("service err, FetchAppDetailsV2, resource tree", "err", err, "app", appId, "env", envId) + internalMsg := fmt.Sprintf("%s, err:- %s", constants.UnableToFetchResourceTreeForAcdErrMsg, err.Error()) + clientCode, _ := util.GetClientDetailedError(err) + httpStatusCode := clientCode.GetHttpStatusCodeForGivenGrpcCode() + err = &util.ApiError{ + HttpStatusCode: httpStatusCode, + Code: constants.AppDetailResourceTreeNotFound, + InternalMessage: internalMsg, + UserMessage: "Error fetching detail, if you have recently created this deployment pipeline please try after sometime.", + } + return resourceTree, err + } + + // we currently add appId and envId as labels for devtron apps deployed via acd + label := fmt.Sprintf("appId=%v,envId=%v", cdPipeline.AppId, cdPipeline.EnvironmentId) + pods, err := impl.k8sApplicationService.GetPodListByLabel(cdPipeline.Environment.ClusterId, cdPipeline.Environment.Namespace, label) + if err != nil { + impl.logger.Errorw("error in getting pods by label", "err", err, "clusterId", cdPipeline.Environment.ClusterId, "namespace", cdPipeline.Environment.Namespace, "label", label) + return resourceTree, err + } + ephemeralContainersMap := k8sObjectUtils.ExtractEphemeralContainers(pods) + for _, metaData := range resp.PodMetadata { + metaData.EphemeralContainers = ephemeralContainersMap[metaData.Name] + } + + if resp.Status == string(health.HealthStatusHealthy) { + status, err := impl.appListingService.ISLastReleaseStopType(appId, envId) + if err != nil { + impl.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) + } else if status { + resp.Status = argoApplication.HIBERNATING + } + } + if resp.Status == string(health.HealthStatusDegraded) { + count, err := impl.appListingService.GetReleaseCount(appId, envId) + if err != nil { + impl.logger.Errorw("service err, FetchAppDetailsV2, release count", "err", err, "app", appId, "env", envId) + } else if count == 0 { + resp.Status = app.NotDeployed + } + } + resourceTree = util2.InterfaceToMapAdapter(resp) + go func() { + if resp.Status == string(health.HealthStatusHealthy) { + err = impl.cdApplicationStatusUpdateHandler.SyncPipelineStatusForResourceTreeCall(cdPipeline) + if err != nil { + impl.logger.Errorw("error in syncing pipeline status", "err", err) + } + } + // updating app_status table here + err = impl.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, resp.Status) + if err != nil { + impl.logger.Warnw("error in updating app status", "err", err, "appId", cdPipeline.AppId, "envId", cdPipeline.EnvironmentId) + } + }() + + } else if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsHelmApp(deploymentConfig.DeploymentAppType) { + config, err := impl.helmAppReadService.GetClusterConf(cdPipeline.Environment.ClusterId) + if err != nil { + impl.logger.Errorw("error in fetching cluster detail", "err", err) + } + req := &gRPC.AppDetailRequest{ + ClusterConfig: config, + Namespace: cdPipeline.Environment.Namespace, + ReleaseName: cdPipeline.DeploymentAppName, + } + detail, err := impl.helmAppClient.GetAppDetail(context.Background(), req) + if err != nil { + impl.logger.Errorw("error in fetching app detail", "err", err) + } + if detail != nil && detail.ReleaseExist { + resourceTree = util2.InterfaceToMapAdapter(detail.ResourceTreeResponse) + releaseStatus := util2.InterfaceToMapAdapter(detail.ReleaseStatus) + applicationStatus := detail.ApplicationStatus + resourceTree["releaseStatus"] = releaseStatus + resourceTree["status"] = applicationStatus + if applicationStatus == argoApplication.Healthy { + status, err := impl.appListingService.ISLastReleaseStopType(appId, envId) + if err != nil { + impl.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) + } else if status { + resourceTree["status"] = argoApplication.HIBERNATING + } + } + impl.logger.Warnw("appName and envName not found - avoiding resource tree call", "app", cdPipeline.DeploymentAppName, "env", cdPipeline.Environment.Name) + } + } else { + impl.logger.Warnw("appName and envName not found - avoiding resource tree call", "app", cdPipeline.DeploymentAppName, "env", cdPipeline.Environment.Name) + } + if resourceTree != nil { + version, err := impl.k8sCommonService.GetK8sServerVersion(cdPipeline.Environment.ClusterId) + if err != nil { + impl.logger.Errorw("error in fetching k8s version in resource tree call fetching", "clusterId", cdPipeline.Environment.ClusterId, "err", err) + } else { + resourceTree["serverVersion"] = version.String() + } + } + k8sAppDetail := AppView.AppDetailContainer{ + DeploymentDetailContainer: AppView.DeploymentDetailContainer{ + ClusterId: cdPipeline.Environment.ClusterId, + Namespace: cdPipeline.Environment.Namespace, + }, + } + clusterIdString := strconv.Itoa(cdPipeline.Environment.ClusterId) + validRequest := impl.k8sCommonService.FilterK8sResources(ctx, resourceTree, k8sAppDetail, clusterIdString, []string{k8sCommonBean.ServiceKind, k8sCommonBean.EndpointsKind, k8sCommonBean.IngressKind}, "") + resp, err := impl.k8sCommonService.GetManifestsByBatch(ctx, validRequest) + if err != nil { + impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) + httpStatus, ok := util.IsErrorContextCancelledOrDeadlineExceeded(err) + if ok { + return nil, &util.ApiError{HttpStatusCode: httpStatus, Code: strconv.Itoa(httpStatus), InternalMessage: err.Error()} + } + return nil, err + } + newResourceTree := impl.k8sCommonService.PortNumberExtraction(resp, resourceTree) + return newResourceTree, nil +} diff --git a/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go b/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go new file mode 100644 index 0000000000..10ce5fd06b --- /dev/null +++ b/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go @@ -0,0 +1,8 @@ +package resourceTree + +import "github.com/google/wire" + +var WireSet = wire.NewSet( + NewServiceImpl, + wire.Bind(new(Service), new(*ServiceImpl)), +) diff --git a/pkg/deployment/deployedApp/status/wire_status.go b/pkg/deployment/deployedApp/status/wire_status.go new file mode 100644 index 0000000000..1187426c19 --- /dev/null +++ b/pkg/deployment/deployedApp/status/wire_status.go @@ -0,0 +1,10 @@ +package status + +import ( + "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status/resourceTree" + "github.com/google/wire" +) + +var WireSet = wire.NewSet( + resourceTree.WireSet, +) diff --git a/pkg/deployment/deployedApp/wire_deployedApp.go b/pkg/deployment/deployedApp/wire_deployedApp.go index 6ef6c0fddc..a18c17178b 100644 --- a/pkg/deployment/deployedApp/wire_deployedApp.go +++ b/pkg/deployment/deployedApp/wire_deployedApp.go @@ -17,10 +17,12 @@ package deployedApp import ( + "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status" "github.com/google/wire" ) var DeployedAppWireSet = wire.NewSet( + status.WireSet, NewDeployedAppServiceImpl, wire.Bind(new(DeployedAppService), new(*DeployedAppServiceImpl)), ) diff --git a/wire_gen.go b/wire_gen.go index 97b21efbcd..32601a5b19 100644 --- a/wire_gen.go +++ b/wire_gen.go @@ -78,7 +78,7 @@ import ( "github.com/devtron-labs/devtron/client/argocdServer/connection" "github.com/devtron-labs/devtron/client/argocdServer/repoCredsK8sClient" repository26 "github.com/devtron-labs/devtron/client/argocdServer/repocreds" - repository21 "github.com/devtron-labs/devtron/client/argocdServer/repository" + repository22 "github.com/devtron-labs/devtron/client/argocdServer/repository" "github.com/devtron-labs/devtron/client/argocdServer/version" cron2 "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/client/dashboard" @@ -97,7 +97,7 @@ import ( "github.com/devtron-labs/devtron/internal/sql/repository/deploymentConfig" repository7 "github.com/devtron-labs/devtron/internal/sql/repository/dockerRegistry" "github.com/devtron-labs/devtron/internal/sql/repository/helper" - repository19 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" + repository20 "github.com/devtron-labs/devtron/internal/sql/repository/imageTagging" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/sql/repository/resourceGroup" "github.com/devtron-labs/devtron/internal/util" @@ -141,14 +141,14 @@ import ( read11 "github.com/devtron-labs/devtron/pkg/build/artifacts/imageTagging/read" "github.com/devtron-labs/devtron/pkg/build/git/gitHost" read14 "github.com/devtron-labs/devtron/pkg/build/git/gitHost/read" - repository23 "github.com/devtron-labs/devtron/pkg/build/git/gitHost/repository" + repository24 "github.com/devtron-labs/devtron/pkg/build/git/gitHost/repository" read10 "github.com/devtron-labs/devtron/pkg/build/git/gitMaterial/read" - repository17 "github.com/devtron-labs/devtron/pkg/build/git/gitMaterial/repository" + repository18 "github.com/devtron-labs/devtron/pkg/build/git/gitMaterial/repository" "github.com/devtron-labs/devtron/pkg/build/git/gitProvider" read6 "github.com/devtron-labs/devtron/pkg/build/git/gitProvider/read" repository10 "github.com/devtron-labs/devtron/pkg/build/git/gitProvider/repository" "github.com/devtron-labs/devtron/pkg/build/git/gitWebhook" - repository20 "github.com/devtron-labs/devtron/pkg/build/git/gitWebhook/repository" + repository21 "github.com/devtron-labs/devtron/pkg/build/git/gitWebhook/repository" pipeline2 "github.com/devtron-labs/devtron/pkg/build/pipeline" read9 "github.com/devtron-labs/devtron/pkg/build/pipeline/read" "github.com/devtron-labs/devtron/pkg/bulkAction" @@ -169,6 +169,7 @@ import ( delete2 "github.com/devtron-labs/devtron/pkg/delete" "github.com/devtron-labs/devtron/pkg/deployment/common" "github.com/devtron-labs/devtron/pkg/deployment/deployedApp" + "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status/resourceTree" config2 "github.com/devtron-labs/devtron/pkg/deployment/gitOps/config" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/git" "github.com/devtron-labs/devtron/pkg/deployment/gitOps/validation" @@ -183,7 +184,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/publish" "github.com/devtron-labs/devtron/pkg/deployment/providerConfig" "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps" - repository22 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/userDeploymentRequest/repository" + repository23 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/userDeploymentRequest/repository" service3 "github.com/devtron-labs/devtron/pkg/deployment/trigger/devtronApps/userDeploymentRequest/service" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/devtronResource" @@ -202,7 +203,7 @@ import ( repository8 "github.com/devtron-labs/devtron/pkg/genericNotes/repository" "github.com/devtron-labs/devtron/pkg/gitops" "github.com/devtron-labs/devtron/pkg/imageDigestPolicy" - repository14 "github.com/devtron-labs/devtron/pkg/infraConfig/repository" + repository15 "github.com/devtron-labs/devtron/pkg/infraConfig/repository" service2 "github.com/devtron-labs/devtron/pkg/infraConfig/service" "github.com/devtron-labs/devtron/pkg/infraConfig/units" k8s2 "github.com/devtron-labs/devtron/pkg/k8s" @@ -210,7 +211,7 @@ import ( "github.com/devtron-labs/devtron/pkg/k8s/capacity" "github.com/devtron-labs/devtron/pkg/k8s/informer" "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs" - repository24 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" + repository14 "github.com/devtron-labs/devtron/pkg/kubernetesResourceAuditLogs/repository" "github.com/devtron-labs/devtron/pkg/module" "github.com/devtron-labs/devtron/pkg/module/repo" "github.com/devtron-labs/devtron/pkg/module/store" @@ -218,12 +219,12 @@ import ( "github.com/devtron-labs/devtron/pkg/pipeline" "github.com/devtron-labs/devtron/pkg/pipeline/executors" "github.com/devtron-labs/devtron/pkg/pipeline/history" - repository18 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" + repository19 "github.com/devtron-labs/devtron/pkg/pipeline/history/repository" "github.com/devtron-labs/devtron/pkg/pipeline/infraProviders" - repository15 "github.com/devtron-labs/devtron/pkg/pipeline/repository" + repository16 "github.com/devtron-labs/devtron/pkg/pipeline/repository" "github.com/devtron-labs/devtron/pkg/pipeline/types" "github.com/devtron-labs/devtron/pkg/plugin" - repository16 "github.com/devtron-labs/devtron/pkg/plugin/repository" + repository17 "github.com/devtron-labs/devtron/pkg/plugin/repository" "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning" read12 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/read" repository9 "github.com/devtron-labs/devtron/pkg/policyGovernance/security/imageScanning/repository" @@ -555,13 +556,24 @@ func InitializeApp() (*App, error) { appLevelMetricsRepositoryImpl := repository13.NewAppLevelMetricsRepositoryImpl(db, sugaredLogger) envLevelAppMetricsRepositoryImpl := repository13.NewEnvLevelAppMetricsRepositoryImpl(db, sugaredLogger) deployedAppMetricsServiceImpl := deployedAppMetrics.NewDeployedAppMetricsServiceImpl(sugaredLogger, appLevelMetricsRepositoryImpl, envLevelAppMetricsRepositoryImpl, chartRefServiceImpl) - appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl, deployedAppMetricsServiceImpl, ciArtifactRepositoryImpl, envConfigOverrideReadServiceImpl, ciPipelineConfigReadServiceImpl) + k8sResourceHistoryRepositoryImpl := repository14.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) + k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) + ephemeralContainersRepositoryImpl := repository4.NewEphemeralContainersRepositoryImpl(db, transactionUtilImpl) + ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) + terminalSessionHandlerImpl := terminal.NewTerminalSessionHandlerImpl(environmentServiceImpl, sugaredLogger, k8sServiceImpl, ephemeralContainerServiceImpl, argoApplicationConfigServiceImpl, clusterReadServiceImpl) + fluxApplicationServiceImpl := fluxApplication.NewFluxApplicationServiceImpl(sugaredLogger, helmAppReadServiceImpl, clusterServiceImplExtended, helmAppClientImpl, pumpImpl) + k8sApplicationServiceImpl, err := application2.NewK8sApplicationServiceImpl(sugaredLogger, clusterServiceImplExtended, pumpImpl, helmAppServiceImpl, k8sServiceImpl, acdAuthConfig, k8sResourceHistoryServiceImpl, k8sCommonServiceImpl, terminalSessionHandlerImpl, ephemeralContainerServiceImpl, ephemeralContainersRepositoryImpl, fluxApplicationServiceImpl, clusterReadServiceImpl) + if err != nil { + return nil, err + } + argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationConfigServiceImpl, applicationServiceClientImpl) + appListingServiceImpl := app2.NewAppListingServiceImpl(sugaredLogger, appListingRepositoryImpl, applicationServiceClientImpl, appRepositoryImpl, appListingViewBuilderImpl, pipelineRepositoryImpl, linkoutsRepositoryImpl, cdWorkflowRepositoryImpl, pipelineOverrideRepositoryImpl, environmentRepositoryImpl, chartRepositoryImpl, ciPipelineRepositoryImpl, dockerRegistryIpsConfigServiceImpl, userRepositoryImpl, deployedAppMetricsServiceImpl, ciArtifactRepositoryImpl, envConfigOverrideReadServiceImpl, ciPipelineConfigReadServiceImpl, argoApplicationServiceExtendedImpl, k8sCommonServiceImpl) appServiceImpl := app2.NewAppService(pipelineOverrideRepositoryImpl, mergeUtil, sugaredLogger, pipelineRepositoryImpl, eventRESTClientImpl, eventSimpleFactoryImpl, applicationServiceClientImpl, appRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, cdWorkflowRepositoryImpl, commonServiceImpl, chartTemplateServiceImpl, pipelineStatusTimelineRepositoryImpl, pipelineStatusTimelineResourcesServiceImpl, pipelineStatusSyncDetailServiceImpl, pipelineStatusTimelineServiceImpl, appServiceConfig, appStatusServiceImpl, installedAppReadServiceImpl, installedAppVersionHistoryRepositoryImpl, scopedVariableCMCSManagerImpl, acdConfig, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, deploymentTemplateServiceImpl, appListingServiceImpl, deploymentConfigServiceImpl, envConfigOverrideReadServiceImpl) globalCMCSRepositoryImpl := repository2.NewGlobalCMCSRepositoryImpl(sugaredLogger, db) globalCMCSServiceImpl := pipeline.NewGlobalCMCSServiceImpl(sugaredLogger, globalCMCSRepositoryImpl) argoWorkflowExecutorImpl := executors.NewArgoWorkflowExecutorImpl(sugaredLogger) systemWorkflowExecutorImpl := executors.NewSystemWorkflowExecutorImpl(sugaredLogger, k8sServiceImpl) - infraConfigRepositoryImpl := repository14.NewInfraProfileRepositoryImpl(db, transactionUtilImpl) + infraConfigRepositoryImpl := repository15.NewInfraProfileRepositoryImpl(db, transactionUtilImpl) unitsUnits := units.NewUnits() infraConfigServiceImpl, err := service2.NewInfraConfigServiceImpl(sugaredLogger, infraConfigRepositoryImpl, appServiceImpl, unitsUnits) if err != nil { @@ -572,8 +584,8 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - pipelineStageRepositoryImpl := repository15.NewPipelineStageRepository(sugaredLogger, db) - globalPluginRepositoryImpl := repository16.NewGlobalPluginRepository(sugaredLogger, db) + pipelineStageRepositoryImpl := repository16.NewPipelineStageRepository(sugaredLogger, db) + globalPluginRepositoryImpl := repository17.NewGlobalPluginRepository(sugaredLogger, db) scopedVariableManagerImpl, err := variables.NewScopedVariableManagerImpl(sugaredLogger, scopedVariableServiceImpl, variableEntityMappingServiceImpl, variableSnapshotHistoryServiceImpl, variableTemplateParserImpl) if err != nil { return nil, err @@ -588,7 +600,7 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - materialRepositoryImpl := repository17.NewMaterialRepositoryImpl(db) + materialRepositoryImpl := repository18.NewMaterialRepositoryImpl(db) gitMaterialReadServiceImpl := read10.NewGitMaterialReadServiceImpl(sugaredLogger, materialRepositoryImpl) appCrudOperationServiceImpl := app2.NewAppCrudOperationServiceImpl(appLabelRepositoryImpl, sugaredLogger, appRepositoryImpl, userRepositoryImpl, installedAppRepositoryImpl, genericNoteServiceImpl, installedAppDBServiceImpl, crudOperationServiceConfig, dbMigrationServiceImpl, gitMaterialReadServiceImpl) imageTagRepositoryImpl := repository2.NewImageTagRepository(db, sugaredLogger) @@ -602,20 +614,20 @@ func InitializeApp() (*App, error) { if err != nil { return nil, err } - prePostCdScriptHistoryRepositoryImpl := repository18.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) - configMapHistoryRepositoryImpl := repository18.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db, transactionUtilImpl) + prePostCdScriptHistoryRepositoryImpl := repository19.NewPrePostCdScriptHistoryRepositoryImpl(sugaredLogger, db) + configMapHistoryRepositoryImpl := repository19.NewConfigMapHistoryRepositoryImpl(sugaredLogger, db, transactionUtilImpl) configMapHistoryServiceImpl := configMapAndSecret.NewConfigMapHistoryServiceImpl(sugaredLogger, configMapHistoryRepositoryImpl, pipelineRepositoryImpl, configMapRepositoryImpl, userServiceImpl, scopedVariableCMCSManagerImpl) prePostCdScriptHistoryServiceImpl := history.NewPrePostCdScriptHistoryServiceImpl(sugaredLogger, prePostCdScriptHistoryRepositoryImpl, configMapRepositoryImpl, configMapHistoryServiceImpl) - gitMaterialHistoryRepositoryImpl := repository18.NewGitMaterialHistoryRepositoyImpl(db) + gitMaterialHistoryRepositoryImpl := repository19.NewGitMaterialHistoryRepositoyImpl(db) gitMaterialHistoryServiceImpl := history.NewGitMaterialHistoryServiceImpl(gitMaterialHistoryRepositoryImpl, sugaredLogger) - ciPipelineHistoryRepositoryImpl := repository18.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) + ciPipelineHistoryRepositoryImpl := repository19.NewCiPipelineHistoryRepositoryImpl(db, sugaredLogger) ciPipelineHistoryServiceImpl := history.NewCiPipelineHistoryServiceImpl(ciPipelineHistoryRepositoryImpl, sugaredLogger, ciPipelineRepositoryImpl) ciBuildConfigRepositoryImpl := pipelineConfig.NewCiBuildConfigRepositoryImpl(db, sugaredLogger) ciBuildConfigServiceImpl := pipeline.NewCiBuildConfigServiceImpl(sugaredLogger, ciBuildConfigRepositoryImpl) ciTemplateServiceImpl := pipeline.NewCiTemplateServiceImpl(sugaredLogger, ciBuildConfigServiceImpl, ciTemplateRepositoryImpl, ciTemplateOverrideRepositoryImpl) pipelineConfigRepositoryImpl := chartConfig.NewPipelineConfigRepository(db) configMapServiceImpl := pipeline.NewConfigMapServiceImpl(chartRepositoryImpl, sugaredLogger, chartRepoRepositoryImpl, utilMergeUtil, pipelineConfigRepositoryImpl, configMapRepositoryImpl, envConfigOverrideRepositoryImpl, commonServiceImpl, appRepositoryImpl, configMapHistoryServiceImpl, environmentRepositoryImpl, scopedVariableCMCSManagerImpl) - deploymentTemplateHistoryRepositoryImpl := repository18.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) + deploymentTemplateHistoryRepositoryImpl := repository19.NewDeploymentTemplateHistoryRepositoryImpl(sugaredLogger, db) deploymentTemplateHistoryServiceImpl := deploymentTemplate.NewDeploymentTemplateHistoryServiceImpl(sugaredLogger, deploymentTemplateHistoryRepositoryImpl, pipelineRepositoryImpl, chartRepositoryImpl, userServiceImpl, cdWorkflowRepositoryImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl) chartServiceImpl := chart.NewChartServiceImpl(chartRepositoryImpl, sugaredLogger, chartTemplateServiceImpl, chartRepoRepositoryImpl, appRepositoryImpl, utilMergeUtil, envConfigOverrideRepositoryImpl, pipelineConfigRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, chartRefServiceImpl, gitOpsConfigReadServiceImpl, deploymentConfigServiceImpl, envConfigOverrideReadServiceImpl) ciCdPipelineOrchestratorImpl := pipeline.NewCiCdPipelineOrchestrator(appRepositoryImpl, sugaredLogger, materialRepositoryImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl, cdWorkflowRepositoryImpl, clientImpl, ciCdConfig, appWorkflowRepositoryImpl, environmentRepositoryImpl, attributesServiceImpl, appCrudOperationServiceImpl, userAuthServiceImpl, prePostCdScriptHistoryServiceImpl, pipelineStageServiceImpl, gitMaterialHistoryServiceImpl, ciPipelineHistoryServiceImpl, ciTemplateReadServiceImpl, ciTemplateServiceImpl, dockerArtifactStoreRepositoryImpl, ciArtifactRepositoryImpl, configMapServiceImpl, customTagServiceImpl, genericNoteServiceImpl, chartServiceImpl, transactionUtilImpl, gitOpsConfigReadServiceImpl, deploymentConfigServiceImpl) @@ -627,7 +639,7 @@ func InitializeApp() (*App, error) { resourceGroupRepositoryImpl := resourceGroup.NewResourceGroupRepositoryImpl(db) resourceGroupMappingRepositoryImpl := resourceGroup.NewResourceGroupMappingRepositoryImpl(db) resourceGroupServiceImpl := resourceGroup2.NewResourceGroupServiceImpl(sugaredLogger, resourceGroupRepositoryImpl, resourceGroupMappingRepositoryImpl, enforcerUtilImpl, devtronResourceSearchableKeyServiceImpl, appStatusRepositoryImpl) - imageTaggingRepositoryImpl := repository19.NewImageTaggingRepositoryImpl(db, transactionUtilImpl) + imageTaggingRepositoryImpl := repository20.NewImageTaggingRepositoryImpl(db, transactionUtilImpl) imageTaggingReadServiceImpl, err := read11.NewImageTaggingReadServiceImpl(imageTaggingRepositoryImpl, sugaredLogger) if err != nil { return nil, err @@ -635,23 +647,23 @@ func InitializeApp() (*App, error) { imageTaggingServiceImpl := imageTagging.NewImageTaggingServiceImpl(imageTaggingRepositoryImpl, imageTaggingReadServiceImpl, ciPipelineRepositoryImpl, pipelineRepositoryImpl, environmentRepositoryImpl, sugaredLogger) blobStorageConfigServiceImpl := pipeline.NewBlobStorageConfigServiceImpl(sugaredLogger, k8sServiceImpl, ciCdConfig) ciHandlerImpl := pipeline.NewCiHandlerImpl(sugaredLogger, ciServiceImpl, ciPipelineMaterialRepositoryImpl, clientImpl, ciWorkflowRepositoryImpl, workflowServiceImpl, ciLogServiceImpl, ciArtifactRepositoryImpl, userServiceImpl, eventRESTClientImpl, eventSimpleFactoryImpl, ciPipelineRepositoryImpl, appListingRepositoryImpl, k8sServiceImpl, pipelineRepositoryImpl, enforcerUtilImpl, resourceGroupServiceImpl, environmentRepositoryImpl, imageTaggingServiceImpl, k8sCommonServiceImpl, clusterServiceImplExtended, blobStorageConfigServiceImpl, appWorkflowRepositoryImpl, customTagServiceImpl, environmentServiceImpl) - gitWebhookRepositoryImpl := repository20.NewGitWebhookRepositoryImpl(db) + gitWebhookRepositoryImpl := repository21.NewGitWebhookRepositoryImpl(db) gitWebhookServiceImpl := gitWebhook.NewGitWebhookServiceImpl(sugaredLogger, ciHandlerImpl, gitWebhookRepositoryImpl) gitWebhookRestHandlerImpl := restHandler.NewGitWebhookRestHandlerImpl(sugaredLogger, gitWebhookServiceImpl) ecrConfig, err := pipeline.GetEcrConfig() if err != nil { return nil, err } - ciTemplateHistoryRepositoryImpl := repository18.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) + ciTemplateHistoryRepositoryImpl := repository19.NewCiTemplateHistoryRepositoryImpl(db, sugaredLogger) ciTemplateHistoryServiceImpl := history.NewCiTemplateHistoryServiceImpl(ciTemplateHistoryRepositoryImpl, sugaredLogger) buildPipelineSwitchServiceImpl := pipeline.NewBuildPipelineSwitchServiceImpl(sugaredLogger, ciPipelineConfigReadServiceImpl, ciPipelineRepositoryImpl, ciCdPipelineOrchestratorImpl, pipelineRepositoryImpl, ciWorkflowRepositoryImpl, appWorkflowRepositoryImpl, ciPipelineHistoryServiceImpl, ciTemplateOverrideRepositoryImpl, ciPipelineMaterialRepositoryImpl) ciPipelineConfigServiceImpl := pipeline.NewCiPipelineConfigServiceImpl(sugaredLogger, ciCdPipelineOrchestratorImpl, dockerArtifactStoreRepositoryImpl, gitMaterialReadServiceImpl, appRepositoryImpl, pipelineRepositoryImpl, ciPipelineConfigReadServiceImpl, ciPipelineRepositoryImpl, ecrConfig, appWorkflowRepositoryImpl, ciCdConfig, attributesServiceImpl, pipelineStageServiceImpl, ciPipelineMaterialRepositoryImpl, ciTemplateServiceImpl, ciTemplateReadServiceImpl, ciTemplateOverrideRepositoryImpl, ciTemplateHistoryServiceImpl, enforcerUtilImpl, ciWorkflowRepositoryImpl, resourceGroupServiceImpl, customTagServiceImpl, cdWorkflowRepositoryImpl, buildPipelineSwitchServiceImpl, pipelineStageRepositoryImpl, globalPluginRepositoryImpl) ciMaterialConfigServiceImpl := pipeline.NewCiMaterialConfigServiceImpl(sugaredLogger, materialRepositoryImpl, ciTemplateReadServiceImpl, ciCdPipelineOrchestratorImpl, ciPipelineRepositoryImpl, gitMaterialHistoryServiceImpl, pipelineRepositoryImpl, ciPipelineMaterialRepositoryImpl, transactionUtilImpl, gitMaterialReadServiceImpl) deploymentGroupRepositoryImpl := repository2.NewDeploymentGroupRepositoryImpl(sugaredLogger, db) - pipelineStrategyHistoryRepositoryImpl := repository18.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) + pipelineStrategyHistoryRepositoryImpl := repository19.NewPipelineStrategyHistoryRepositoryImpl(sugaredLogger, db) pipelineStrategyHistoryServiceImpl := history.NewPipelineStrategyHistoryServiceImpl(sugaredLogger, pipelineStrategyHistoryRepositoryImpl, userServiceImpl) propertiesConfigServiceImpl := pipeline.NewPropertiesConfigServiceImpl(sugaredLogger, envConfigOverrideRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, deploymentTemplateHistoryServiceImpl, scopedVariableManagerImpl, deployedAppMetricsServiceImpl, envConfigOverrideReadServiceImpl) - repositoryServiceClientImpl := repository21.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) + repositoryServiceClientImpl := repository22.NewServiceClientImpl(sugaredLogger, argoCDConnectionManagerImpl) runnable := asyncProvider.NewAsyncRunnable(sugaredLogger) argoClientWrapperServiceImpl := argocdServer.NewArgoClientWrapperServiceImpl(sugaredLogger, applicationServiceClientImpl, acdConfig, repositoryServiceClientImpl, gitOpsConfigReadServiceImpl, gitOperationServiceImpl, runnable) imageDigestPolicyServiceImpl := imageDigestPolicy.NewImageDigestPolicyServiceImpl(sugaredLogger, qualifierMappingServiceImpl, devtronResourceSearchableKeyServiceImpl) @@ -706,11 +718,11 @@ func InitializeApp() (*App, error) { manifestCreationServiceImpl := manifest.NewManifestCreationServiceImpl(sugaredLogger, dockerRegistryIpsConfigServiceImpl, chartRefServiceImpl, scopedVariableCMCSManagerImpl, k8sCommonServiceImpl, deployedAppMetricsServiceImpl, imageDigestPolicyServiceImpl, mergeUtil, appCrudOperationServiceImpl, deploymentTemplateServiceImpl, applicationServiceClientImpl, configMapHistoryRepositoryImpl, configMapRepositoryImpl, chartRepositoryImpl, envConfigOverrideRepositoryImpl, environmentRepositoryImpl, pipelineRepositoryImpl, ciArtifactRepositoryImpl, pipelineOverrideRepositoryImpl, pipelineStrategyHistoryRepositoryImpl, pipelineConfigRepositoryImpl, deploymentTemplateHistoryRepositoryImpl, deploymentConfigServiceImpl, envConfigOverrideReadServiceImpl) configMapHistoryReadServiceImpl := read13.NewConfigMapHistoryReadService(sugaredLogger, configMapHistoryRepositoryImpl, scopedVariableCMCSManagerImpl) deployedConfigurationHistoryServiceImpl := history.NewDeployedConfigurationHistoryServiceImpl(sugaredLogger, userServiceImpl, deploymentTemplateHistoryServiceImpl, pipelineStrategyHistoryServiceImpl, configMapHistoryServiceImpl, cdWorkflowRepositoryImpl, scopedVariableCMCSManagerImpl, deploymentTemplateHistoryReadServiceImpl, configMapHistoryReadServiceImpl) - userDeploymentRequestRepositoryImpl := repository22.NewUserDeploymentRequestRepositoryImpl(db, transactionUtilImpl) + userDeploymentRequestRepositoryImpl := repository23.NewUserDeploymentRequestRepositoryImpl(db, transactionUtilImpl) userDeploymentRequestServiceImpl := service3.NewUserDeploymentRequestServiceImpl(sugaredLogger, userDeploymentRequestRepositoryImpl) imageScanDeployInfoReadServiceImpl := read12.NewImageScanDeployInfoReadService(sugaredLogger, imageScanDeployInfoRepositoryImpl) imageScanDeployInfoServiceImpl := imageScanning.NewImageScanDeployInfoService(sugaredLogger, imageScanDeployInfoRepositoryImpl) - manifestPushConfigRepositoryImpl := repository15.NewManifestPushConfigRepository(sugaredLogger, db) + manifestPushConfigRepositoryImpl := repository16.NewManifestPushConfigRepository(sugaredLogger, db) scanToolExecutionHistoryMappingRepositoryImpl := repository9.NewScanToolExecutionHistoryMappingRepositoryImpl(db, sugaredLogger) imageScanServiceImpl := imageScanning.NewImageScanServiceImpl(sugaredLogger, imageScanHistoryRepositoryImpl, imageScanResultRepositoryImpl, imageScanObjectMetaRepositoryImpl, cveStoreRepositoryImpl, imageScanDeployInfoRepositoryImpl, userServiceImpl, appRepositoryImpl, environmentServiceImpl, ciArtifactRepositoryImpl, policyServiceImpl, pipelineRepositoryImpl, ciPipelineRepositoryImpl, scanToolMetadataRepositoryImpl, scanToolExecutionHistoryMappingRepositoryImpl, cvePolicyRepositoryImpl, cdWorkflowRepositoryImpl) triggerServiceImpl, err := devtronApps.NewTriggerServiceImpl(sugaredLogger, cdWorkflowCommonServiceImpl, gitOpsManifestPushServiceImpl, gitOpsConfigReadServiceImpl, argoK8sClientImpl, acdConfig, argoClientWrapperServiceImpl, pipelineStatusTimelineServiceImpl, chartTemplateServiceImpl, workflowEventPublishServiceImpl, manifestCreationServiceImpl, deployedConfigurationHistoryServiceImpl, pipelineStageServiceImpl, globalPluginServiceImpl, customTagServiceImpl, pluginInputVariableParserImpl, prePostCdScriptHistoryServiceImpl, scopedVariableCMCSManagerImpl, workflowServiceImpl, imageDigestPolicyServiceImpl, userServiceImpl, clientImpl, helmAppServiceImpl, enforcerUtilImpl, userDeploymentRequestServiceImpl, helmAppClientImpl, eventSimpleFactoryImpl, eventRESTClientImpl, environmentVariables, appRepositoryImpl, ciPipelineMaterialRepositoryImpl, imageScanHistoryReadServiceImpl, imageScanDeployInfoReadServiceImpl, imageScanDeployInfoServiceImpl, pipelineRepositoryImpl, pipelineOverrideRepositoryImpl, manifestPushConfigRepositoryImpl, chartRepositoryImpl, environmentRepositoryImpl, cdWorkflowRepositoryImpl, ciWorkflowRepositoryImpl, ciArtifactRepositoryImpl, ciTemplateReadServiceImpl, gitMaterialReadServiceImpl, appLabelRepositoryImpl, ciPipelineRepositoryImpl, appWorkflowRepositoryImpl, dockerArtifactStoreRepositoryImpl, imageScanServiceImpl, k8sServiceImpl, transactionUtilImpl, deploymentConfigServiceImpl, ciCdPipelineOrchestratorImpl, gitOperationServiceImpl, attributesServiceImpl, clusterRepositoryImpl) @@ -734,7 +746,7 @@ func InitializeApp() (*App, error) { deleteServiceFullModeImpl := delete2.NewDeleteServiceFullModeImpl(sugaredLogger, gitMaterialReadServiceImpl, gitRegistryConfigImpl, ciTemplateRepositoryImpl, dockerRegistryConfigImpl, dockerArtifactStoreRepositoryImpl) gitProviderRestHandlerImpl := restHandler.NewGitProviderRestHandlerImpl(dockerRegistryConfigImpl, sugaredLogger, gitRegistryConfigImpl, userServiceImpl, validate, enforcerImpl, teamServiceImpl, deleteServiceFullModeImpl, gitProviderReadServiceImpl) gitProviderRouterImpl := router.NewGitProviderRouterImpl(gitProviderRestHandlerImpl) - gitHostRepositoryImpl := repository23.NewGitHostRepositoryImpl(db) + gitHostRepositoryImpl := repository24.NewGitHostRepositoryImpl(db) gitHostConfigImpl := gitHost.NewGitHostConfigImpl(gitHostRepositoryImpl, sugaredLogger) gitHostReadServiceImpl := read14.NewGitHostReadServiceImpl(sugaredLogger, gitHostRepositoryImpl, attributesServiceImpl) gitHostRestHandlerImpl := restHandler.NewGitHostRestHandlerImpl(sugaredLogger, gitHostConfigImpl, userServiceImpl, validate, enforcerImpl, clientImpl, gitProviderReadServiceImpl, gitHostReadServiceImpl) @@ -764,17 +776,6 @@ func InitializeApp() (*App, error) { chartRefRouterImpl := router.NewChartRefRouterImpl(chartRefRestHandlerImpl) configMapRestHandlerImpl := restHandler.NewConfigMapRestHandlerImpl(pipelineBuilderImpl, sugaredLogger, chartServiceImpl, userServiceImpl, teamServiceImpl, enforcerImpl, pipelineRepositoryImpl, enforcerUtilImpl, configMapServiceImpl) configMapRouterImpl := router.NewConfigMapRouterImpl(configMapRestHandlerImpl) - k8sResourceHistoryRepositoryImpl := repository24.NewK8sResourceHistoryRepositoryImpl(db, sugaredLogger) - k8sResourceHistoryServiceImpl := kubernetesResourceAuditLogs.Newk8sResourceHistoryServiceImpl(k8sResourceHistoryRepositoryImpl, sugaredLogger, appRepositoryImpl, environmentRepositoryImpl) - ephemeralContainersRepositoryImpl := repository4.NewEphemeralContainersRepositoryImpl(db, transactionUtilImpl) - ephemeralContainerServiceImpl := cluster2.NewEphemeralContainerServiceImpl(ephemeralContainersRepositoryImpl, sugaredLogger) - terminalSessionHandlerImpl := terminal.NewTerminalSessionHandlerImpl(environmentServiceImpl, sugaredLogger, k8sServiceImpl, ephemeralContainerServiceImpl, argoApplicationConfigServiceImpl, clusterReadServiceImpl) - fluxApplicationServiceImpl := fluxApplication.NewFluxApplicationServiceImpl(sugaredLogger, helmAppReadServiceImpl, clusterServiceImplExtended, helmAppClientImpl, pumpImpl) - k8sApplicationServiceImpl, err := application2.NewK8sApplicationServiceImpl(sugaredLogger, clusterServiceImplExtended, pumpImpl, helmAppServiceImpl, k8sServiceImpl, acdAuthConfig, k8sResourceHistoryServiceImpl, k8sCommonServiceImpl, terminalSessionHandlerImpl, ephemeralContainerServiceImpl, ephemeralContainersRepositoryImpl, fluxApplicationServiceImpl, clusterReadServiceImpl) - if err != nil { - return nil, err - } - argoApplicationServiceExtendedImpl := argoApplication.NewArgoApplicationServiceExtendedServiceImpl(sugaredLogger, clusterRepositoryImpl, k8sServiceImpl, helmAppClientImpl, helmAppServiceImpl, k8sApplicationServiceImpl, argoApplicationConfigServiceImpl, applicationServiceClientImpl) installedAppResourceServiceImpl := resource.NewInstalledAppResourceServiceImpl(sugaredLogger, installedAppRepositoryImpl, appStoreApplicationVersionRepositoryImpl, applicationServiceClientImpl, acdAuthConfig, installedAppVersionHistoryRepositoryImpl, helmAppClientImpl, helmAppServiceImpl, helmAppReadServiceImpl, appStatusServiceImpl, k8sCommonServiceImpl, k8sApplicationServiceImpl, k8sServiceImpl, deploymentConfigServiceImpl, ociRegistryConfigRepositoryImpl, argoApplicationServiceExtendedImpl) chartGroupEntriesRepositoryImpl := repository25.NewChartGroupEntriesRepositoryImpl(db, sugaredLogger) chartGroupReposotoryImpl := repository25.NewChartGroupReposotoryImpl(db, sugaredLogger) @@ -901,7 +902,8 @@ func InitializeApp() (*App, error) { webhookListenerRouterImpl := router.NewWebhookListenerRouterImpl(webhookEventHandlerImpl) appFilteringRestHandlerImpl := appList.NewAppFilteringRestHandlerImpl(sugaredLogger, teamServiceImpl, enforcerImpl, userServiceImpl, clusterServiceImplExtended, environmentServiceImpl, teamReadServiceImpl) appFilteringRouterImpl := appList2.NewAppFilteringRouterImpl(appFilteringRestHandlerImpl) - appListingRestHandlerImpl := appList.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, helmAppReadServiceImpl, k8sCommonServiceImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentConfigServiceImpl, argoApplicationServiceExtendedImpl) + serviceImpl := resourceTree.NewServiceImpl(sugaredLogger, appListingServiceImpl, appStatusServiceImpl, argoApplicationServiceExtendedImpl, cdApplicationStatusUpdateHandlerImpl, helmAppClientImpl, helmAppReadServiceImpl, k8sApplicationServiceImpl, k8sCommonServiceImpl) + appListingRestHandlerImpl := appList.NewAppListingRestHandlerImpl(applicationServiceClientImpl, appListingServiceImpl, enforcerImpl, pipelineBuilderImpl, sugaredLogger, enforcerUtilImpl, deploymentGroupServiceImpl, userServiceImpl, helmAppClientImpl, helmAppReadServiceImpl, k8sCommonServiceImpl, installedAppDBExtendedServiceImpl, installedAppResourceServiceImpl, cdApplicationStatusUpdateHandlerImpl, pipelineRepositoryImpl, appStatusServiceImpl, installedAppRepositoryImpl, genericNoteServiceImpl, k8sApplicationServiceImpl, generateManifestDeploymentTemplateServiceImpl, deploymentConfigServiceImpl, argoApplicationServiceExtendedImpl, serviceImpl) appListingRouterImpl := appList2.NewAppListingRouterImpl(appListingRestHandlerImpl) appInfoRestHandlerImpl := appInfo.NewAppInfoRestHandlerImpl(sugaredLogger, appCrudOperationServiceImpl, userServiceImpl, validate, enforcerUtilImpl, enforcerImpl, helmAppServiceImpl, enforcerUtilHelmImpl, genericNoteServiceImpl) appInfoRouterImpl := appInfo2.NewAppInfoRouterImpl(sugaredLogger, appInfoRestHandlerImpl) @@ -911,7 +913,7 @@ func InitializeApp() (*App, error) { pipelineTriggerRouterImpl := trigger2.NewPipelineTriggerRouter(pipelineTriggerRestHandlerImpl, sseSSE) webhookDataRestHandlerImpl := webhook.NewWebhookDataRestHandlerImpl(sugaredLogger, userServiceImpl, ciPipelineMaterialRepositoryImpl, enforcerUtilImpl, enforcerImpl, clientImpl, webhookEventDataConfigImpl) pipelineConfigRouterImpl := configure2.NewPipelineRouterImpl(pipelineConfigRestHandlerImpl, webhookDataRestHandlerImpl) - prePostCiScriptHistoryRepositoryImpl := repository18.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) + prePostCiScriptHistoryRepositoryImpl := repository19.NewPrePostCiScriptHistoryRepositoryImpl(sugaredLogger, db) prePostCiScriptHistoryServiceImpl := history.NewPrePostCiScriptHistoryServiceImpl(sugaredLogger, prePostCiScriptHistoryRepositoryImpl) pipelineHistoryRestHandlerImpl := history2.NewPipelineHistoryRestHandlerImpl(sugaredLogger, userServiceImpl, enforcerImpl, pipelineStrategyHistoryServiceImpl, deploymentTemplateHistoryServiceImpl, configMapHistoryServiceImpl, prePostCiScriptHistoryServiceImpl, prePostCdScriptHistoryServiceImpl, enforcerUtilImpl, deployedConfigurationHistoryServiceImpl) pipelineHistoryRouterImpl := history3.NewPipelineHistoryRouterImpl(pipelineHistoryRestHandlerImpl) From fe30a556ddf483f5e1ab32030dbcdff7d29d373e Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 13:49:56 +0530 Subject: [PATCH 04/23] resrouce tree service ent --- .../status/resourceTree/ResourceTreeService.go | 10 +++++++--- .../status/resourceTree/ResourceTreeService_ent.go | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService_ent.go diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index b30dc651d9..3ba82c28db 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -18,7 +18,7 @@ import ( "github.com/devtron-labs/devtron/pkg/app" "github.com/devtron-labs/devtron/pkg/appStatus" argoApplication2 "github.com/devtron-labs/devtron/pkg/argoApplication" - bean3 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/common/bean" "github.com/devtron-labs/devtron/pkg/k8s" application2 "github.com/devtron-labs/devtron/pkg/k8s/application" util2 "github.com/devtron-labs/devtron/util" @@ -29,7 +29,11 @@ import ( type Service interface { FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, - deploymentConfig *bean3.DeploymentConfig) (map[string]interface{}, error) + deploymentConfig *commonBean.DeploymentConfig) (map[string]interface{}, error) + + //ent + FetchResourceTreeWithDrift(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, + deploymentConfig *commonBean.DeploymentConfig) (map[string]interface{}, error) } type ServiceImpl struct { @@ -68,7 +72,7 @@ func NewServiceImpl(logger *zap.SugaredLogger, } func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, - deploymentConfig *bean3.DeploymentConfig) (map[string]interface{}, error) { + deploymentConfig *commonBean.DeploymentConfig) (map[string]interface{}, error) { var resourceTree map[string]interface{} if !cdPipeline.DeploymentAppCreated { impl.logger.Infow("deployment for this pipeline does not exist", "pipelineId", cdPipeline.Id) diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService_ent.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService_ent.go new file mode 100644 index 0000000000..89dee8d431 --- /dev/null +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService_ent.go @@ -0,0 +1,12 @@ +package resourceTree + +import ( + "context" + "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" + commonBean "github.com/devtron-labs/devtron/pkg/deployment/common/bean" +) + +func (impl *ServiceImpl) FetchResourceTreeWithDrift(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, + deploymentConfig *commonBean.DeploymentConfig) (map[string]interface{}, error) { + return nil, nil +} From 44b3a0fdd66da5a31440c069a4cb96825d00ee1b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 13:50:48 +0530 Subject: [PATCH 05/23] Added licenses --- .../status/resourceTree/ResourceTreeService.go | 16 ++++++++++++++++ .../status/resourceTree/wire_resourceTree.go | 16 ++++++++++++++++ pkg/deployment/deployedApp/status/wire_status.go | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index 3ba82c28db..5061db120a 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024. Devtron Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package resourceTree import ( diff --git a/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go b/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go index 10ce5fd06b..47975da8f8 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go +++ b/pkg/deployment/deployedApp/status/resourceTree/wire_resourceTree.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024. Devtron Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package resourceTree import "github.com/google/wire" diff --git a/pkg/deployment/deployedApp/status/wire_status.go b/pkg/deployment/deployedApp/status/wire_status.go index 1187426c19..e1c7c1ffa7 100644 --- a/pkg/deployment/deployedApp/status/wire_status.go +++ b/pkg/deployment/deployedApp/status/wire_status.go @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2024. Devtron Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package status import ( From c2ba6309d86554431c8a642534742e0287537165 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 15:57:46 +0530 Subject: [PATCH 06/23] removed resource tree --- .../app/appList/AppListingRestHandler.go | 152 ------------------ 1 file changed, 152 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index c491ff9b98..7ded839871 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -21,18 +21,14 @@ import ( "encoding/json" "errors" "fmt" - application2 "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" - "github.com/devtron-labs/common-lib/utils/k8s/health" - k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/service/read" "github.com/devtron-labs/devtron/api/restHandler/common" util3 "github.com/devtron-labs/devtron/api/util" "github.com/devtron-labs/devtron/client/argocdServer/application" - argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/middleware" @@ -61,7 +57,6 @@ import ( application3 "github.com/devtron-labs/devtron/pkg/k8s/application" "github.com/devtron-labs/devtron/pkg/pipeline" bean6 "github.com/devtron-labs/devtron/pkg/team/bean" - util2 "github.com/devtron-labs/devtron/util" "github.com/devtron-labs/devtron/util/rbac" "github.com/go-pg/pg" "github.com/gorilla/mux" @@ -948,150 +943,3 @@ func (handler AppListingRestHandlerImpl) getAppDetails(ctx context.Context, appI appDetail, err = handler.installedAppService.FindAppDetailsForAppstoreApplication(appId, envId) return appDetail, err, appId } - -// TODO: move this to service -func (handler AppListingRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, deploymentConfig *bean3.DeploymentConfig) (map[string]interface{}, error) { - var resourceTree map[string]interface{} - if !cdPipeline.DeploymentAppCreated { - handler.logger.Infow("deployment for this pipeline does not exist", "pipelineId", cdPipeline.Id) - return resourceTree, nil - } - - if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsAcdApp(deploymentConfig.DeploymentAppType) { - // RBAC enforcer Ends - query := &application2.ResourcesQuery{ - ApplicationName: &cdPipeline.DeploymentAppName, - } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - defer cancel() - start := time.Now() - resp, err := handler.argoApplicationService.ResourceTree(ctx, query) - elapsed := time.Since(start) - handler.logger.Debugw("FetchAppDetailsV2, time elapsed in fetching application for environment ", "elapsed", elapsed, "appId", appId, "envId", envId) - if err != nil { - handler.logger.Errorw("service err, FetchAppDetailsV2, resource tree", "err", err, "app", appId, "env", envId) - internalMsg := fmt.Sprintf("%s, err:- %s", constants.UnableToFetchResourceTreeForAcdErrMsg, err.Error()) - clientCode, _ := util.GetClientDetailedError(err) - httpStatusCode := clientCode.GetHttpStatusCodeForGivenGrpcCode() - err = &util.ApiError{ - HttpStatusCode: httpStatusCode, - Code: constants.AppDetailResourceTreeNotFound, - InternalMessage: internalMsg, - UserMessage: "Error fetching detail, if you have recently created this deployment pipeline please try after sometime.", - } - return resourceTree, err - } - - // we currently add appId and envId as labels for devtron apps deployed via acd - label := fmt.Sprintf("appId=%v,envId=%v", cdPipeline.AppId, cdPipeline.EnvironmentId) - pods, err := handler.k8sApplicationService.GetPodListByLabel(cdPipeline.Environment.ClusterId, cdPipeline.Environment.Namespace, label) - if err != nil { - handler.logger.Errorw("error in getting pods by label", "err", err, "clusterId", cdPipeline.Environment.ClusterId, "namespace", cdPipeline.Environment.Namespace, "label", label) - return resourceTree, err - } - ephemeralContainersMap := k8sObjectUtils.ExtractEphemeralContainers(pods) - for _, metaData := range resp.PodMetadata { - metaData.EphemeralContainers = ephemeralContainersMap[metaData.Name] - } - - if resp.Status == string(health.HealthStatusHealthy) { - status, err := handler.appListingService.ISLastReleaseStopType(appId, envId) - if err != nil { - handler.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) - } else if status { - resp.Status = argoApplication.HIBERNATING - } - } - if resp.Status == string(health.HealthStatusDegraded) { - count, err := handler.appListingService.GetReleaseCount(appId, envId) - if err != nil { - handler.logger.Errorw("service err, FetchAppDetailsV2, release count", "err", err, "app", appId, "env", envId) - } else if count == 0 { - resp.Status = app.NotDeployed - } - } - resourceTree = util2.InterfaceToMapAdapter(resp) - go func() { - if resp.Status == string(health.HealthStatusHealthy) { - err = handler.cdApplicationStatusUpdateHandler.SyncPipelineStatusForResourceTreeCall(cdPipeline) - if err != nil { - handler.logger.Errorw("error in syncing pipeline status", "err", err) - } - } - // updating app_status table here - err = handler.appStatusService.UpdateStatusWithAppIdEnvId(appId, envId, resp.Status) - if err != nil { - handler.logger.Warnw("error in updating app status", "err", err, "appId", cdPipeline.AppId, "envId", cdPipeline.EnvironmentId) - } - }() - - } else if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsHelmApp(deploymentConfig.DeploymentAppType) { - config, err := handler.helmAppReadService.GetClusterConf(cdPipeline.Environment.ClusterId) - if err != nil { - handler.logger.Errorw("error in fetching cluster detail", "err", err) - } - req := &gRPC.AppDetailRequest{ - ClusterConfig: config, - Namespace: cdPipeline.Environment.Namespace, - ReleaseName: cdPipeline.DeploymentAppName, - } - detail, err := handler.helmAppClient.GetAppDetail(context.Background(), req) - if err != nil { - handler.logger.Errorw("error in fetching app detail", "err", err) - } - if detail != nil && detail.ReleaseExist { - resourceTree = util2.InterfaceToMapAdapter(detail.ResourceTreeResponse) - releaseStatus := util2.InterfaceToMapAdapter(detail.ReleaseStatus) - applicationStatus := detail.ApplicationStatus - resourceTree["releaseStatus"] = releaseStatus - resourceTree["status"] = applicationStatus - if applicationStatus == argoApplication.Healthy { - status, err := handler.appListingService.ISLastReleaseStopType(appId, envId) - if err != nil { - handler.logger.Errorw("service err, FetchAppDetailsV2", "err", err, "app", appId, "env", envId) - } else if status { - resourceTree["status"] = argoApplication.HIBERNATING - } - } - handler.logger.Warnw("appName and envName not found - avoiding resource tree call", "app", cdPipeline.DeploymentAppName, "env", cdPipeline.Environment.Name) - } - } else { - handler.logger.Warnw("appName and envName not found - avoiding resource tree call", "app", cdPipeline.DeploymentAppName, "env", cdPipeline.Environment.Name) - } - if resourceTree != nil { - version, err := handler.k8sCommonService.GetK8sServerVersion(cdPipeline.Environment.ClusterId) - if err != nil { - handler.logger.Errorw("error in fetching k8s version in resource tree call fetching", "clusterId", cdPipeline.Environment.ClusterId, "err", err) - } else { - resourceTree["serverVersion"] = version.String() - } - } - k8sAppDetail := AppView.AppDetailContainer{ - DeploymentDetailContainer: AppView.DeploymentDetailContainer{ - ClusterId: cdPipeline.Environment.ClusterId, - Namespace: cdPipeline.Environment.Namespace, - }, - } - clusterIdString := strconv.Itoa(cdPipeline.Environment.ClusterId) - validRequest := handler.k8sCommonService.FilterK8sResources(r.Context(), resourceTree, k8sAppDetail, clusterIdString, []string{k8sCommonBean.ServiceKind, k8sCommonBean.EndpointsKind, k8sCommonBean.IngressKind}, "") - resp, err := handler.k8sCommonService.GetManifestsByBatch(r.Context(), validRequest) - if err != nil { - handler.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) - httpStatus, ok := util.IsErrorContextCancelledOrDeadlineExceeded(err) - if ok { - return nil, &util.ApiError{HttpStatusCode: httpStatus, Code: strconv.Itoa(httpStatus), InternalMessage: err.Error()} - } - return nil, err - } - newResourceTree := handler.k8sCommonService.PortNumberExtraction(resp, resourceTree) - return newResourceTree, nil -} From 24701e6a51fb4bd117127f084b7c13660963ec53 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 16:00:58 +0530 Subject: [PATCH 07/23] wip --- .../app/appList/AppListingRestHandler.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 7ded839871..37699a2bd3 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -788,6 +788,17 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite installedAppIdParam := vars.Get("installedAppId") envIdParam := vars.Get("envId") + ctx, cancel := context.WithCancel(r.Context()) + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + defer cancel() if (appIdParam == "" && installedAppIdParam == "") || (appIdParam != "" && installedAppIdParam != "") { handler.logger.Error("error in decoding batch request body", "appId", appIdParam, "installedAppId", installedAppIdParam) common.WriteJsonResp(w, fmt.Errorf("only one of the appId or installedAppId should be valid appId: %s installedAppId: %s", appIdParam, installedAppIdParam), nil, http.StatusBadRequest) @@ -886,17 +897,6 @@ func (handler AppListingRestHandlerImpl) GetHostUrlsByBatch(w http.ResponseWrite common.WriteJsonResp(w, fmt.Errorf("error in getting deployment config for env"), nil, http.StatusInternalServerError) return } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - defer cancel() resourceTree, err = handler.resourceTreeService.FetchResourceTree(ctx, appId, envId, cdPipeline, envDeploymentConfig) } _, ok := resourceTree["nodes"] From de84a087988bb8a65d222e3eb6bc12e0987aa61b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 16:05:58 +0530 Subject: [PATCH 08/23] removed unused dependencies --- .../app/appList/AppListingRestHandler.go | 92 ++++++------------- 1 file changed, 29 insertions(+), 63 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 37699a2bd3..f5c58140e2 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -24,24 +24,18 @@ import ( "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" "github.com/devtron-labs/devtron/api/bean/AppView" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" - "github.com/devtron-labs/devtron/api/helm-app/service/read" "github.com/devtron-labs/devtron/api/restHandler/common" util3 "github.com/devtron-labs/devtron/api/util" - "github.com/devtron-labs/devtron/client/argocdServer/application" - "github.com/devtron-labs/devtron/client/cron" "github.com/devtron-labs/devtron/internal/constants" "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/helper" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig" "github.com/devtron-labs/devtron/internal/util" "github.com/devtron-labs/devtron/pkg/app" - "github.com/devtron-labs/devtron/pkg/appStatus" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/repository" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode" "github.com/devtron-labs/devtron/pkg/appStore/installedApp/service/FullMode/resource" util4 "github.com/devtron-labs/devtron/pkg/appStore/util" - argoApplication2 "github.com/devtron-labs/devtron/pkg/argoApplication" "github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin" "github.com/devtron-labs/devtron/pkg/auth/user" bean5 "github.com/devtron-labs/devtron/pkg/cluster/bean" @@ -51,8 +45,6 @@ import ( bean4 "github.com/devtron-labs/devtron/pkg/deployment/common/bean" "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status/resourceTree" "github.com/devtron-labs/devtron/pkg/deploymentGroup" - "github.com/devtron-labs/devtron/pkg/generateManifest" - "github.com/devtron-labs/devtron/pkg/genericNotes" "github.com/devtron-labs/devtron/pkg/k8s" application3 "github.com/devtron-labs/devtron/pkg/k8s/application" "github.com/devtron-labs/devtron/pkg/pipeline" @@ -85,30 +77,20 @@ type AppListingRestHandler interface { } type AppListingRestHandlerImpl struct { - application application.ServiceClient - appListingService app.AppListingService - enforcer casbin.Enforcer - pipeline pipeline.PipelineBuilder - logger *zap.SugaredLogger - enforcerUtil rbac.EnforcerUtil - deploymentGroupService deploymentGroup.DeploymentGroupService - userService user.UserService - // TODO fix me next - helmAppClient gRPC.HelmAppClient // TODO refactoring: use HelmAppService - helmAppReadService read.HelmAppReadService - k8sCommonService k8s.K8sCommonService - installedAppService FullMode.InstalledAppDBExtendedService - installedAppResourceService resource.InstalledAppResourceService - cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler - pipelineRepository pipelineConfig.PipelineRepository - appStatusService appStatus.AppStatusService - installedAppRepository repository.InstalledAppRepository - genericNoteService genericNotes.GenericNoteService - k8sApplicationService application3.K8sApplicationService - deploymentTemplateService generateManifest.DeploymentTemplateService - deploymentConfigService common2.DeploymentConfigService - argoApplicationService argoApplication2.ArgoApplicationService - resourceTreeService resourceTree.Service + appListingService app.AppListingService + enforcer casbin.Enforcer + pipeline pipeline.PipelineBuilder + logger *zap.SugaredLogger + enforcerUtil rbac.EnforcerUtil + deploymentGroupService deploymentGroup.DeploymentGroupService + userService user.UserService + k8sCommonService k8s.K8sCommonService + installedAppService FullMode.InstalledAppDBExtendedService + installedAppResourceService resource.InstalledAppResourceService + pipelineRepository pipelineConfig.PipelineRepository + k8sApplicationService application3.K8sApplicationService + deploymentConfigService common2.DeploymentConfigService + resourceTreeService resourceTree.Service } type AppStatus struct { @@ -125,49 +107,33 @@ type AppAutocomplete struct { Clusters []bean5.ClusterBean } -func NewAppListingRestHandlerImpl(application application.ServiceClient, - appListingService app.AppListingService, +func NewAppListingRestHandlerImpl(appListingService app.AppListingService, enforcer casbin.Enforcer, pipeline pipeline.PipelineBuilder, logger *zap.SugaredLogger, enforcerUtil rbac.EnforcerUtil, deploymentGroupService deploymentGroup.DeploymentGroupService, userService user.UserService, - helmAppClient gRPC.HelmAppClient, helmAppReadService read.HelmAppReadService, k8sCommonService k8s.K8sCommonService, installedAppService FullMode.InstalledAppDBExtendedService, installedAppResourceService resource.InstalledAppResourceService, - cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, pipelineRepository pipelineConfig.PipelineRepository, - appStatusService appStatus.AppStatusService, installedAppRepository repository.InstalledAppRepository, - genericNoteService genericNotes.GenericNoteService, k8sApplicationService application3.K8sApplicationService, - deploymentTemplateService generateManifest.DeploymentTemplateService, deploymentConfigService common2.DeploymentConfigService, - argoApplicationService argoApplication2.ArgoApplicationService, resourceTreeService resourceTree.Service) *AppListingRestHandlerImpl { appListingHandler := &AppListingRestHandlerImpl{ - application: application, - appListingService: appListingService, - logger: logger, - pipeline: pipeline, - enforcer: enforcer, - enforcerUtil: enforcerUtil, - deploymentGroupService: deploymentGroupService, - userService: userService, - helmAppClient: helmAppClient, - helmAppReadService: helmAppReadService, - k8sCommonService: k8sCommonService, - installedAppService: installedAppService, - installedAppResourceService: installedAppResourceService, - cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, - pipelineRepository: pipelineRepository, - appStatusService: appStatusService, - installedAppRepository: installedAppRepository, - genericNoteService: genericNoteService, - k8sApplicationService: k8sApplicationService, - deploymentTemplateService: deploymentTemplateService, - deploymentConfigService: deploymentConfigService, - argoApplicationService: argoApplicationService, - resourceTreeService: resourceTreeService, + appListingService: appListingService, + logger: logger, + pipeline: pipeline, + enforcer: enforcer, + enforcerUtil: enforcerUtil, + deploymentGroupService: deploymentGroupService, + userService: userService, + k8sCommonService: k8sCommonService, + installedAppService: installedAppService, + installedAppResourceService: installedAppResourceService, + pipelineRepository: pipelineRepository, + k8sApplicationService: k8sApplicationService, + deploymentConfigService: deploymentConfigService, + resourceTreeService: resourceTreeService, } return appListingHandler } From 233ec5553cbb8dfbfe0e4dfc3ba5d9d802937223 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 16:09:48 +0530 Subject: [PATCH 09/23] oss/ent --- .../app/appList/AppListingRestHandler.go | 5 +++++ .../app/appList/AppListingRestHandler_ent.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 api/restHandler/app/appList/AppListingRestHandler_ent.go diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index f5c58140e2..3775f04aa8 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -74,6 +74,11 @@ type AppListingRestHandler interface { FetchAppsByEnvironmentV2(w http.ResponseWriter, r *http.Request) FetchOverviewAppsByEnvironment(w http.ResponseWriter, r *http.Request) + + //ent + FetchAppPolicyConsequences(w http.ResponseWriter, r *http.Request) + FetchAutocompleteJobCiPipelines(w http.ResponseWriter, r *http.Request) + GetAllAppEnvsFromResourceNames(w http.ResponseWriter, r *http.Request) } type AppListingRestHandlerImpl struct { diff --git a/api/restHandler/app/appList/AppListingRestHandler_ent.go b/api/restHandler/app/appList/AppListingRestHandler_ent.go new file mode 100644 index 0000000000..e923552619 --- /dev/null +++ b/api/restHandler/app/appList/AppListingRestHandler_ent.go @@ -0,0 +1,14 @@ +package appList + +import ( + "net/http" +) + +func (handler AppListingRestHandlerImpl) FetchAppPolicyConsequences(w http.ResponseWriter, r *http.Request) { +} + +func (handler AppListingRestHandlerImpl) FetchAutocompleteJobCiPipelines(w http.ResponseWriter, r *http.Request) { +} + +func (handler AppListingRestHandlerImpl) GetAllAppEnvsFromResourceNames(w http.ResponseWriter, r *http.Request) { +} From 6ecdabf93595b655eca783afe1188e40bb6f7a75 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 16:33:26 +0530 Subject: [PATCH 10/23] wip --- .../app/appList/AppListingRestHandler.go | 13 +++++++ .../resourceTree/ResourceTreeService.go | 39 ++++++++++--------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 3775f04aa8..d2595caa84 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -502,6 +502,19 @@ func (handler AppListingRestHandlerImpl) FetchResourceTree(w http.ResponseWriter common.WriteJsonResp(w, err, nil, http.StatusBadRequest) return } + ctx, cancel := context.WithCancel(r.Context()) + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + defer cancel() + ctx = context.WithValue(ctx, "token", token) + envId, err := strconv.Atoi(vars["env-id"]) if err != nil { common.WriteJsonResp(w, err, nil, http.StatusBadRequest) diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index 5061db120a..cdb1524e8e 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -160,6 +160,25 @@ func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId impl.logger.Warnw("error in updating app status", "err", err, "appId", cdPipeline.AppId, "envId", cdPipeline.EnvironmentId) } }() + k8sAppDetail := AppView.AppDetailContainer{ + DeploymentDetailContainer: AppView.DeploymentDetailContainer{ + ClusterId: cdPipeline.Environment.ClusterId, + Namespace: cdPipeline.Environment.Namespace, + }, + } + + clusterIdString := strconv.Itoa(cdPipeline.Environment.ClusterId) + validRequest := impl.k8sCommonService.FilterK8sResources(ctx, resourceTree, k8sAppDetail, clusterIdString, []string{k8sCommonBean.ServiceKind, k8sCommonBean.EndpointsKind, k8sCommonBean.IngressKind}, "") + respManifest, err := impl.k8sCommonService.GetManifestsByBatch(ctx, validRequest) + if err != nil { + impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) + httpStatus, ok := util.IsErrorContextCancelledOrDeadlineExceeded(err) + if ok { + return nil, &util.ApiError{HttpStatusCode: httpStatus, Code: strconv.Itoa(httpStatus), InternalMessage: err.Error()} + } + return nil, err + } + resourceTree = impl.k8sCommonService.PortNumberExtraction(respManifest, resourceTree) } else if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsHelmApp(deploymentConfig.DeploymentAppType) { config, err := impl.helmAppReadService.GetClusterConf(cdPipeline.Environment.ClusterId) @@ -202,23 +221,5 @@ func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId resourceTree["serverVersion"] = version.String() } } - k8sAppDetail := AppView.AppDetailContainer{ - DeploymentDetailContainer: AppView.DeploymentDetailContainer{ - ClusterId: cdPipeline.Environment.ClusterId, - Namespace: cdPipeline.Environment.Namespace, - }, - } - clusterIdString := strconv.Itoa(cdPipeline.Environment.ClusterId) - validRequest := impl.k8sCommonService.FilterK8sResources(ctx, resourceTree, k8sAppDetail, clusterIdString, []string{k8sCommonBean.ServiceKind, k8sCommonBean.EndpointsKind, k8sCommonBean.IngressKind}, "") - resp, err := impl.k8sCommonService.GetManifestsByBatch(ctx, validRequest) - if err != nil { - impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) - httpStatus, ok := util.IsErrorContextCancelledOrDeadlineExceeded(err) - if ok { - return nil, &util.ApiError{HttpStatusCode: httpStatus, Code: strconv.Itoa(httpStatus), InternalMessage: err.Error()} - } - return nil, err - } - newResourceTree := impl.k8sCommonService.PortNumberExtraction(resp, resourceTree) - return newResourceTree, nil + return resourceTree, nil } From 4226677ee92c461e5014d08f384a287875588304 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 16:41:04 +0530 Subject: [PATCH 11/23] wip --- .../app/appList/AppListingRestHandler.go | 11 --------- .../FullMode/resource/ResourceTreeService.go | 19 ++++++--------- .../resourceTree/ResourceTreeService.go | 23 ++++++++----------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index d2595caa84..8761580c0e 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -550,17 +550,6 @@ func (handler AppListingRestHandlerImpl) FetchResourceTree(w http.ResponseWriter common.WriteJsonResp(w, fmt.Errorf("error in getting deployment config for env"), nil, http.StatusInternalServerError) return } - ctx, cancel := context.WithCancel(r.Context()) - if cn, ok := w.(http.CloseNotifier); ok { - go func(done <-chan struct{}, closed <-chan bool) { - select { - case <-done: - case <-closed: - cancel() - } - }(ctx.Done(), cn.CloseNotify()) - } - defer cancel() resourceTree, err := handler.resourceTreeService.FetchResourceTree(ctx, appId, envId, cdPipeline, envDeploymentConfig) if err != nil { handler.logger.Errorw("error in fetching resource tree", "err", err, "appId", appId, "envId", envId) diff --git a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 0e48146a48..6cb3d8dd16 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -27,6 +27,7 @@ import ( "github.com/devtron-labs/devtron/api/bean/AppView" "github.com/devtron-labs/devtron/api/helm-app/gRPC" "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/api/helm-app/service/bean" "github.com/devtron-labs/devtron/api/helm-app/service/read" application2 "github.com/devtron-labs/devtron/client/argocdServer/application" "github.com/devtron-labs/devtron/internal/constants" @@ -66,7 +67,6 @@ type InstalledAppResourceServiceImpl struct { acdClient application2.ServiceClient aCDAuthConfig *util3.ACDAuthConfig installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository - helmAppClient gRPC.HelmAppClient helmAppService service.HelmAppService helmAppReadService read.HelmAppReadService appStatusService appStatus.AppStatusService @@ -84,7 +84,7 @@ func NewInstalledAppResourceServiceImpl(logger *zap.SugaredLogger, acdClient application2.ServiceClient, aCDAuthConfig *util3.ACDAuthConfig, installedAppRepositoryHistory repository.InstalledAppVersionHistoryRepository, - helmAppClient gRPC.HelmAppClient, helmAppService service.HelmAppService, + helmAppService service.HelmAppService, helmAppReadService read.HelmAppReadService, appStatusService appStatus.AppStatusService, k8sCommonService k8s.K8sCommonService, k8sApplicationService application3.K8sApplicationService, K8sUtil k8s2.K8sService, @@ -98,7 +98,6 @@ func NewInstalledAppResourceServiceImpl(logger *zap.SugaredLogger, acdClient: acdClient, aCDAuthConfig: aCDAuthConfig, installedAppRepositoryHistory: installedAppRepositoryHistory, - helmAppClient: helmAppClient, helmAppService: helmAppService, helmAppReadService: helmAppReadService, appStatusService: appStatusService, @@ -118,16 +117,12 @@ func (impl *InstalledAppResourceServiceImpl) FetchResourceTree(rctx context.Cont if util.IsAcdApp(deploymentConfig.DeploymentAppType) { resourceTree, err = impl.fetchResourceTreeForACD(rctx, cn, installedApp.App.Id, installedApp.EnvironmentId, installedApp.Environment.ClusterId, deploymentAppName, installedApp.Environment.Namespace) } else if util.IsHelmApp(deploymentConfig.DeploymentAppType) { - config, err := impl.helmAppReadService.GetClusterConf(installedApp.Environment.ClusterId) - if err != nil { - impl.logger.Errorw("error in fetching cluster detail", "err", err) - } - req := &gRPC.AppDetailRequest{ - ClusterConfig: config, - Namespace: installedApp.Environment.Namespace, - ReleaseName: installedApp.App.AppName, + req := &bean.AppIdentifier{ + ClusterId: installedApp.Environment.ClusterId, + Namespace: installedApp.Environment.Namespace, + ReleaseName: installedApp.App.AppName, } - detail, err := impl.helmAppClient.GetAppDetail(rctx, req) + detail, err := impl.helmAppService.GetApplicationDetail(rctx, req) if err != nil { impl.logger.Errorw("error in fetching app detail", "err", err) } diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index cdb1524e8e..29dbbffd15 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -24,7 +24,8 @@ import ( k8sCommonBean "github.com/devtron-labs/common-lib/utils/k8s/commonBean" k8sObjectUtils "github.com/devtron-labs/common-lib/utils/k8sObjectsUtil" "github.com/devtron-labs/devtron/api/bean/AppView" - "github.com/devtron-labs/devtron/api/helm-app/gRPC" + "github.com/devtron-labs/devtron/api/helm-app/service" + "github.com/devtron-labs/devtron/api/helm-app/service/bean" "github.com/devtron-labs/devtron/api/helm-app/service/read" argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" "github.com/devtron-labs/devtron/client/cron" @@ -58,8 +59,8 @@ type ServiceImpl struct { appStatusService appStatus.AppStatusService argoApplicationService argoApplication2.ArgoApplicationService cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler - helmAppClient gRPC.HelmAppClient helmAppReadService read.HelmAppReadService + helmAppService service.HelmAppService k8sApplicationService application2.K8sApplicationService k8sCommonService k8s.K8sCommonService } @@ -69,8 +70,8 @@ func NewServiceImpl(logger *zap.SugaredLogger, appStatusService appStatus.AppStatusService, argoApplicationService argoApplication2.ArgoApplicationService, cdApplicationStatusUpdateHandler cron.CdApplicationStatusUpdateHandler, - helmAppClient gRPC.HelmAppClient, helmAppReadService read.HelmAppReadService, + helmAppService service.HelmAppService, k8sApplicationService application2.K8sApplicationService, k8sCommonService k8s.K8sCommonService) *ServiceImpl { serviceImpl := &ServiceImpl{ @@ -79,8 +80,8 @@ func NewServiceImpl(logger *zap.SugaredLogger, appStatusService: appStatusService, argoApplicationService: argoApplicationService, cdApplicationStatusUpdateHandler: cdApplicationStatusUpdateHandler, - helmAppClient: helmAppClient, helmAppReadService: helmAppReadService, + helmAppService: helmAppService, k8sApplicationService: k8sApplicationService, k8sCommonService: k8sCommonService, } @@ -181,16 +182,12 @@ func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId resourceTree = impl.k8sCommonService.PortNumberExtraction(respManifest, resourceTree) } else if len(cdPipeline.DeploymentAppName) > 0 && cdPipeline.EnvironmentId > 0 && util.IsHelmApp(deploymentConfig.DeploymentAppType) { - config, err := impl.helmAppReadService.GetClusterConf(cdPipeline.Environment.ClusterId) - if err != nil { - impl.logger.Errorw("error in fetching cluster detail", "err", err) - } - req := &gRPC.AppDetailRequest{ - ClusterConfig: config, - Namespace: cdPipeline.Environment.Namespace, - ReleaseName: cdPipeline.DeploymentAppName, + req := &bean.AppIdentifier{ + ClusterId: cdPipeline.Environment.ClusterId, + Namespace: cdPipeline.Environment.Namespace, + ReleaseName: cdPipeline.DeploymentAppName, } - detail, err := impl.helmAppClient.GetAppDetail(context.Background(), req) + detail, err := impl.helmAppService.GetApplicationDetail(context.Background(), req) if err != nil { impl.logger.Errorw("error in fetching app detail", "err", err) } From 1328df4b9b159829439fe82f472d583b35a133ed Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 17:33:04 +0530 Subject: [PATCH 12/23] oss/ent --- api/helm-app/service/HelmAppService.go | 27 +++++++++++++++------- api/helm-app/service/HelmAppService_ent.go | 8 +++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/api/helm-app/service/HelmAppService.go b/api/helm-app/service/HelmAppService.go index d62036d322..2f790f6b10 100644 --- a/api/helm-app/service/HelmAppService.go +++ b/api/helm-app/service/HelmAppService.go @@ -246,7 +246,7 @@ func (impl *HelmAppServiceImpl) UnHibernateApplication(ctx context.Context, app } func (impl *HelmAppServiceImpl) GetApplicationDetail(ctx context.Context, app *helmBean.AppIdentifier) (*gRPC.AppDetail, error) { - return impl.getApplicationDetail(ctx, app, nil) + return impl.getApplicationDetailWithInstallerStatus(ctx, app, nil) } func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Context, app *helmBean.AppIdentifier) (*gRPC.AppStatus, error) { @@ -254,10 +254,10 @@ func (impl *HelmAppServiceImpl) GetApplicationAndReleaseStatus(ctx context.Conte } func (impl *HelmAppServiceImpl) GetApplicationDetailWithFilter(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { - return impl.getApplicationDetail(ctx, app, resourceTreeFilter) + return impl.getApplicationDetailWithInstallerStatus(ctx, app, resourceTreeFilter) } -func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { +func (impl *HelmAppServiceImpl) getApplicationDetailWithInstallerStatus(ctx context.Context, app *helmBean.AppIdentifier, resourceTreeFilter *gRPC.ResourceTreeFilter) (*gRPC.AppDetail, error) { config, err := impl.helmAppReadService.GetClusterConf(app.ClusterId) if err != nil { impl.logger.Errorw("error in fetching cluster detail", "err", err) @@ -269,7 +269,7 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *h ReleaseName: app.ReleaseName, ResourceTreeFilter: resourceTreeFilter, } - appdetail, err := impl.helmAppClient.GetAppDetail(ctx, req) + appDetail, err := impl.getAppDetail(ctx, req) if err != nil { impl.logger.Errorw("error in fetching app detail", "err", err) return nil, err @@ -283,14 +283,24 @@ func (impl *HelmAppServiceImpl) getApplicationDetail(ctx context.Context, app *h impl.serverDataStore.InstallerCrdObjectExists { if impl.serverDataStore.InstallerCrdObjectStatus != serverBean.InstallerCrdObjectStatusApplied { // if timeout - if time.Now().After(appdetail.GetLastDeployed().AsTime().Add(1 * time.Hour)) { - appdetail.ApplicationStatus = serverBean.AppHealthStatusDegraded + if time.Now().After(appDetail.GetLastDeployed().AsTime().Add(1 * time.Hour)) { + appDetail.ApplicationStatus = serverBean.AppHealthStatusDegraded } else { - appdetail.ApplicationStatus = serverBean.AppHealthStatusProgressing + appDetail.ApplicationStatus = serverBean.AppHealthStatusProgressing } } } - return appdetail, err + return appDetail, err +} + +func (impl *HelmAppServiceImpl) getAppDetail(ctx context.Context, req *gRPC.AppDetailRequest) (*gRPC.AppDetail, error) { + impl.updateAppDetailRequestWithCacheConfig(req) + appDetail, err := impl.helmAppClient.GetAppDetail(ctx, req) + if err != nil { + impl.logger.Errorw("error in fetching app detail", "payload", req, "err", err) + return nil, err + } + return appDetail, nil } func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context.Context, clusterId int, @@ -310,6 +320,7 @@ func (impl *HelmAppServiceImpl) GetResourceTreeForExternalResources(ctx context. ClusterConfig: config, ExternalResourceDetail: resources, } + impl.updateExternalResTreeRequestWithCacheConfig(clusterId, req) return impl.helmAppClient.GetResourceTreeForExternalResources(ctx, req) } diff --git a/api/helm-app/service/HelmAppService_ent.go b/api/helm-app/service/HelmAppService_ent.go index 9e14356328..f68f40ba23 100644 --- a/api/helm-app/service/HelmAppService_ent.go +++ b/api/helm-app/service/HelmAppService_ent.go @@ -8,3 +8,11 @@ import ( func (impl *HelmAppServiceImpl) GetAppStatusV2(ctx context.Context, req *gRPC.AppDetailRequest, clusterId int) (*gRPC.AppStatus, error) { return nil, nil } + +func (impl *HelmAppServiceImpl) updateAppDetailRequestWithCacheConfig(req *gRPC.AppDetailRequest) { + return +} + +func (impl *HelmAppServiceImpl) updateExternalResTreeRequestWithCacheConfig(clusterId int, req *gRPC.ExternalResourceTreeRequest) { + return +} From 1f916e4f3ed3c76b92d32e0d3749c927060f0a4e Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 17:51:02 +0530 Subject: [PATCH 13/23] minor changes --- api/restHandler/app/appList/AppListingRestHandler.go | 6 +++--- pkg/app/AppListingService.go | 12 ++---------- .../status/resourceTree/ResourceTreeService.go | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 8761580c0e..d262ae81e5 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -46,7 +46,7 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/deployedApp/status/resourceTree" "github.com/devtron-labs/devtron/pkg/deploymentGroup" "github.com/devtron-labs/devtron/pkg/k8s" - application3 "github.com/devtron-labs/devtron/pkg/k8s/application" + k8sApplication "github.com/devtron-labs/devtron/pkg/k8s/application" "github.com/devtron-labs/devtron/pkg/pipeline" bean6 "github.com/devtron-labs/devtron/pkg/team/bean" "github.com/devtron-labs/devtron/util/rbac" @@ -93,7 +93,7 @@ type AppListingRestHandlerImpl struct { installedAppService FullMode.InstalledAppDBExtendedService installedAppResourceService resource.InstalledAppResourceService pipelineRepository pipelineConfig.PipelineRepository - k8sApplicationService application3.K8sApplicationService + k8sApplicationService k8sApplication.K8sApplicationService deploymentConfigService common2.DeploymentConfigService resourceTreeService resourceTree.Service } @@ -121,7 +121,7 @@ func NewAppListingRestHandlerImpl(appListingService app.AppListingService, installedAppService FullMode.InstalledAppDBExtendedService, installedAppResourceService resource.InstalledAppResourceService, pipelineRepository pipelineConfig.PipelineRepository, - k8sApplicationService application3.K8sApplicationService, + k8sApplicationService k8sApplication.K8sApplicationService, deploymentConfigService common2.DeploymentConfigService, resourceTreeService resourceTree.Service) *AppListingRestHandlerImpl { appListingHandler := &AppListingRestHandlerImpl{ diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 8876874ceb..9645f7b964 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -25,7 +25,6 @@ import ( "github.com/devtron-labs/devtron/internal/middleware" "github.com/devtron-labs/devtron/internal/sql/repository/app" "github.com/devtron-labs/devtron/internal/sql/repository/pipelineConfig/bean/workflow/cdWorkflow" - argoApplication2 "github.com/devtron-labs/devtron/pkg/argoApplication" userrepository "github.com/devtron-labs/devtron/pkg/auth/user/repository" ciConfig "github.com/devtron-labs/devtron/pkg/build/pipeline/read" chartRepoRepository "github.com/devtron-labs/devtron/pkg/chartRepo/repository" @@ -33,7 +32,6 @@ import ( "github.com/devtron-labs/devtron/pkg/deployment/manifest/deployedAppMetrics" "github.com/devtron-labs/devtron/pkg/deployment/manifest/deploymentTemplate/read" "github.com/devtron-labs/devtron/pkg/dockerRegistry" - "github.com/devtron-labs/devtron/pkg/k8s" "github.com/devtron-labs/devtron/pkg/pipeline/constants" util2 "github.com/devtron-labs/devtron/util" errors2 "github.com/juju/errors" @@ -149,9 +147,6 @@ type AppListingServiceImpl struct { ciArtifactRepository repository.CiArtifactRepository envConfigOverrideReadService read.EnvConfigOverrideService ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService - - argoApplicationService argoApplication2.ArgoApplicationService - k8sCommonService k8s.K8sCommonService } func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository repository.AppListingRepository, @@ -163,9 +158,7 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re dockerRegistryIpsConfigService dockerRegistry.DockerRegistryIpsConfigService, userRepository userrepository.UserRepository, deployedAppMetricsService deployedAppMetrics.DeployedAppMetricsService, ciArtifactRepository repository.CiArtifactRepository, envConfigOverrideReadService read.EnvConfigOverrideService, - ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService, - argoApplicationService argoApplication2.ArgoApplicationService, - k8sCommonService k8s.K8sCommonService) *AppListingServiceImpl { + ciPipelineConfigReadService ciConfig.CiPipelineConfigReadService) *AppListingServiceImpl { serviceImpl := &AppListingServiceImpl{ Logger: Logger, appListingRepository: appListingRepository, @@ -185,8 +178,6 @@ func NewAppListingServiceImpl(Logger *zap.SugaredLogger, appListingRepository re ciArtifactRepository: ciArtifactRepository, envConfigOverrideReadService: envConfigOverrideReadService, ciPipelineConfigReadService: ciPipelineConfigReadService, - argoApplicationService: argoApplicationService, - k8sCommonService: k8sCommonService, } return serviceImpl } @@ -335,6 +326,7 @@ func (impl AppListingServiceImpl) FetchAllDevtronManagedApps() ([]AppNameTypeIdC } return apps, nil } + func (impl AppListingServiceImpl) FetchJobs(fetchJobListingRequest FetchAppListingRequest) ([]*AppView.JobContainer, error) { jobListingFilter := helper.AppListingFilter{ diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index 29dbbffd15..afaac554e2 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -187,7 +187,7 @@ func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId Namespace: cdPipeline.Environment.Namespace, ReleaseName: cdPipeline.DeploymentAppName, } - detail, err := impl.helmAppService.GetApplicationDetail(context.Background(), req) + detail, err := impl.helmAppService.GetApplicationDetail(ctx, req) if err != nil { impl.logger.Errorw("error in fetching app detail", "err", err) } From eadaccfaccd8d473c793240d3e7874f559c379b4 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 17:54:20 +0530 Subject: [PATCH 14/23] updated log --- .../deployedApp/status/resourceTree/ResourceTreeService.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index afaac554e2..1b10e4a65e 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -189,7 +189,7 @@ func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId } detail, err := impl.helmAppService.GetApplicationDetail(ctx, req) if err != nil { - impl.logger.Errorw("error in fetching app detail", "err", err) + impl.logger.Errorw("error in fetching app detail", "payload", req, "err", err) } if detail != nil && detail.ReleaseExist { resourceTree = util2.InterfaceToMapAdapter(detail.ResourceTreeResponse) From a1ba8d7527a23f59428b4b1cb31702576a5dbe89 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 18:03:49 +0530 Subject: [PATCH 15/23] added ent func --- api/restHandler/app/appList/AppListingRestHandler.go | 6 ++++++ api/restHandler/app/appList/AppListingRestHandler_ent.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index d262ae81e5..2b0739e4e1 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -491,6 +491,12 @@ func (handler AppListingRestHandlerImpl) FetchAppDetailsV2(w http.ResponseWriter common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) return } + + err = handler.updateApprovalConfigDataInAppDetailResp(appDetail, appId, envId) + if err != nil { + common.WriteJsonResp(w, err, nil, http.StatusInternalServerError) + return + } common.WriteJsonResp(w, err, appDetail, http.StatusOK) } diff --git a/api/restHandler/app/appList/AppListingRestHandler_ent.go b/api/restHandler/app/appList/AppListingRestHandler_ent.go index e923552619..e209c5b52a 100644 --- a/api/restHandler/app/appList/AppListingRestHandler_ent.go +++ b/api/restHandler/app/appList/AppListingRestHandler_ent.go @@ -1,6 +1,7 @@ package appList import ( + "github.com/devtron-labs/devtron/api/bean/AppView" "net/http" ) @@ -12,3 +13,7 @@ func (handler AppListingRestHandlerImpl) FetchAutocompleteJobCiPipelines(w http. func (handler AppListingRestHandlerImpl) GetAllAppEnvsFromResourceNames(w http.ResponseWriter, r *http.Request) { } + +func (handler AppListingRestHandlerImpl) updateApprovalConfigDataInAppDetailResp(appDetail AppView.AppDetailContainer, appId, envId int) error { + return nil +} From ffef7f9826b921b667908d3b0f672c678b165760 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 19:04:32 +0530 Subject: [PATCH 16/23] added pointer in receiver --- .../deployedApp/status/resourceTree/ResourceTreeService.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go index 1b10e4a65e..14046cebbf 100644 --- a/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go +++ b/pkg/deployment/deployedApp/status/resourceTree/ResourceTreeService.go @@ -88,7 +88,7 @@ func NewServiceImpl(logger *zap.SugaredLogger, return serviceImpl } -func (impl ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, +func (impl *ServiceImpl) FetchResourceTree(ctx context.Context, appId int, envId int, cdPipeline *pipelineConfig.Pipeline, deploymentConfig *commonBean.DeploymentConfig) (map[string]interface{}, error) { var resourceTree map[string]interface{} if !cdPipeline.DeploymentAppCreated { From d4146027e6d0322814b66a8ad5b9569a4f0f1e4c Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 20:02:48 +0530 Subject: [PATCH 17/23] return statement --- api/restHandler/app/appList/AppListingRestHandler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/restHandler/app/appList/AppListingRestHandler.go b/api/restHandler/app/appList/AppListingRestHandler.go index 2b0739e4e1..b0610ba22d 100644 --- a/api/restHandler/app/appList/AppListingRestHandler.go +++ b/api/restHandler/app/appList/AppListingRestHandler.go @@ -358,6 +358,7 @@ func (handler AppListingRestHandlerImpl) FetchAppsByEnvironmentV2(w http.Respons if err != nil { handler.logger.Errorw("service err, FetchAppsByEnvironment", "err", err, "payload", fetchAppListingRequest) common.WriteJsonResp(w, err, "", http.StatusInternalServerError) + return } t2 := time.Now() From d7713a440dba22e413f0ebf5a15134068e40b88b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Wed, 8 Jan 2025 23:18:37 +0530 Subject: [PATCH 18/23] wip --- .../sql/repository/AppListingRepository.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index cb5584beef..531af804a1 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -150,15 +150,15 @@ func (impl AppListingRepositoryImpl) FetchOverviewCiPipelines(jobId int) ([]*App } func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit, offset int) ([]*AppView.AppEnvironmentContainer, error) { - query := " SELECT a.id as app_id,a.app_name,aps.status as app_status, ld.last_deployed_time " + - " FROM app a " + - " INNER JOIN pipeline p ON p.app_id = a.id and p.deleted = false and p.environment_id = ? " + - " LEFT JOIN app_status aps ON aps.app_id = a.id and aps.env_id = ? " + - " LEFT JOIN " + - " (SELECT pco.pipeline_id,MAX(pco.created_on) as last_deployed_time from pipeline_config_override pco " + - " GROUP BY pco.pipeline_id) ld ON ld.pipeline_id = p.id " + - " WHERE a.active = true " + - " ORDER BY a.app_name " + query := ` SELECT a.id as app_id,a.app_name,aps.status as app_status, ld.last_deployed_time, p.id as pipeline_id + FROM app a + INNER JOIN pipeline p ON p.app_id = a.id and p.deleted = false and p.environment_id = ? + LEFT JOIN app_status aps ON aps.app_id = a.id and aps.env_id = ? + LEFT JOIN + (SELECT pco.pipeline_id,MAX(pco.created_on) as last_deployed_time from pipeline_config_override pco + GROUP BY pco.pipeline_id) ld ON ld.pipeline_id = p.id + WHERE a.active = true + ORDER BY a.app_name ` if limit > 0 { query += fmt.Sprintf("LIMIT %v", limit) } From 1e32846bf7b05953629be4ce059e540be3288e0b Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 10 Jan 2025 10:10:13 +0530 Subject: [PATCH 19/23] erview comments --- internal/sql/repository/AppListingRepository.go | 3 +++ pkg/app/AppListingService.go | 4 ++-- .../service/FullMode/resource/ResourceTreeService.go | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 531af804a1..3eacff96a4 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -159,11 +159,14 @@ func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit GROUP BY pco.pipeline_id) ld ON ld.pipeline_id = p.id WHERE a.active = true ORDER BY a.app_name ` + queryParams := []interface{}{envId, envId} if limit > 0 { query += fmt.Sprintf("LIMIT %v", limit) + queryParams = append(queryParams, limit) } if offset > 0 { query += fmt.Sprintf("OFFSET %v", offset) + queryParams = append(queryParams, offset) } var envContainers []*AppView.AppEnvironmentContainer _, err := impl.dbConnection.Query(&envContainers, query, envId, envId) diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 9645f7b964..6231518d9b 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -243,7 +243,7 @@ func (impl AppListingServiceImpl) FetchOverviewAppsByEnvironment(envId, limit, o err = impl.updateAppStatusForHelmTypePipelines(envContainers) if err != nil { - impl.Logger.Errorw("err, updateAppStatusForHelmTypePipelines", "err", err) + impl.Logger.Errorw("err, updateAppStatusForHelmTypePipelines", "envId", envId, "err", err) return resp, err } @@ -421,7 +421,7 @@ func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingReques } err = impl.updateAppStatusForHelmTypePipelines(envContainers) if err != nil { - impl.Logger.Errorw("error, UpdateAppStatusForHelmTypePipelines", "err", err) + impl.Logger.Errorw("error, UpdateAppStatusForHelmTypePipelines", "envIds", envIds, "err", err) return []*AppView.AppEnvironmentContainer{}, appSize, err } return envContainers, appSize, nil diff --git a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go index 6cb3d8dd16..a2bad6fab6 100644 --- a/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go +++ b/pkg/appStore/installedApp/service/FullMode/resource/ResourceTreeService.go @@ -275,7 +275,7 @@ func (impl *InstalledAppResourceServiceImpl) fetchResourceTreeForACD(rctx contex validRequest := impl.k8sCommonService.FilterK8sResources(rctx, resourceTree, k8sAppDetail, clusterIdString, []string{commonBean.ServiceKind, commonBean.EndpointsKind, commonBean.IngressKind}, "") response, err := impl.k8sCommonService.GetManifestsByBatch(rctx, validRequest) if err != nil { - impl.logger.Errorw("error in getting manifest by batch", "err", err, "clusterId", clusterIdString) + impl.logger.Errorw("error in getting manifest by batch", "clusterId", clusterIdString, "err", err) return nil, err } newResourceTree := impl.k8sCommonService.PortNumberExtraction(response, resourceTree) From 940bc2f0b6a5967e45dc95fb325a8cafe841c7fa Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 10 Jan 2025 10:11:39 +0530 Subject: [PATCH 20/23] review comments --- pkg/app/AppListingService.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/app/AppListingService.go b/pkg/app/AppListingService.go index 6231518d9b..abd25e5d75 100644 --- a/pkg/app/AppListingService.go +++ b/pkg/app/AppListingService.go @@ -422,7 +422,6 @@ func (impl AppListingServiceImpl) FetchAppsByEnvironmentV2(fetchAppListingReques err = impl.updateAppStatusForHelmTypePipelines(envContainers) if err != nil { impl.Logger.Errorw("error, UpdateAppStatusForHelmTypePipelines", "envIds", envIds, "err", err) - return []*AppView.AppEnvironmentContainer{}, appSize, err } return envContainers, appSize, nil } From c6f8cca07f9096c6516156fb36dca7b3298fdfa6 Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 10 Jan 2025 10:13:29 +0530 Subject: [PATCH 21/23] wip --- internal/sql/repository/AppListingRepository.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 3eacff96a4..2d2aa4f7c4 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -169,7 +169,7 @@ func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit queryParams = append(queryParams, offset) } var envContainers []*AppView.AppEnvironmentContainer - _, err := impl.dbConnection.Query(&envContainers, query, envId, envId) + _, err := impl.dbConnection.Query(&envContainers, query, queryParams...) return envContainers, err } From c472b6e37cbd941d47a1c80e8cf8bc03dfbf3e0d Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 10 Jan 2025 10:32:07 +0530 Subject: [PATCH 22/23] wip --- internal/sql/repository/AppListingRepository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 2d2aa4f7c4..29b5c302c9 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -161,11 +161,11 @@ func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit ORDER BY a.app_name ` queryParams := []interface{}{envId, envId} if limit > 0 { - query += fmt.Sprintf("LIMIT %v", limit) + query += fmt.Sprintf("LIMIT ?") queryParams = append(queryParams, limit) } if offset > 0 { - query += fmt.Sprintf("OFFSET %v", offset) + query += fmt.Sprintf("OFFSET ?") queryParams = append(queryParams, offset) } var envContainers []*AppView.AppEnvironmentContainer From 384a769d63e42896e8ccedd85b3686f10812adfd Mon Sep 17 00:00:00 2001 From: kartik-579 Date: Fri, 10 Jan 2025 10:53:45 +0530 Subject: [PATCH 23/23] query update --- internal/sql/repository/AppListingRepository.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/sql/repository/AppListingRepository.go b/internal/sql/repository/AppListingRepository.go index 29b5c302c9..864f87921e 100644 --- a/internal/sql/repository/AppListingRepository.go +++ b/internal/sql/repository/AppListingRepository.go @@ -161,11 +161,11 @@ func (impl AppListingRepositoryImpl) FetchOverviewAppsByEnvironment(envId, limit ORDER BY a.app_name ` queryParams := []interface{}{envId, envId} if limit > 0 { - query += fmt.Sprintf("LIMIT ?") + query += fmt.Sprintf("LIMIT ? ") queryParams = append(queryParams, limit) } if offset > 0 { - query += fmt.Sprintf("OFFSET ?") + query += fmt.Sprintf("OFFSET ? ") queryParams = append(queryParams, offset) } var envContainers []*AppView.AppEnvironmentContainer