Skip to content

Commit 874ee33

Browse files
authored
Merge pull request #6467 from devtron-labs/develop-main-sync-24-mar
misc: Merge remote-tracking branch 'main' into develop
2 parents eb7868a + 8625d14 commit 874ee33

File tree

35 files changed

+1855
-3150
lines changed

35 files changed

+1855
-3150
lines changed

api/helm-app/HelmAppRestHandler.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type HelmAppRestHandler interface {
6262
UpdateApplication(w http.ResponseWriter, r *http.Request)
6363
TemplateChart(w http.ResponseWriter, r *http.Request)
6464
SaveHelmAppDetailsViewedTelemetryData(w http.ResponseWriter, r *http.Request)
65+
ListHelmApplicationsForEnvironment(w http.ResponseWriter, r *http.Request)
6566
}
6667

6768
const HELM_APP_ACCESS_COUNTER = "HelmAppAccessCounter"
@@ -588,3 +589,46 @@ func (handler *HelmAppRestHandlerImpl) SaveHelmAppDetailsViewedTelemetryData(w h
588589
common.WriteJsonResp(w, err, nil, http.StatusOK)
589590

590591
}
592+
593+
func (handler *HelmAppRestHandlerImpl) ListHelmApplicationsForEnvironment(w http.ResponseWriter, r *http.Request) {
594+
595+
query := r.URL.Query()
596+
597+
clusterIdString := query.Get("clusterId")
598+
var (
599+
clusterId int
600+
envId int
601+
err error
602+
)
603+
604+
if len(clusterIdString) != 0 {
605+
clusterId, err = strconv.Atoi(clusterIdString)
606+
if err != nil {
607+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
608+
return
609+
}
610+
}
611+
612+
envIdString := query.Get("envId")
613+
if len(envIdString) != 0 {
614+
envId, err = strconv.Atoi(envIdString)
615+
if err != nil {
616+
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
617+
return
618+
}
619+
}
620+
621+
token := r.Header.Get("token")
622+
if ok := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionGet, "*"); !ok {
623+
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
624+
return
625+
}
626+
releaseList, err := handler.helmAppService.ListHelmApplicationsForClusterOrEnv(r.Context(), clusterId, envId)
627+
if err != nil {
628+
handler.logger.Errorw("error in fetching helm release for given env", "err", err)
629+
common.WriteJsonResp(w, err, "error in fetching helm release", http.StatusInternalServerError)
630+
return
631+
}
632+
common.WriteJsonResp(w, nil, releaseList, http.StatusOK)
633+
return
634+
}

api/helm-app/HelmAppRouter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func (impl *HelmAppRouterImpl) InitAppListRouter(helmRouter *mux.Router) {
4545
helmRouter.Path("/hibernate").Queries("appType", "{appType}").HandlerFunc(impl.helmAppRestHandler.Hibernate).Methods("POST")
4646
helmRouter.Path("/unhibernate").Queries("appType", "{appType}").HandlerFunc(impl.helmAppRestHandler.UnHibernate).Methods("POST")
4747

48+
helmRouter.Path("/external-helm-release").
49+
HandlerFunc(impl.helmAppRestHandler.ListHelmApplicationsForEnvironment).
50+
Methods("GET")
51+
4852
// GetReleaseInfo used only for external apps
4953
helmRouter.Path("/release-info").Queries("appId", "{appId}").
5054
HandlerFunc(impl.helmAppRestHandler.GetReleaseInfo).Methods("GET")

api/helm-app/bean/bean.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
SOURCE_DEVTRON_APP SourceAppType = "devtron-app"
2727
SOURCE_HELM_APP SourceAppType = "helm-app"
2828
SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app"
29+
SOURCE_LINKED_HELM_APP SourceAppType = "linked-helm-app"
2930
SOURCE_UNKNOWN SourceAppType = "unknown"
3031
ErrReleaseNotFound string = "release: not found"
3132
)

api/helm-app/gRPC/applicationClient.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type HelmAppClient interface {
5252
InstallReleaseWithCustomChart(ctx context.Context, in *HelmInstallCustomRequest) (*HelmInstallCustomResponse, error)
5353
GetNotes(ctx context.Context, request *InstallReleaseRequest) (*ChartNotesResponse, error)
5454
ValidateOCIRegistry(ctx context.Context, OCIRegistryRequest *RegistryCredential) (*OCIRegistryResponse, error)
55+
GetReleaseDetails(ctx context.Context, in *ReleaseIdentifier) (*DeployedAppDetail, error)
5556
GetExternalFluxAppDetail(ctx context.Context, in *FluxAppDetailRequest) (*FluxAppDetail, error)
5657
}
5758

@@ -395,6 +396,19 @@ func (impl *HelmAppClientImpl) ListFluxApplication(ctx context.Context, req *App
395396
}
396397
return stream, nil
397398
}
399+
400+
func (impl *HelmAppClientImpl) GetReleaseDetails(ctx context.Context, in *ReleaseIdentifier) (*DeployedAppDetail, error) {
401+
applicationClient, err := impl.getApplicationClient()
402+
if err != nil {
403+
return nil, err
404+
}
405+
response, err := applicationClient.GetReleaseDetails(ctx, in)
406+
if err != nil {
407+
return nil, err
408+
}
409+
return response, nil
410+
}
411+
398412
func (impl *HelmAppClientImpl) GetExternalFluxAppDetail(ctx context.Context, in *FluxAppDetailRequest) (*FluxAppDetail, error) {
399413
applicationClient, err := impl.getApplicationClient()
400414
if err != nil {

api/helm-app/gRPC/applist.pb.go

Lines changed: 610 additions & 590 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/helm-app/gRPC/applist.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ message DeployedAppDetail {
109109
EnvironmentDetails environmentDetail = 5;
110110
google.protobuf.Timestamp LastDeployed = 6;
111111
string chartVersion = 7;
112+
string releaseStatus = 8;
113+
string home = 9;
112114
}
113115
message EnvironmentDetails{
114116
string clusterName = 1;

api/helm-app/gRPC/applist_grpc.pb.go

Lines changed: 80 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)