Skip to content

Commit e1cc5d3

Browse files
committed
Merge branch 'develop' into config-diff-3-oss
2 parents fba905e + 9b7b568 commit e1cc5d3

File tree

65 files changed

+1692
-713
lines changed

Some content is hidden

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

65 files changed

+1692
-713
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN apt install git gcc musl-dev make -y
66
RUN go install github.com/google/wire/cmd/wire@latest
77
WORKDIR /go/src/github.com/devtron-labs/devtron
88
ADD . /go/src/github.com/devtron-labs/devtron/
9+
ADD ./vendor/github.com/Microsoft/ /go/src/github.com/devtron-labs/devtron/vendor/github.com/microsoft/
910
RUN GOOS=linux make build-all
1011

1112
# uncomment this post build arg

DockerfileEA

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN apt install git gcc musl-dev make -y
66
RUN go install github.com/google/wire/cmd/wire@latest
77
WORKDIR /go/src/github.com/devtron-labs/devtron
88
ADD . /go/src/github.com/devtron-labs/devtron/
9+
ADD ./vendor/github.com/Microsoft/ /go/src/github.com/devtron-labs/devtron/vendor/github.com/microsoft/
910
RUN GOOS=linux make build-all
1011

1112
FROM ubuntu:22.04@sha256:1b8d8ff4777f36f19bfe73ee4df61e3a0b789caeff29caa019539ec7c9a57f95 as devtron-ea

Wire.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func InitializeApp() (*App, error) {
202202
terminal.TerminalWireSet,
203203
build.BuildWireSet,
204204
deployment2.DeploymentWireSet,
205-
argoApplication.ArgoApplicationWireSet,
205+
argoApplication.ArgoApplicationWireSetFull,
206206
fluxApplication.FluxApplicationWireSet,
207207
eventProcessor.EventProcessorWireSet,
208208
workflow3.WorkflowWireSet,

api/appStore/AppStoreRouter.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ func (router AppStoreRouterImpl) Init(configRouter *mux.Router) {
8383
HandlerFunc(router.deployRestHandler.CheckAppExists).Methods("POST")
8484
configRouter.Path("/group/install").
8585
HandlerFunc(router.deployRestHandler.DeployBulk).Methods("POST")
86-
configRouter.Path("/installed-app/detail").Queries("installed-app-id", "{installed-app-id}").Queries("env-id", "{env-id}").
87-
HandlerFunc(router.deployRestHandler.FetchAppDetailsForInstalledApp).
88-
Methods("GET")
8986
configRouter.Path("/installed-app/delete/{installedAppId}/non-cascade").
9087
HandlerFunc(router.deployRestHandler.DeleteArgoInstalledAppWithNonCascade).
9188
Methods("DELETE")

api/appStore/InstalledAppRestHandler.go

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import (
4949
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
5050
"github.com/devtron-labs/devtron/pkg/auth/user"
5151
"github.com/devtron-labs/devtron/pkg/cluster"
52-
bean3 "github.com/devtron-labs/devtron/pkg/deployment/common/bean"
5352
"github.com/devtron-labs/devtron/util"
5453
"github.com/devtron-labs/devtron/util/argo"
5554
"github.com/devtron-labs/devtron/util/rbac"
@@ -65,7 +64,6 @@ type InstalledAppRestHandler interface {
6564
DeployBulk(w http.ResponseWriter, r *http.Request)
6665
CheckAppExists(w http.ResponseWriter, r *http.Request)
6766
DefaultComponentInstallation(w http.ResponseWriter, r *http.Request)
68-
FetchAppDetailsForInstalledApp(w http.ResponseWriter, r *http.Request)
6967
DeleteArgoInstalledAppWithNonCascade(w http.ResponseWriter, r *http.Request)
7068
FetchAppDetailsForInstalledAppV2(w http.ResponseWriter, r *http.Request)
7169
FetchResourceTree(w http.ResponseWriter, r *http.Request)
@@ -692,90 +690,6 @@ func (handler *InstalledAppRestHandlerImpl) checkNotesAuth(token string, appName
692690
return ok
693691
}
694692

695-
func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledApp(w http.ResponseWriter, r *http.Request) {
696-
userId, err := handler.userAuthService.GetLoggedInUser(r)
697-
if userId == 0 || err != nil {
698-
common.WriteJsonResp(w, err, nil, http.StatusUnauthorized)
699-
return
700-
}
701-
702-
vars := mux.Vars(r)
703-
installedAppId, err := strconv.Atoi(vars["installed-app-id"])
704-
if err != nil {
705-
handler.Logger.Errorw("request err, FetchAppDetailsForInstalledApp", "err", err, "installedAppId", installedAppId)
706-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
707-
return
708-
}
709-
token := r.Header.Get("token")
710-
envId, err := strconv.Atoi(vars["env-id"])
711-
if err != nil {
712-
handler.Logger.Errorw("request err, FetchAppDetailsForInstalledApp", "err", err, "installedAppId", installedAppId, "envId", envId)
713-
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
714-
return
715-
}
716-
handler.Logger.Infow("request payload, FetchAppDetailsForInstalledApp, app store", "installedAppId", installedAppId, "envId", envId)
717-
718-
installedApp, err := handler.installedAppService.GetInstalledAppById(installedAppId)
719-
if err == pg.ErrNoRows {
720-
common.WriteJsonResp(w, err, "App not found in database", http.StatusBadRequest)
721-
return
722-
}
723-
if util3.IsExternalChartStoreApp(installedApp.App.DisplayName) {
724-
//this is external app case where app_name is a unique identifier, and we want to fetch resource based on display_name
725-
handler.installedAppService.ChangeAppNameToDisplayNameForInstalledApp(installedApp)
726-
}
727-
728-
appDetail, err := handler.installedAppService.FindAppDetailsForAppstoreApplication(installedAppId, envId)
729-
if err != nil {
730-
handler.Logger.Errorw("service err, FetchAppDetailsForInstalledApp, app store", "err", err, "installedAppId", installedAppId, "envId", envId)
731-
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
732-
return
733-
}
734-
735-
//rbac block starts from here
736-
object, object2 := handler.enforcerUtil.GetHelmObjectByAppNameAndEnvId(appDetail.AppName, appDetail.EnvironmentId)
737-
738-
var ok bool
739-
740-
if object2 == "" {
741-
ok = handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionGet, object)
742-
} else {
743-
ok = handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionGet, object) || handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionGet, object2)
744-
}
745-
746-
if !ok {
747-
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), nil, http.StatusForbidden)
748-
return
749-
}
750-
//rback block ends here
751-
resourceTreeAndNotesContainer := bean2.AppDetailsContainer{}
752-
resourceTreeAndNotesContainer.ResourceTree = map[string]interface{}{}
753-
754-
if len(installedApp.App.AppName) > 0 && len(installedApp.Environment.Name) > 0 {
755-
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig, "", "")
756-
if appDetail.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
757-
apiError, ok := err.(*util2.ApiError)
758-
if ok && apiError != nil {
759-
if apiError.Code == constants.AppDetailResourceTreeNotFound && installedApp.DeploymentAppDeleteRequest == true {
760-
// TODO refactoring: should be performed through nats
761-
err = handler.appStoreDeploymentService.MarkGitOpsInstalledAppsDeletedIfArgoAppIsDeleted(installedAppId, envId)
762-
appDeleteErr, appDeleteErrOk := err.(*util2.ApiError)
763-
if appDeleteErrOk && appDeleteErr != nil {
764-
handler.Logger.Errorw(appDeleteErr.InternalMessage)
765-
return
766-
}
767-
}
768-
}
769-
} else if err != nil {
770-
common.WriteJsonResp(w, fmt.Errorf("error in fetching resource tree"), nil, http.StatusInternalServerError)
771-
return
772-
}
773-
}
774-
appDetail.ResourceTree = resourceTreeAndNotesContainer.ResourceTree
775-
appDetail.Notes = resourceTreeAndNotesContainer.Notes
776-
common.WriteJsonResp(w, nil, appDetail, http.StatusOK)
777-
}
778-
779693
func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledAppV2(w http.ResponseWriter, r *http.Request) {
780694
userId, err := handler.userAuthService.GetLoggedInUser(r)
781695
if userId == 0 || err != nil {
@@ -820,6 +734,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchAppDetailsForInstalledAppV2(w h
820734
}
821735

822736
func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWriter, r *http.Request) {
737+
token := r.Header.Get("token")
738+
ctx := context.WithValue(r.Context(), "token", token)
823739
userId, err := handler.userAuthService.GetLoggedInUser(r)
824740
if userId == 0 || err != nil {
825741
common.WriteJsonResp(w, err, nil, http.StatusUnauthorized)
@@ -853,7 +769,6 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri
853769
common.WriteJsonResp(w, nil, nil, http.StatusOK)
854770
return
855771
}
856-
token := r.Header.Get("token")
857772
object, object2 := handler.enforcerUtil.GetHelmObjectByAppNameAndEnvId(installedApp.App.AppName, installedApp.EnvironmentId)
858773
var ok bool
859774
if object2 == "" {
@@ -876,7 +791,8 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTree(w http.ResponseWri
876791
resourceTreeAndNotesContainer.ResourceTree = map[string]interface{}{}
877792

878793
if len(installedApp.App.AppName) > 0 && len(installedApp.Environment.Name) > 0 {
879-
err = handler.fetchResourceTree(w, r, &resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig, appDetail.HelmReleaseInstallStatus, appDetail.Status)
794+
cn, _ := w.(http.CloseNotifier)
795+
err = handler.installedAppResourceService.FetchResourceTree(ctx, cn, &resourceTreeAndNotesContainer, *installedApp, appDetail.DeploymentConfig, appDetail.HelmReleaseInstallStatus, appDetail.Status)
880796
if appDetail.DeploymentAppType == util2.PIPELINE_DEPLOYMENT_TYPE_ACD {
881797
//resource tree has been fetched now prepare to sync application deployment status with this resource tree call
882798
handler.syncDeploymentStatusWithResourceTreeCall(appDetail)
@@ -968,13 +884,6 @@ func (handler *InstalledAppRestHandlerImpl) FetchResourceTreeForACDApp(w http.Re
968884
common.WriteJsonResp(w, err, appDetail, http.StatusOK)
969885
}
970886

971-
func (handler *InstalledAppRestHandlerImpl) fetchResourceTree(w http.ResponseWriter, r *http.Request, resourceTreeAndNotesContainer *bean2.AppDetailsContainer, installedApp repository.InstalledApps, deploymentConfig *bean3.DeploymentConfig, helmReleaseInstallStatus string, status string) error {
972-
ctx := r.Context()
973-
cn, _ := w.(http.CloseNotifier)
974-
err := handler.installedAppResourceService.FetchResourceTree(ctx, cn, resourceTreeAndNotesContainer, installedApp, deploymentConfig, helmReleaseInstallStatus, status)
975-
return err
976-
}
977-
978887
func (handler *InstalledAppRestHandlerImpl) fetchResourceTreeWithHibernateForACD(w http.ResponseWriter, r *http.Request, appDetail *bean2.AppDetailContainer) {
979888
ctx := r.Context()
980889
cn, _ := w.(http.CloseNotifier)

api/appStore/deployment/CommonDeploymentRestHandler.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ func (handler *CommonDeploymentRestHandlerImpl) getAppOfferingMode(installedAppI
9292
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "invalid app id"}
9393
return appOfferingMode, installedAppDto, err
9494
}
95-
uniqueAppName := appIdentifier.GetUniqueAppNameIdentifier()
96-
installedAppDto, err = handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier.ClusterId, appIdentifier.Namespace, uniqueAppName)
95+
installedAppDto, err = handler.installedAppService.GetInstalledAppByClusterNamespaceAndName(appIdentifier)
9796
if err != nil {
9897
err = &util.ApiError{HttpStatusCode: http.StatusBadRequest, UserMessage: "unable to find app in database"}
9998
return appOfferingMode, installedAppDto, err

api/argoApplication/wire_argoApplication.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,21 @@ import (
2222
"github.com/google/wire"
2323
)
2424

25-
var ArgoApplicationWireSet = wire.NewSet(
25+
var ArgoApplicationWireSetFull = wire.NewSet(
26+
read.NewArgoApplicationReadServiceImpl,
27+
wire.Bind(new(read.ArgoApplicationReadService), new(*read.ArgoApplicationReadServiceImpl)),
28+
29+
argoApplication.NewArgoApplicationServiceExtendedServiceImpl,
30+
wire.Bind(new(argoApplication.ArgoApplicationService), new(*argoApplication.ArgoApplicationServiceExtendedImpl)),
31+
32+
NewArgoApplicationRestHandlerImpl,
33+
wire.Bind(new(ArgoApplicationRestHandler), new(*ArgoApplicationRestHandlerImpl)),
34+
35+
NewArgoApplicationRouterImpl,
36+
wire.Bind(new(ArgoApplicationRouter), new(*ArgoApplicationRouterImpl)),
37+
)
38+
39+
var ArgoApplicationWireSetEA = wire.NewSet(
2640
read.NewArgoApplicationReadServiceImpl,
2741
wire.Bind(new(read.ArgoApplicationReadService), new(*read.ArgoApplicationReadServiceImpl)),
2842

0 commit comments

Comments
 (0)