Skip to content

Commit

Permalink
resolve golint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffhuang4704 committed Oct 13, 2024
1 parent 3386b11 commit aa54630
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 31 deletions.
16 changes: 8 additions & 8 deletions controller/access/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func getRestRolePermitValues(roleName, domain string) map[string]rwPermit {
}
for _, option := range PermissionOptions {
// need to check fed/nv_resource permissions as well
permit, _ := rolePermits[option.ID]
permit := rolePermits[option.ID]
optionReadValue, optionWriteValue := option.Value, option.Value
if domain == AccessDomainGlobal {
optionReadValue &= share.PERMS_FED_READ
Expand Down Expand Up @@ -521,7 +521,7 @@ func getDomainPermissions(domain string, roles []string, extraPermits []share.Nv
} else {
for id, rw := range rolePermits {
if rw.read || rw.write {
rwFound, _ := allPermits[id]
rwFound := allPermits[id]
allPermits[id] = rwPermit{read: rwFound.read || rw.read, write: rwFound.write || rw.write}
}
}
Expand All @@ -544,7 +544,7 @@ func getDomainPermissions(domain string, roles []string, extraPermits []share.Nv
}
for _, permit := range GetTopLevelPermitsList(scope, dExtraPermits) { // iterate thru []*api.RESTRolePermission from extra permissions
if permit.Read || permit.Write {
rw, _ := allPermits[permit.ID]
rw := allPermits[permit.ID]
allPermits[permit.ID] = rwPermit{read: rw.read || permit.Read, write: rw.write || permit.Write}
}
}
Expand Down Expand Up @@ -584,7 +584,7 @@ func GetUserPermissions(role string, roleDomains map[string][]string, extraPermi
}
for _, domain := range domains {
if domain != AccessDomainGlobal {
roles, _ := domainRoles[domain]
roles := domainRoles[domain]
domainRoles[domain] = append(roles, role)
allDomains[domain] = nil
}
Expand All @@ -599,7 +599,7 @@ func GetUserPermissions(role string, roleDomains map[string][]string, extraPermi
}
for _, domain := range permitsDomains.Domains {
if domain != AccessDomainGlobal {
permits, _ := domainPermits[domain]
permits := domainPermits[domain]
domainPermits[domain] = append(permits, permitsDomains.Permits)
allDomains[domain] = nil
}
Expand All @@ -609,8 +609,8 @@ func GetUserPermissions(role string, roleDomains map[string][]string, extraPermi
// 2-3. merge #2-1 & #2-2 to get the top-level permissions list for each domain
dPermitsList := make(map[string][]*api.RESTRolePermission, len(allDomains)) // domain -> list of permissions
for domain := range allDomains {
roles, _ := domainRoles[domain]
extraPermits, _ := domainPermits[domain]
roles := domainRoles[domain]
extraPermits := domainPermits[domain]
if permitsList := getDomainPermissions(domain, roles, extraPermits); len(permitsList) > 0 {
dPermitsList[domain] = permitsList
}
Expand Down Expand Up @@ -672,7 +672,7 @@ func getRequiredPermissions(r *http.Request) (int8, uint32) {
}
}
}
requiredPermissions, _ := apiPermissions[apiCategoryID]
requiredPermissions := apiPermissions[apiCategoryID]

return apiCategoryID, requiredPermissions
}
Expand Down
4 changes: 1 addition & 3 deletions controller/rest/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2929,9 +2929,7 @@ func _setFedJointPrivateKey(id string, key *rsa.PrivateKey) {
if key != nil {
jointClustersKeyCache[id] = key
} else {
if _, exist := jointClustersKeyCache[id]; exist {
delete(jointClustersKeyCache, id)
}
delete(jointClustersKeyCache, id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions controller/rest/crdvalidatewebhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (q *tCrdRequestsMgr) crdQueueProc() {
crdHandler.mdName = req.Name
} else {
errCount = 1
errMsg = fmt.Sprintf("CRD Rule format error")
errMsg = "CRD Rule format error"
}
case "CREATE", "UPDATE":
if crdSecRule, err = resource.CreateNvCrdObject(rscType); crdSecRule != nil {
Expand All @@ -327,7 +327,7 @@ func (q *tCrdRequestsMgr) crdQueueProc() {
}
if err != nil {
errCount = 1
errMsg = fmt.Sprintf("CRD Rule format error")
errMsg = "CRD Rule format error"
} else {
if crdHandler.mdName != "" && rscType != "" {
if obj, err := global.ORCH.GetResource(rscType, req.Namespace, crdHandler.mdName); err == nil {
Expand Down
4 changes: 1 addition & 3 deletions controller/rest/dlp_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,7 @@ func deleteDlpSensor(w http.ResponseWriter, name string, reviewType share.TRevie
defsensor.PreRuleList = make(map[string][]*share.CLUSDlpRule)
}
for _, rn := range dlpsensor.RuleListNames {
if _, foundInAll := defsensor.RuleList[rn]; foundInAll {
delete(defsensor.RuleList, rn)
}
delete(defsensor.RuleList, rn)
}
clusHelper.PutDlpSensorTxn(txn, defsensor)
clusHelper.DeleteDlpSensorTxn(txn, name)
Expand Down
4 changes: 1 addition & 3 deletions controller/rest/federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,7 @@ func revertMappedFedRoles(groupRoleMappings []*share.GroupRoleMapping) {
groupRoleMapping.GlobalRole = api.UserRoleReader
}
if groupRoleMapping.RoleDomains != nil {
if _, ok := groupRoleMapping.RoleDomains[groupRoleMapping.GlobalRole]; ok {
delete(groupRoleMapping.RoleDomains, groupRoleMapping.GlobalRole)
}
delete(groupRoleMapping.RoleDomains, groupRoleMapping.GlobalRole)
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions controller/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,12 +1002,10 @@ func restEventLog(r *http.Request, body []byte, login *loginSession, fields rest
clog.RESTBody = string(body[:size])
}

if fields != nil {
for key, value := range fields {
switch key {
case restLogFieldMsg:
clog.Msg = value
}
for key, value := range fields {
switch key {
case restLogFieldMsg:
clog.Msg = value
}
}

Expand Down
4 changes: 1 addition & 3 deletions controller/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ func checkGroupRolesMapping(oldSettings, newSettings []*share.GroupRoleMapping,

// if a groups is mapped to a role for global domain, it's implicitly mapped to that same role for all domains. So remove unnecessary domain role mapping entry
if mappedRoles.RoleDomains != nil {
if _, ok := mappedRoles.RoleDomains[mappedRoles.GlobalRole]; ok {
delete(mappedRoles.RoleDomains, mappedRoles.GlobalRole)
}
delete(mappedRoles.RoleDomains, mappedRoles.GlobalRole)
}

mappedDomainRole := make(map[string]string, 0) // for each group, each domain can only be mapped to one role
Expand Down
4 changes: 1 addition & 3 deletions controller/rest/waf_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,7 @@ func deleteWafSensor(w http.ResponseWriter, name string, reviewType share.TRevie
defsensor.PreRuleList = make(map[string][]*share.CLUSWafRule)
}
for _, rn := range wafsensor.RuleListNames {
if _, foundInAll := defsensor.RuleList[rn]; foundInAll {
delete(defsensor.RuleList, rn)
}
delete(defsensor.RuleList, rn)
}
clusHelper.PutWafSensorTxn(txn, defsensor)
clusHelper.DeleteWafSensorTxn(txn, name)
Expand Down

0 comments on commit aa54630

Please sign in to comment.