Skip to content

Commit

Permalink
Add IsClientOrg utility
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha committed Feb 7, 2025
1 parent 7f3619f commit 8f8d674
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"crypto/sha256"
"encoding/base64"
"fmt"
core "k8s.io/api/core/v1"
"k8s.io/apiserver/pkg/authentication/user"
"strings"
)

Expand Down Expand Up @@ -147,6 +149,20 @@ func (cm ClusterManager) ManagedByVirtualCluster() bool {
return cm&ClusterManagerVirtualCluster == ClusterManagerVirtualCluster
}

func IsClientOrgMember(user user.Info, list core.NamespaceList) (bool, string) {
cOrg, exists := user.GetExtra()[AceOrgIDKey]
if exists && len(cOrg) > 0 {
for _, ns := range list.Items {
if val, exist := ns.Annotations[AceOrgIDKey]; exist && val == cOrg[0] {
if val, exist = ns.Labels[ClientOrgKey]; exist && val == "true" {
return true, cOrg[0]
}
}
}
}
return false, ""
}

func (cm ClusterManager) Strings() []string {
out := make([]string, 0, 7)
if cm.ManagedByACE() {
Expand Down

0 comments on commit 8f8d674

Please sign in to comment.