Skip to content

sync: Temp rc #6549

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 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a9502af
approval deployment flow
prakash100198 Apr 4, 2025
a3fff41
Merge branch 'approval-bypass-v1-oss' into approval-bypass-v2-oss
prakash100198 Apr 7, 2025
6fc04d7
Merge branch 'approval-bypass-v1-oss' into approval-bypass-v2-oss
prakash100198 Apr 7, 2025
15d0fc8
Merge branch 'approval-bypass-v1-oss' into approval-bypass-v2-oss
prakash100198 Apr 7, 2025
06d5ad8
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 Apr 7, 2025
1b440ad
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 Apr 9, 2025
bd1a417
add image_state in cwr
prakash100198 Apr 9, 2025
8e7a80b
make image_state as ImageStateWhileDeployment data type
prakash100198 Apr 9, 2025
2ff9f11
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 Apr 10, 2025
538321e
update notification_templates set template payload for CD trigger ses
prakash100198 Apr 10, 2025
3be33af
code review fixes: 1st level kartik
prakash100198 Apr 11, 2025
d0a7cbc
code review fixes: 1st level kartik
prakash100198 Apr 14, 2025
d1aff8e
code review fixes: 1st level nishant
prakash100198 Apr 14, 2025
353cac8
oss sync with ent
prakash100198 Apr 14, 2025
7a2493a
resource_version in global policy table
prakash100198 Apr 14, 2025
5dff7b9
varchar 50 to 20
prakash100198 Apr 15, 2025
26b26c8
update col name to policy_revision
prakash100198 Apr 15, 2025
9962cbd
varchar to text policy revision
prakash100198 Apr 15, 2025
067e9b8
GetCmAndSecretBulkUpdateResponseForOneApp new adaptor func
prakash100198 Apr 16, 2025
fa50887
script fix
prakash100198 Apr 16, 2025
6036c8b
GetDeploymentTemplateBulkUpdateResponseForOneApp
prakash100198 Apr 16, 2025
03693a4
code review corporation :- level 2
prakash100198 Apr 25, 2025
d5ff588
revert ArtifactStateWhileDeployment to ImageStateWhileDeployment
prakash100198 Apr 25, 2025
7f42451
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 Apr 25, 2025
32e5b07
merge develop
prakash100198 Apr 25, 2025
88edb03
correct migration script number
prakash100198 Apr 25, 2025
129b867
vendor update in develop after main sync
vikramdevtron Apr 28, 2025
03faced
Merge pull request #6542 from devtron-labs/main-sync-develop-28apr
vikramdevtron Apr 28, 2025
e958720
sql files (#6541)
kartik-579 Apr 28, 2025
8ebba97
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 Apr 28, 2025
2c09b2a
fix: chart name fixed in chart reference table (#6543)
vikramdevtron Apr 29, 2025
c96d45b
Merge remote-tracking branch 'origin/feat-file-variable-cm-mount-main…
Ash-exp May 4, 2025
33d93e9
Merge pull request #6547 from devtron-labs/chore-main-sync-develop-4-may
Ash-exp May 4, 2025
83372b7
Merge branch 'develop' into approval-bypass-v2-oss
prakash100198 May 5, 2025
4afc071
change script number
prakash100198 May 5, 2025
2e8051b
Merge remote-tracking branch 'origin/approval-bypass-v2-oss' into app…
prakash100198 May 5, 2025
aa8800b
Merge pull request #6510 from devtron-labs/approval-bypass-v2-oss
prakash100198 May 5, 2025
8fbdd88
sync: Main sync develop (#6548)
vikramdevtron May 5, 2025
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
4 changes: 4 additions & 0 deletions api/appStore/deployment/AppStoreDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
if err != nil {
handler.Logger.Errorw("error in decoding app id", "err", err)
common.WriteJsonResp(w, err, "error in decoding app id", http.StatusBadRequest)
return
}
// this rbac object checks that whether user have permission to change current project.
rbacObjectForCurrentProject, rbacObjectForCurrentProject2 := handler.enforcerUtilHelm.GetHelmObjectByClusterIdNamespaceAndAppName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName)
Expand All @@ -555,6 +556,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
if err != nil {
handler.Logger.Errorw("service err, InstalledAppId", "err", err, "InstalledAppId", request.InstalledAppId)
common.WriteJsonResp(w, fmt.Errorf("Unable to fetch installed app details"), nil, http.StatusBadRequest)
return
}
if installedApp.IsVirtualEnvironment {
rbacObjectForCurrentProject, _ := handler.enforcerUtilHelm.GetAppRBACNameByInstalledAppId(request.InstalledAppId)
Expand All @@ -580,8 +582,10 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
if err != nil {
handler.Logger.Errorw("error in updating project for helm apps", "err", err)
common.WriteJsonResp(w, err, "error in updating project", http.StatusBadRequest)
return
} else {
handler.Logger.Errorw("Helm App project update")
common.WriteJsonResp(w, nil, "Project Updated", http.StatusOK)
return
}
}
1 change: 1 addition & 0 deletions api/appStore/deployment/CommonDeploymentRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func (handler *CommonDeploymentRestHandlerImpl) RollbackApplication(w http.Respo
appOfferingMode, installedAppDto, err := handler.getAppOfferingMode(installedAppId, *request.HAppId)
if err != nil {
common.WriteJsonResp(w, err, "bad request", http.StatusBadRequest)
return
}
installedAppDto.UserId = userId
//rbac block starts from here
Expand Down
1 change: 1 addition & 0 deletions api/auth/user/UserAuthHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (handler UserAuthHandlerImpl) LoginHandler(w http.ResponseWriter, r *http.R
if err != nil {
handler.logger.Errorw("request err, LoginHandler", "err", err, "payload", up)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}

err = handler.validator.Struct(up)
Expand Down
2 changes: 2 additions & 0 deletions api/helm-app/HelmAppRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (handler *HelmAppRestHandlerImpl) Hibernate(w http.ResponseWriter, r *http.
appType, err = strconv.Atoi(appTypeString)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
}

Expand Down Expand Up @@ -282,6 +283,7 @@ func (handler *HelmAppRestHandlerImpl) UnHibernate(w http.ResponseWriter, r *htt
appType, err = strconv.Atoi(appTypeString)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
}
token := r.Header.Get("token")
Expand Down
1 change: 1 addition & 0 deletions api/k8s/application/k8sApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ func (handler *K8sApplicationRestHandlerImpl) requestValidationAndRBAC(w http.Re
if err != nil {
handler.logger.Errorw(bean2.AppIdDecodingError, "err", err, "appIdentifier", request.AppIdentifier)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
valid, err := handler.argoApplicationReadService.ValidateArgoResourceRequest(r.Context(), appIdentifier, request.K8sRequest)
if err != nil || !valid {
Expand Down
1 change: 1 addition & 0 deletions api/restHandler/BatchOperationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (handler BatchOperationRestHandlerImpl) Operate(w http.ResponseWriter, r *h

if workflow.Destination.App == nil || len(*workflow.Destination.App) == 0 {
common.WriteJsonResp(w, errors.New("app name cannot be empty"), nil, http.StatusBadRequest)
return
}
rbacString := handler.enforcerUtil.GetProjectAdminRBACNameBYAppName(*workflow.Destination.App)
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, rbacString); !ok {
Expand Down
54 changes: 48 additions & 6 deletions api/restHandler/BulkUpdateRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package restHandler
import (
"encoding/json"
"fmt"
bean4 "github.com/devtron-labs/devtron/pkg/auth/user/bean"
"github.com/devtron-labs/devtron/pkg/build/git/gitMaterial/repository"
"github.com/devtron-labs/devtron/pkg/build/git/gitProvider"
"github.com/devtron-labs/devtron/pkg/bulkAction/bean"
"github.com/devtron-labs/devtron/pkg/bulkAction/service"
"github.com/devtron-labs/devtron/pkg/cluster/environment"
"github.com/devtron-labs/devtron/util"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -181,22 +183,26 @@ func (handler BulkUpdateRestHandlerImpl) GetImpactedAppsName(w http.ResponseWrit
ok := handler.CheckAuthForImpactedObjects(deploymentTemplateImpactedApp.AppId, deploymentTemplateImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
for _, configMapImpactedApp := range impactedApps.ConfigMap {
ok := handler.CheckAuthForImpactedObjects(configMapImpactedApp.AppId, configMapImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
for _, secretImpactedApp := range impactedApps.Secret {
ok := handler.CheckAuthForImpactedObjects(secretImpactedApp.AppId, secretImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
common.WriteJsonResp(w, err, impactedApps, http.StatusOK)
}

func (handler BulkUpdateRestHandlerImpl) CheckAuthForBulkUpdate(AppId int, EnvId int, AppName string, rbacObjects map[int]string, token string) bool {
resourceName := rbacObjects[AppId]
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, resourceName); !ok {
Expand All @@ -212,9 +218,14 @@ func (handler BulkUpdateRestHandlerImpl) CheckAuthForBulkUpdate(AppId int, EnvId

}
func (handler BulkUpdateRestHandlerImpl) BulkUpdate(w http.ResponseWriter, r *http.Request) {
userId, err := handler.userAuthService.GetLoggedInUser(r)
if userId == 0 || err != nil {
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
decoder := json.NewDecoder(r.Body)
var script bean.BulkUpdateScript
err := decoder.Decode(&script)
err = decoder.Decode(&script)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
Expand All @@ -236,22 +247,31 @@ func (handler BulkUpdateRestHandlerImpl) BulkUpdate(w http.ResponseWriter, r *ht
ok := handler.CheckAuthForBulkUpdate(deploymentTemplateImpactedApp.AppId, deploymentTemplateImpactedApp.EnvId, deploymentTemplateImpactedApp.AppName, rbacObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
for _, configMapImpactedApp := range impactedApps.ConfigMap {
ok := handler.CheckAuthForBulkUpdate(configMapImpactedApp.AppId, configMapImpactedApp.EnvId, configMapImpactedApp.AppName, rbacObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}
for _, secretImpactedApp := range impactedApps.Secret {
ok := handler.CheckAuthForBulkUpdate(secretImpactedApp.AppId, secretImpactedApp.EnvId, secretImpactedApp.AppName, rbacObjects, token)
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
}

response := handler.bulkUpdateService.BulkUpdate(script.Spec)
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail := util.GetEmailFromContext(r.Context())
userMetadata := &bean4.UserMetadata{
UserEmailId: userEmail,
IsUserSuperAdmin: isSuperAdmin,
UserId: userId,
}
response := handler.bulkUpdateService.BulkUpdate(script.Spec, userMetadata)
common.WriteJsonResp(w, nil, response, http.StatusOK)
}

Expand All @@ -261,7 +281,15 @@ func (handler BulkUpdateRestHandlerImpl) BulkHibernate(w http.ResponseWriter, r
return // response already written by the helper on error.
}
token := r.Header.Get("token")
response, err := handler.bulkUpdateService.BulkHibernate(request, r.Context(), w, token, handler.checkAuthForBulkHibernateAndUnhibernate)
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail := util.GetEmailFromContext(r.Context())
userMetadata := &bean4.UserMetadata{
UserEmailId: userEmail,
IsUserSuperAdmin: isSuperAdmin,
UserId: request.UserId,
}

response, err := handler.bulkUpdateService.BulkHibernate(r.Context(), request, handler.checkAuthForBulkHibernateAndUnhibernate, userMetadata)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
Expand Down Expand Up @@ -298,7 +326,14 @@ func (handler BulkUpdateRestHandlerImpl) BulkUnHibernate(w http.ResponseWriter,
return // response already written by the helper on error.
}
token := r.Header.Get("token")
response, err := handler.bulkUpdateService.BulkUnHibernate(request, r.Context(), w, token, handler.checkAuthForBulkHibernateAndUnhibernate)
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail := util.GetEmailFromContext(r.Context())
userMetadata := &bean4.UserMetadata{
UserEmailId: userEmail,
IsUserSuperAdmin: isSuperAdmin,
UserId: request.UserId,
}
response, err := handler.bulkUpdateService.BulkUnHibernate(r.Context(), request, handler.checkAuthForBulkHibernateAndUnhibernate, userMetadata)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
Expand Down Expand Up @@ -326,7 +361,14 @@ func (handler BulkUpdateRestHandlerImpl) BulkDeploy(w http.ResponseWriter, r *ht
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
response, err := handler.bulkUpdateService.BulkDeploy(&request, token, handler.checkAuthBatch)
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail := util.GetEmailFromContext(r.Context())
userMetadata := &bean4.UserMetadata{
UserEmailId: userEmail,
IsUserSuperAdmin: isSuperAdmin,
UserId: userId,
}
response, err := handler.bulkUpdateService.BulkDeploy(&request, token, handler.checkAuthBatch, userMetadata)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
Expand Down
65 changes: 17 additions & 48 deletions api/restHandler/ConfigMapRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package restHandler
import (
"encoding/json"
"fmt"
"github.com/devtron-labs/devtron/pkg/auth/user/util"
"github.com/devtron-labs/devtron/pkg/pipeline/draftAwareConfigService"
"net/http"
"strconv"
Expand Down Expand Up @@ -125,12 +126,8 @@ func (handler ConfigMapRestHandlerImpl) CMGlobalAddUpdate(w http.ResponseWriter,
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
res, err := handler.draftAwareResourceService.CMGlobalAddUpdate(ctx, &configMapRequest, isSuperAdmin, userEmail)
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
res, err := handler.draftAwareResourceService.CMGlobalAddUpdate(ctx, &configMapRequest, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CMGlobalAddUpdate", "err", err, "payload", configMapRequest)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -175,12 +172,8 @@ func (handler ConfigMapRestHandlerImpl) CMEnvironmentAddUpdate(w http.ResponseWr
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
res, err := handler.draftAwareResourceService.CMEnvironmentAddUpdate(ctx, &configMapRequest, isSuperAdmin, userEmail)
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
res, err := handler.draftAwareResourceService.CMEnvironmentAddUpdate(ctx, &configMapRequest, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CMEnvironmentAddUpdate", "err", err, "payload", configMapRequest)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -378,12 +371,8 @@ func (handler ConfigMapRestHandlerImpl) CSGlobalAddUpdate(w http.ResponseWriter,
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
res, err := handler.draftAwareResourceService.CSGlobalAddUpdate(ctx, &configMapRequest, isSuperAdmin, userEmail)
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
res, err := handler.draftAwareResourceService.CSGlobalAddUpdate(ctx, &configMapRequest, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CSGlobalAddUpdate", "err", err, "payload", configMapRequest)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -429,12 +418,8 @@ func (handler ConfigMapRestHandlerImpl) CSEnvironmentAddUpdate(w http.ResponseWr
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
res, err := handler.draftAwareResourceService.CSEnvironmentAddUpdate(ctx, &configMapRequest, isSuperAdmin, userEmail)
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
res, err := handler.draftAwareResourceService.CSEnvironmentAddUpdate(ctx, &configMapRequest, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CSEnvironmentAddUpdate", "err", err, "payload", configMapRequest)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -548,17 +533,13 @@ func (handler ConfigMapRestHandlerImpl) CMGlobalDelete(w http.ResponseWriter, r
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
deleteReq := &bean.ConfigDataRequest{
Id: id,
AppId: appId,
UserId: userId,
}
res, err := handler.draftAwareResourceService.CMGlobalDelete(ctx, name, deleteReq, isSuperAdmin, userEmail)
res, err := handler.draftAwareResourceService.CMGlobalDelete(ctx, name, deleteReq, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CMGlobalDelete", "err", err, "appId", appId, "id", id, "name", name)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -614,17 +595,13 @@ func (handler ConfigMapRestHandlerImpl) CMEnvironmentDelete(w http.ResponseWrite
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
deleteReq := &bean.ConfigDataRequest{
Id: id,
AppId: appId,
UserId: userId,
}
res, err := handler.draftAwareResourceService.CMEnvironmentDelete(ctx, name, deleteReq, isSuperAdmin, userEmail)
res, err := handler.draftAwareResourceService.CMEnvironmentDelete(ctx, name, deleteReq, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CMEnvironmentDelete", "err", err, "appId", appId, "envId", envId, "id", id)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -666,17 +643,13 @@ func (handler ConfigMapRestHandlerImpl) CSGlobalDelete(w http.ResponseWriter, r
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
deleteReq := &bean.ConfigDataRequest{
Id: id,
AppId: appId,
UserId: userId,
}
res, err := handler.draftAwareResourceService.CSGlobalDelete(ctx, name, deleteReq, isSuperAdmin, userEmail)
res, err := handler.draftAwareResourceService.CSGlobalDelete(ctx, name, deleteReq, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CSGlobalDelete", "err", err, "appId", appId, "id", id, "name", name)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down Expand Up @@ -732,17 +705,13 @@ func (handler ConfigMapRestHandlerImpl) CSEnvironmentDelete(w http.ResponseWrite
//RBAC END
ctx := r.Context()
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")
userEmail, err := handler.userAuthService.GetActiveEmailById(userId)
if err != nil {
common.WriteJsonResp(w, fmt.Errorf("userEmail not found by userId"), "userEmail not found by userId", http.StatusNotFound)
return
}
userMetadata := util.GetUserMetadata(r.Context(), userId, isSuperAdmin)
deleteReq := &bean.ConfigDataRequest{
Id: id,
AppId: appId,
UserId: userId,
}
res, err := handler.draftAwareResourceService.CSEnvironmentDelete(ctx, name, deleteReq, isSuperAdmin, userEmail)
res, err := handler.draftAwareResourceService.CSEnvironmentDelete(ctx, name, deleteReq, userMetadata)
if err != nil {
handler.Logger.Errorw("service err, CSEnvironmentDelete", "err", err, "appId", appId, "envId", envId, "id", id)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
Expand Down
1 change: 1 addition & 0 deletions api/restHandler/GitOpsConfigRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ func (impl GitOpsConfigRestHandlerImpl) GitOpsValidator(w http.ResponseWriter, r
if err != nil && !errors.Is(err, moduleErr.ModuleNotFoundError) {
impl.logger.Errorw("error in getting argo module", "error", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
detailedErrorGitOpsConfigResponse := impl.gitOpsConfigService.GitOpsValidateDryRun(argoModule.IsInstalled(), &bean)
common.WriteJsonResp(w, nil, detailedErrorGitOpsConfigResponse, http.StatusOK)
Expand Down
Loading