Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ext argo app rbac and missing common features and flux app listing and details with rbac #5528

Merged
merged 79 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
57e2b33
app list logic completed and proto is yet to generate
Jun 5, 2024
6852607
resolved the proto file issue
RajeevRanjan27 Jun 5, 2024
71dbc35
modified the proto and go routine call handling
RajeevRanjan27 Jun 5, 2024
8e74bfd
corrected the proto file datatype changes
RajeevRanjan27 Jun 5, 2024
8a8f760
applied the list of flux apps in given cluster
Jun 5, 2024
ae6f68a
resolved the conversations
Jun 5, 2024
3bf74dd
incorporated the review changes
Jun 5, 2024
27a0d9b
modified the fluxhandler and handlled the errros
Jun 6, 2024
668a1ad
resolved the coversations
Jun 6, 2024
5f3a04b
implemented the flush for streaming the data to client
Jun 7, 2024
41ee5d5
resolve the conflicts
Jun 7, 2024
53dc30a
incorporated comments
Jun 10, 2024
7d71b8c
Merge branch 'main' into flux-app-list
Jun 10, 2024
6137d5c
Added the spec file for fluxcd App listing
Jun 11, 2024
60fc2e2
Merge branch 'main' into flux-app-list
Jun 11, 2024
693ad55
Merge branch 'main' into flux-app-list
Jun 12, 2024
eb3befc
added the app type in the struct
RajeevRanjan27 Jun 13, 2024
87f0611
changed the fluxAppType data type
RajeevRanjan27 Jun 13, 2024
8f8b4a9
resolve
RajeevRanjan27 Jun 13, 2024
78df27f
resolve
RajeevRanjan27 Jun 13, 2024
80251ff
redefined the query params to process with
RajeevRanjan27 Jun 17, 2024
0c24d05
specs for flux app list added
RajeevRanjan27 Jun 17, 2024
134e08c
Merge branch 'main' into flux-app-list
RajeevRanjan27 Jun 17, 2024
3184637
Merge branch 'flux-app-list' into flux-app-detail
RajeevRanjan27 Jun 18, 2024
560a344
added the flux app detail
RajeevRanjan27 Jun 18, 2024
77db907
minor changes around the app listing response
RajeevRanjan27 Jun 18, 2024
74d47b5
Resolved the decoder appId function
RajeevRanjan27 Jun 19, 2024
4fb9e37
Added the spec for the app detail api
RajeevRanjan27 Jun 19, 2024
c82fa28
changed the field of flux app detail dto
RajeevRanjan27 Jun 25, 2024
9a855a6
taken merge from flux-app-list
RajeevRanjan27 Jun 25, 2024
a345b10
taken merge from main and grpc code resolved
RajeevRanjan27 Jun 25, 2024
252d199
taken merge from main and wire run
RajeevRanjan27 Jun 25, 2024
a8cd9b7
Added the rbac for the list Events and resource Deletion
RajeevRanjan27 Jun 26, 2024
df08766
handled the error in listing of apps with errror field in grpc
RajeevRanjan27 Jun 27, 2024
4c23e11
Revert "taken merge from main and wire run"
RajeevRanjan27 Jun 27, 2024
9b09b56
Revert "handled the error in listing of apps with errror field in grpc"
RajeevRanjan27 Jul 1, 2024
24abc12
Added the error in the Listing of flux apps
RajeevRanjan27 Jul 1, 2024
b9106bf
Merge remote-tracking branch 'origin/flux-app-detail' into flux-app-d…
RajeevRanjan27 Jul 1, 2024
31148ad
generated the grpc code
RajeevRanjan27 Jul 1, 2024
efd2814
modified the logic for error handling in flux app listing and app det…
RajeevRanjan27 Jul 1, 2024
4e19367
Merge branch 'main' into flux-app-detail
RajeevRanjan27 Jul 1, 2024
5db5e18
took merge from main and run make
RajeevRanjan27 Jul 1, 2024
0eaf481
added the handler message for the root app i.e flux-system
RajeevRanjan27 Jul 1, 2024
f67d3d6
Merge branch 'flux-app-detail' into flux-app-events
RajeevRanjan27 Jul 2, 2024
db84941
added the rbac for update of resources
RajeevRanjan27 Jul 2, 2024
7c03c65
minor changes: resolved the review comments after review
RajeevRanjan27 Jul 2, 2024
396c9d8
Merge branch 'flux-app-detail' into flux-app-events
RajeevRanjan27 Jul 4, 2024
7726cdf
Merge branch 'main' into flux-app-detail
RajeevRanjan27 Jul 4, 2024
90982a9
took merge from main and executed the make cmd too
RajeevRanjan27 Jul 4, 2024
891a43d
added the debugger points in the flux app listing
RajeevRanjan27 Jul 5, 2024
3c49408
completed rbac for list events, get resources, getTerminalSession,upd…
RajeevRanjan27 Jul 8, 2024
8883d75
Merge branch 'flux-app-detail' into flux-app-events
RajeevRanjan27 Jul 8, 2024
b12d7d1
removed the debugger points
RajeevRanjan27 Jul 8, 2024
b93a532
resolved the comment and incorporated the changes
RajeevRanjan27 Jul 9, 2024
760ec41
modified the verifyRbacForAppRequests function
RajeevRanjan27 Jul 9, 2024
a1c652e
Added the hibernate and unhibernate function for flux
RajeevRanjan27 Jul 9, 2024
22756a8
added the constants for making the redundency less
RajeevRanjan27 Jul 9, 2024
a488c9d
refactor the unhibernate code part
RajeevRanjan27 Jul 9, 2024
4768b34
removed the previous coded comments
RajeevRanjan27 Jul 9, 2024
748da5d
Merge branch 'main' into flux-added-feats
RajeevRanjan27 Jul 9, 2024
1fc0b49
resolved minor changes from comments
RajeevRanjan27 Jul 9, 2024
1099894
added the rbac for podLogs and k8sresourceurls
RajeevRanjan27 Jul 11, 2024
1fc7d5d
added some rbac for the external argo with validation of resources
RajeevRanjan27 Jul 16, 2024
11a8519
added the handling of resource urls and hibernation
RajeevRanjan27 Jul 18, 2024
28e0df6
added the ea part of ext argo and also made changes in the k8shandlers
RajeevRanjan27 Jul 18, 2024
3c2a7e7
resolve the conflicts
RajeevRanjan27 Jul 18, 2024
dc1a449
executed make after merging
RajeevRanjan27 Jul 18, 2024
67cb012
resolved the comments and removed the commented codes
RajeevRanjan27 Jul 24, 2024
205765f
merge and resolved the conflicts
RajeevRanjan27 Jul 31, 2024
3a7987f
added the ea mode router of flux
RajeevRanjan27 Jul 31, 2024
c694714
Merge branch 'main' into feat-ext-argo-app-rbac
RajeevRanjan27 Aug 2, 2024
cd0953d
modified the request for external argo during terminal session connect
RajeevRanjan27 Aug 2, 2024
5cfc651
took sync from main branch
RajeevRanjan27 Aug 6, 2024
a89b33d
executed the make after sync from main
RajeevRanjan27 Aug 6, 2024
3efc1fc
Merge branch 'main' into feat-ext-argo-app-rbac
RajeevRanjan27 Aug 9, 2024
46bd806
took merge from main and executed make
RajeevRanjan27 Aug 9, 2024
22ce422
Merge branch 'main' into feat-ext-argo-app-rbac
RajeevRanjan27 Aug 9, 2024
2ac6837
resolved comments
RajeevRanjan27 Aug 9, 2024
7a48b33
after resolving comments executed make
RajeevRanjan27 Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/devtron-labs/devtron/api/deployment"
"github.com/devtron-labs/devtron/api/devtronResource"
"github.com/devtron-labs/devtron/api/externalLink"
fluxApplication "github.com/devtron-labs/devtron/api/fluxApplication"
client "github.com/devtron-labs/devtron/api/helm-app"
"github.com/devtron-labs/devtron/api/infraConfig"
"github.com/devtron-labs/devtron/api/k8s"
Expand Down Expand Up @@ -200,7 +201,7 @@ func InitializeApp() (*App, error) {
build.BuildWireSet,
deployment2.DeploymentWireSet,
argoApplication.ArgoApplicationWireSet,

fluxApplication.FluxApplicationWireSet,
eventProcessor.EventProcessorWireSet,
workflow3.WorkflowWireSet,

Expand Down
94 changes: 94 additions & 0 deletions api/fluxApplication/FluxApplicationRestHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package fluxApplication

import (
"errors"
"github.com/devtron-labs/devtron/api/restHandler/common"
"github.com/devtron-labs/devtron/pkg/auth/authorisation/casbin"
clientErrors "github.com/devtron-labs/devtron/pkg/errors"
"github.com/devtron-labs/devtron/pkg/fluxApplication"
"github.com/gorilla/mux"
"go.uber.org/zap"
"net/http"
)

type FluxApplicationRestHandler interface {
ListFluxApplications(w http.ResponseWriter, r *http.Request)
GetApplicationDetail(w http.ResponseWriter, r *http.Request)
}

type FluxApplicationRestHandlerImpl struct {
fluxApplicationService fluxApplication.FluxApplicationService
logger *zap.SugaredLogger
enforcer casbin.Enforcer
}

func NewFluxApplicationRestHandlerImpl(fluxApplicationService fluxApplication.FluxApplicationService,
logger *zap.SugaredLogger, enforcer casbin.Enforcer) *FluxApplicationRestHandlerImpl {
return &FluxApplicationRestHandlerImpl{
fluxApplicationService: fluxApplicationService,
logger: logger,
enforcer: enforcer,
}

}

func (handler *FluxApplicationRestHandlerImpl) ListFluxApplications(w http.ResponseWriter, r *http.Request) {

//handle super-admin RBAC
token := r.Header.Get("token")
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
return
}
v := r.URL.Query()
clusterIdString := v.Get("clusterIds")
var clusterIds []int
var err error

//handling when the clusterIds string is empty ,it will not support the
if len(clusterIdString) == 0 {
handler.logger.Errorw("error in getting cluster ids", "error", err, "clusterIds", clusterIds)
common.WriteJsonResp(w, errors.New("error in getting cluster ids"), nil, http.StatusBadRequest)
return
}
clusterIds, err = common.ExtractIntArrayQueryParam(w, r, "clusterIds")
if err != nil {
handler.logger.Errorw("error in parsing cluster ids", "error", err, "clusterIds", clusterIds)
return
}
handler.logger.Debugw("extracted ClusterIds successfully ", "clusterIds", clusterIds)
handler.fluxApplicationService.ListFluxApplications(r.Context(), clusterIds, w)
}

func (handler *FluxApplicationRestHandlerImpl) GetApplicationDetail(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
appIdString := vars["appId"]
appIdentifier, err := fluxApplication.DecodeFluxExternalAppId(appIdString)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
if appIdentifier.IsKustomizeApp == true && appIdentifier.Name == "flux-system" && appIdentifier.Namespace == "flux-system" {

common.WriteJsonResp(w, errors.New("cannot proceed for the flux system root level "), nil, http.StatusBadRequest)
return
}

// handle super-admin RBAC
token := r.Header.Get("token")
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
return
}

res, err := handler.fluxApplicationService.GetFluxAppDetail(r.Context(), appIdentifier)
if err != nil {
apiError := clientErrors.ConvertToApiError(err)
if apiError != nil {
err = apiError
}
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
common.WriteJsonResp(w, err, res, http.StatusOK)
}
27 changes: 27 additions & 0 deletions api/fluxApplication/FluxApplicationRouter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package fluxApplication

import (
"github.com/gorilla/mux"
)

type FluxApplicationRouter interface {
InitFluxApplicationRouter(fluxApplicationRouter *mux.Router)
}

type FluxApplicationRouterImpl struct {
fluxApplicationRestHandler FluxApplicationRestHandler
}

func NewFluxApplicationRouterImpl(fluxApplicationRestHandler FluxApplicationRestHandler) *FluxApplicationRouterImpl {
return &FluxApplicationRouterImpl{
fluxApplicationRestHandler: fluxApplicationRestHandler,
}
}

func (impl *FluxApplicationRouterImpl) InitFluxApplicationRouter(fluxApplicationRouter *mux.Router) {
fluxApplicationRouter.Path("").
Methods("GET").
HandlerFunc(impl.fluxApplicationRestHandler.ListFluxApplications)
fluxApplicationRouter.Path("/app").Queries("appId", "{appId}").
HandlerFunc(impl.fluxApplicationRestHandler.GetApplicationDetail).Methods("GET")
}
17 changes: 17 additions & 0 deletions api/fluxApplication/wire_fluxApplication.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package fluxApplication

import (
"github.com/devtron-labs/devtron/pkg/fluxApplication"
"github.com/google/wire"
)

var FluxApplicationWireSet = wire.NewSet(
fluxApplication.NewFluxApplicationServiceImpl,
wire.Bind(new(fluxApplication.FluxApplicationService), new(*fluxApplication.FluxApplicationServiceImpl)),

NewFluxApplicationRestHandlerImpl,
wire.Bind(new(FluxApplicationRestHandler), new(*FluxApplicationRestHandlerImpl)),

NewFluxApplicationRouterImpl,
wire.Bind(new(FluxApplicationRouter), new(*FluxApplicationRouterImpl)),
)
Loading
Loading