* Added structure to swagger * Added updateUserGroups handlers * Updated return definition for user groups. * Logic rewrite * Removed logs * Added some tests to updateUserGroups * lint fix * Updated tests for the new API * Lint * Added comment about why we are setting this groups individually. & more lint fixes * Updated tests page * Added more tests & fixed comments for PR * Lint utils file * Fixed import orders * Changed import order Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
57 lines
1.5 KiB
Go
57 lines
1.5 KiB
Go
// This file is part of MinIO Console Server
|
|
// Copyright (c) 2020 MinIO, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package restapi
|
|
|
|
// DifferenceArrays returns the elements in `a` that aren't in `b`.
|
|
func DifferenceArrays(a, b []string) []string {
|
|
mb := make(map[string]struct{}, len(b))
|
|
for _, x := range b {
|
|
mb[x] = struct{}{}
|
|
}
|
|
var diff []string
|
|
for _, x := range a {
|
|
if _, found := mb[x]; !found {
|
|
diff = append(diff, x)
|
|
}
|
|
}
|
|
return diff
|
|
}
|
|
|
|
// IsElementInSlice returns true if the string belongs to the slice
|
|
func IsElementInArray(a []string, b string) bool {
|
|
for _, e := range a {
|
|
if e == b {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// UniqueKeys returns an array without duplicated keys
|
|
func UniqueKeys(a []string) []string {
|
|
keys := make(map[string]bool)
|
|
list := []string{}
|
|
for _, entry := range a {
|
|
if _, value := keys[entry]; !value {
|
|
keys[entry] = true
|
|
list = append(list, entry)
|
|
}
|
|
}
|
|
return list
|
|
}
|