Merge pull request #9838 from stonezdj/fix_review

Fix review comments on PR9749
This commit is contained in:
Daniel Jiang 2019-11-14 13:12:56 +08:00 committed by GitHub
commit 6f0b4a139a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -97,9 +97,12 @@ func GetUserGroup(id int) (*models.UserGroup, error) {
// PopulateGroup - Return the group ID by given group name. if not exist in Harbor DB, create one
func PopulateGroup(userGroups []models.UserGroup) ([]int, error) {
var ugList []int
ugList := make([]int, 0)
for _, group := range userGroups {
OnBoardUserGroup(&group)
err := OnBoardUserGroup(&group)
if err != nil {
return ugList, err
}
if group.ID > 0 {
ugList = append(ugList, group.ID)
}

View File

@ -32,7 +32,7 @@ func (u *UserGroup) TableName() string {
// UserGroupsFromName ...
func UserGroupsFromName(groupNames []string, groupType int) []UserGroup {
var groups []UserGroup
groups := make([]UserGroup, 0)
for _, name := range groupNames {
groups = append(groups, UserGroup{GroupName: name, GroupType: groupType})
}

View File

@ -103,7 +103,7 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) {
}
}
var userGroups []models.UserGroup
userGroups := make([]models.UserGroup, 0)
for _, dn := range ldapUsers[0].GroupDNList {
userGroups = append(userGroups, models.UserGroup{GroupName: dn, LdapGroupDN: dn, GroupType: common.LDAPGroupType})
}