Skip to content

Commit b9e171d

Browse files
iamayushmAsh-exp
andauthored
feat: Link helm release (#6454)
* wip:deployment config old data migration code * updating repo url get usage * comments * adding comments * wip: adding repo name in deployment config struct * migration files * migration update * feat: updated the target revision * review changes * nil handling * dev testing bug fixes * fixes * value file name fix * fixes * repo url function update * git repo url handing using code * fixing import cycle * feat: dynamic chart loaction and valuesfile path * CRUD operations * repo clone and env override create flow * wip: self review changes * feat: trigger flows updated * self review changes * refactoring * self review fix: env override create * skipping checks * feat: Skip GitOps config CRUD ACD operation if argo module is not installed * handling for IsGitOpsConfigured * feat: release mode data adaptor * validation api * deployment status changes and application filter logic change * self review changes * delete acd app handling * adding route * modifying validate link request * pipeline crud operation * dev testing fix * wip: release config data type fix * fixing check * updated wire gen * added api /environment-variables * added releaseMode validation * fix: isGitOpsEnable flag * updated EnvironmentVariableList response * updated git repo validations * updated migration number * fix: skip pipeline create validation * panic handler for cd pipeline creation * updated wire dep * fix: cd trigger panic fix * fix: validation migrate cd pipeline api * updated ValidateGitOpsRepoUrl request for custom gitops logic * fix: git clone logic for validate migration request * fix: updated API key * chart name handling for migrate release * fix: chart validation * fix: chart validation * fix: pipeline creation * feat: is gitops repo configured flag updated * wip: trigger fix * feat: filter external argo app list * read service for circular import * fix nil poniter panic * fix: empty argo app list * fix empty app name * updated dep of DeploymentConfigService instead of DeploymentConfigReadService in ArgoApplicationService * minor refactorings * replaced release app name from util function * validation and flag if config is for external helm release * fix migrated from flag * fix: resource tree api with scoop * fix: error handling for GetResourceTree * fixing set chart location function * updating config type * fix: scoop argo_cd GetResourceTree * fix: updated validation error * fix: updated BuildDeployedAppName references * fix: common wire set * updating chart location while delete * fix user id * common function for url already present * removing duplicate logic for pipeline filter * fix: nil checker issues * updated global api * pg no rows handling * manual sync mode fix for trigger/deployment statys * fix: resource tree * fix: panic handling * fix default namespace * wip * fix: pipeline delete flow * fix: delete apllication object * fix: delete application object * chore: refactored AppDetailsReadService * added: vlaidation for link external release * review comment incorporated * fix: pointer datatype * added: EnforcedPolicyViolation validation * fix app clone * make fix * fix: workflow_execution_stage cloumn * added gitops adapter * helm deployment status fix * updated deployment config queries * fix: generate manifest diff * wire gen updated * updated feature flag name * updated env_gen.md file * feat: argocd resource tree support * fix: nil handling updated * fix: context handling * review changes * chore: deployment config refactorings * fix: on-board argocd issues * updated updateArgoAppDeleteStatus func * review changes * make fix * delete argo app error handling fixes * payload changes * argo app listing api updated * updated wire_gen files * chore: Argocd dependabot fixes (#6402) * version matched with enterprise * vulnerability fix * argocd dependabot fixes * argo workflow dependabot fixes * fix: link request * updated migration script * fix: GetDeploymentConfigMinForAppAndEnv for app stage api * fix: helm app gitops target revision * fix: cd pipeline create blocked if argo module not installed * setting repo url in new deployment config also * default branch (backward compatibility) if branch is not passed * updated target revision * fix: release config target revision * updated not deployed status to degraded * go mod tidy * helm list api moved from enterprise * fix: app delete flow * listing api * query fix * fix: git commit ref not found * fix: git commit ref not found * fix: gitops branch pull error * validate api for external helm release * fix enum * fix: removed unused import * chore: func renamed * rest handler update * updating chart location when base version is changed * chart location update in deployment config * chart env override fix * wip: fixed pg no rows * wip: bug fixes * fix empty env id * integration fixes * is linkable true * fix chart name * enterprise code moved * function rename * fix empty cluster url * namespace fix * listing api fix * wip: installed app query fix * fix for argo module not installed * wip: adding chart loaction * renaming * wip * wip: head validation * refactoring * deployment app type change fix * chart location heal * wip: validation for linked pipeline in app change api * fix deployment change api * review changes * migration update * validation in create api * fixing issues * fix argo unsupported spec error parsingg * zero time handling * revert time parse * empty createdAt handling * fixing messaging around gitOps * removing hard coding * wip: deployment app name added * fix cluster nil pointer * fix panic if values file is empty * renaming --------- Co-authored-by: Ash-exp <[email protected]>
1 parent 7b8429f commit b9e171d

File tree

35 files changed

+1832
-931
lines changed

35 files changed

+1832
-931
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)