Skip to content

feat: Flux app detail #5301

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 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
d4e885f
Added the router for flux app detail
Jun 13, 2024
2cb2766
Done with the flux app detail implementation
RajeevRanjan27 Jun 13, 2024
02851f7
modified the structure
RajeevRanjan27 Jun 13, 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
d0dc98c
took merge
RajeevRanjan27 Jun 17, 2024
3a5ccd8
Added the logic again due to some merge issues
RajeevRanjan27 Jun 18, 2024
dceffa9
taken merge from main
RajeevRanjan27 Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
88 changes: 0 additions & 88 deletions CHANGELOG/release-notes-v0.7.0.md

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21 AS build-env
FROM golang:1.20 AS build-env

RUN echo $GOPATH
RUN apt update
Expand Down
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 @@ -191,7 +192,7 @@ func InitializeApp() (*App, error) {
build.BuildWireSet,
deployment2.DeploymentWireSet,
argoApplication.ArgoApplicationWireSet,

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

Expand Down
5 changes: 2 additions & 3 deletions api/auth/user/UserAuthHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (handler UserAuthHandlerImpl) AddDefaultPolicyAndRoles(w http.ResponseWrite

}
func (handler UserAuthHandlerImpl) AuthVerification(w http.ResponseWriter, r *http.Request) {
verified, _, err := handler.userAuthService.AuthVerification(r)
verified, err := handler.userAuthService.AuthVerification(r)
if err != nil {
handler.logger.Errorw("service err, AuthVerification", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand All @@ -253,14 +253,13 @@ func (handler UserAuthHandlerImpl) AuthVerificationV2(w http.ResponseWriter, r *
isSuperAdmin = true
}
response := make(map[string]interface{})
verified, emailId, err := handler.userAuthService.AuthVerification(r)
verified, err := handler.userAuthService.AuthVerification(r)
if err != nil {
handler.logger.Errorw("service err, AuthVerification", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
response["isSuperAdmin"] = isSuperAdmin
response["isVerified"] = verified
response["emailId"] = emailId
common.WriteJsonResp(w, nil, response, http.StatusOK)
}
60 changes: 60 additions & 0 deletions api/fluxApplication/FluxApplicationRestHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package fluxApplication

import (
"context"
"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 {
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) GetApplicationDetail(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
clusterIdString := vars["appId"]
appIdentifier, err := handler.fluxApplicationService.DecodeFluxAppId(clusterIdString)
if err != nil {
common.WriteJsonResp(w, err, 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(context.Background(), 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)
}
24 changes: 24 additions & 0 deletions api/fluxApplication/FluxApplicationRouter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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("/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)),
)
12 changes: 12 additions & 0 deletions api/helm-app/gRPC/applicationClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type HelmAppClient interface {
InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest) (*HelmInstallCustomResponse, error)
GetNotes(ctx context.Context, request *InstallReleaseRequest) (*ChartNotesResponse, error)
ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *RegistryCredential) (*OCIRegistryResponse, error)
GetExternalFluxAppDetail(ctx context.Context, in *FluxAppDetailRequest) (*FluxAppDetail, error)
}

type HelmAppClientImpl struct {
Expand Down Expand Up @@ -359,3 +360,14 @@ func (impl *HelmAppClientImpl) ValidateOCIRegistry(ctx context.Context, in *Regi
}
return response, nil
}
func (impl *HelmAppClientImpl) GetExternalFluxAppDetail(ctx context.Context, in *FluxAppDetailRequest) (*FluxAppDetail, error) {
applicationClient, err := impl.getApplicationClient()
if err != nil {
return nil, err
}
detail, err := applicationClient.GetFluxAppDetail(ctx, in)
if err != nil {
return nil, err
}
return detail, nil
}
Loading
Loading