Skip to content

Commit 89fec6b

Browse files
committed
Merge branch 'develop' into further-refact-oss
2 parents 27a79b5 + 8e1991c commit 89fec6b

File tree

16 files changed

+300
-202
lines changed

16 files changed

+300
-202
lines changed

.github/workflows/auto-label.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
issue_comment:
55
types: [created]
66

7-
87
jobs:
98
manage-labels:
109
if: ${{ !github.event.issue.pull_request }}
@@ -16,40 +15,37 @@ jobs:
1615

1716
- name: Parse and manage labels
1817
env:
19-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
GH_TOKEN: ${{ secrets.ORG_MEMBERSHIP_SECRET }}
2019
run: |
2120
set -e
2221
set -x # Enable debugging
2322
24-
# Extract comment on body and issue number
23+
# Extract comment body, issue number, and author
2524
COMMENT_BODY=$(jq -r '.comment.body' "$GITHUB_EVENT_PATH")
2625
ISSUE_NUMBER=$(jq -r '.issue.number // .pull_request.number' "$GITHUB_EVENT_PATH")
26+
COMMENT_AUTHOR=$(jq -r '.comment.user.login' "$GITHUB_EVENT_PATH")
2727
28-
ORG_NAME="devtron-labs"
29-
30-
# checks if the person is authorized to add labels or not
31-
ORG_MEMBERSHIP_STATUS=$(gh api "orgs/$ORG_NAME/members/$COMMENT_AUTHOR" --silent --exit-status)
28+
ORG_NAME="satyam-tests"
3229
30+
# Check if the person is authorized to add labels
31+
curl -s -H "Authorization: token $GH_TOKEN" "https://api.github.com/orgs/$ORG_NAME/members/$COMMENT_AUTHOR" > /dev/null
3332
if [[ $? -ne 0 ]]; then
3433
gh issue comment "$ISSUE_NUMBER" --body "Hi @$COMMENT_AUTHOR, you must be a member of the organization '$ORG_NAME' to add or remove labels."
35-
3634
echo "User '$COMMENT_AUTHOR' is not a member of the organization '$ORG_NAME'. Exiting."
3735
exit 1
3836
fi
3937
40-
echo "User '$COMMENT_AUTHOR' is a verified member of the organization '$ORG_NAME'. Adding label"
41-
38+
echo "User '$COMMENT_AUTHOR' is a verified member of the organization '$ORG_NAME'. Proceeding with label management."
4239
43-
# Get the existing labels on the issue
40+
# Get the existing labels on the issue
4441
EXISTING_LABELS=$(gh issue view "$ISSUE_NUMBER" --json labels -q '.labels[].name')
4542
46-
# Add Label
43+
# Add Label Logic
4744
if [[ "$COMMENT_BODY" =~ ^/([^ ]+)$ ]]; then
4845
LABEL_NAME="${COMMENT_BODY:1}"
4946
50-
# check for already existing labels in reppo
47+
# Check if the label exists in the repository
5148
if gh label list --json name -q '.[].name' | grep -q "^$LABEL_NAME$"; then
52-
# Add the requested label, keeping existing ones intact
5349
gh issue edit "$ISSUE_NUMBER" --add-label "$LABEL_NAME"
5450
echo "Successfully added label '$LABEL_NAME' to issue #$ISSUE_NUMBER."
5551
else

api/bean/UserRequest.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ type RoleFilter struct {
7272
Workflow string `json:"workflow"`
7373
}
7474

75+
func (rf RoleFilter) GetTeam() string { return rf.Team }
76+
func (rf RoleFilter) GetEntity() string { return rf.Entity }
77+
func (rf RoleFilter) GetAction() string { return rf.Action }
78+
func (rf RoleFilter) GetAccessType() string { return rf.AccessType }
79+
func (rf RoleFilter) GetEnvironment() string { return rf.Environment }
80+
func (rf RoleFilter) GetCluster() string { return rf.Cluster }
81+
func (rf RoleFilter) GetGroup() string { return rf.Group }
82+
func (rf RoleFilter) GetKind() string { return rf.Kind }
83+
func (rf RoleFilter) GetEntityName() string { return rf.EntityName }
84+
func (rf RoleFilter) GetResource() string { return rf.Resource }
85+
func (rf RoleFilter) GetWorkflow() string { return rf.Workflow }
86+
func (rf RoleFilter) GetNamespace() string { return rf.Namespace }
87+
7588
type Role struct {
7689
Id int `json:"id" validate:"number"`
7790
Role string `json:"role" validate:"required"`

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ require gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
288288

289289
replace (
290290
github.com/argoproj/argo-workflows/v3 v3.5.10 => github.com/devtron-labs/argo-workflows/v3 v3.5.10
291-
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241204111351-2cfdc19725b5
292-
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241204111351-2cfdc19725b5
291+
github.com/devtron-labs/authenticator => github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241213055820-d24bfa4efd0d
292+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241213055820-d24bfa4efd0d
293293
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
294294
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.5.5
295295
k8s.io/api => k8s.io/api v0.29.7

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,10 +792,10 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
792792
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
793793
github.com/devtron-labs/argo-workflows/v3 v3.5.10 h1:6rxQOesOzDz6SgQCMDQNHaehsKFW3C7U8CZeEek5kgQ=
794794
github.com/devtron-labs/argo-workflows/v3 v3.5.10/go.mod h1:/vqxcovDPT4zqr4DjR5v7CF8ggpY1l3TSa2CIG3jmjA=
795-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241204111351-2cfdc19725b5 h1:MQd6j54syvrqgJzX6hI3Eu1VIdVw1LoSlznaFeFGTEU=
796-
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241204111351-2cfdc19725b5/go.mod h1:vFJ3M7akwAWCtugDXRW+5Q9P+cp0RiH+K/D5FBbb/JA=
797-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241204111351-2cfdc19725b5 h1:lryYTbjOobld0xEwd8K/dpiw1TE4/r2XQYPyvWx2O4s=
798-
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241204111351-2cfdc19725b5/go.mod h1:NJSMdv+zTUK3p7rML12RZSeAUKHeLaoY3sR/oK0xhwo=
795+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241213055820-d24bfa4efd0d h1:C5ajcYJiD4zuGDpIYRSfn7IbYdU0lLFJtlDIS4DBLKk=
796+
github.com/devtron-labs/devtron-services/authenticator v0.0.0-20241213055820-d24bfa4efd0d/go.mod h1:vFJ3M7akwAWCtugDXRW+5Q9P+cp0RiH+K/D5FBbb/JA=
797+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241213055820-d24bfa4efd0d h1:lrpJrtCPBfHlZC6E+seCqcGGokq7PtoQuYs7O9+umeA=
798+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241213055820-d24bfa4efd0d/go.mod h1:NJSMdv+zTUK3p7rML12RZSeAUKHeLaoY3sR/oK0xhwo=
799799
github.com/devtron-labs/go-bitbucket v0.9.60-beta h1:VEx1jvDgdtDPS6A1uUFoaEi0l1/oLhbr+90xOwr6sDU=
800800
github.com/devtron-labs/go-bitbucket v0.9.60-beta/go.mod h1:GnuiCesvh8xyHeMCb+twm8lBR/kQzJYSKL28ZfObp1Y=
801801
github.com/devtron-labs/protos v0.0.3-0.20240802105333-92ee9bb85d80 h1:xwbTeijNTf4/j1v+tSfwVqwLVnReas/NqEKeQHvSTys=

pkg/auth/user/RoleGroupService.go

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -569,46 +569,11 @@ func (impl RoleGroupServiceImpl) getRoleGroupMetadata(roleGroup *repository.Role
569569
impl.logger.Errorw("No Roles Found for user", "roleGroupId", roleGroup.Id)
570570
}
571571
var roleFilters []bean.RoleFilter
572-
isSuperAdmin := false
573-
roleFilterMap := make(map[string]*bean.RoleFilter)
574-
for _, role := range roles {
575-
key := impl.userCommonService.GetUniqueKeyForAllEntity(*role)
576-
if _, ok := roleFilterMap[key]; ok {
577-
impl.userCommonService.BuildRoleFilterForAllTypes(roleFilterMap, *role, key)
578-
} else {
579-
roleFilterMap[key] = &bean.RoleFilter{
580-
Entity: role.Entity,
581-
Team: role.Team,
582-
Environment: role.Environment,
583-
EntityName: role.EntityName,
584-
Action: role.Action,
585-
AccessType: role.AccessType,
586-
Cluster: role.Cluster,
587-
Namespace: role.Namespace,
588-
Group: role.Group,
589-
Kind: role.Kind,
590-
Resource: role.Resource,
591-
Workflow: role.Workflow,
592-
}
593-
}
594-
if role.Role == bean.SUPERADMIN {
595-
isSuperAdmin = true
596-
}
597-
}
598-
for _, v := range roleFilterMap {
599-
if v.Action == bean2.SUPER_ADMIN {
600-
continue
601-
}
602-
roleFilters = append(roleFilters, *v)
603-
}
604-
for index, roleFilter := range roleFilters {
605-
if roleFilter.Entity == "" {
606-
roleFilters[index].Entity = bean2.ENTITY_APPS
607-
}
608-
if roleFilter.Entity == bean2.ENTITY_APPS && roleFilter.AccessType == "" {
609-
roleFilters[index].AccessType = bean2.DEVTRON_APP
610-
}
611-
}
572+
isSuperAdmin := helper2.CheckIfSuperAdminFromRoles(roles)
573+
// merging considering base as env first
574+
roleFilters = impl.userCommonService.BuildRoleFiltersAfterMerging(ConvertRolesToEntityProcessors(roles), bean2.EnvironmentBasedKey)
575+
// merging role filters based on application now, first took env as base merged, now application as base , merged
576+
roleFilters = impl.userCommonService.BuildRoleFiltersAfterMerging(ConvertRoleFiltersToEntityProcessors(roleFilters), bean2.ApplicationBasedKey)
612577
if len(roleFilters) == 0 {
613578
roleFilters = make([]bean.RoleFilter, 0)
614579
}

0 commit comments

Comments
 (0)