support workspace member search

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2018-12-03 21:13:18 +08:00
parent 9e7db66780
commit f25ae2d571
4 changed files with 30 additions and 93 deletions

View File

@@ -156,6 +156,9 @@ func deleteDevopsRoleBinding(workspace string, projectId string, user string) {
if err != nil || resp.StatusCode > 200 {
glog.Warning("delete devops role binding failed", workspace, project, user)
}
if resp != nil {
resp.Body.Close()
}
}
}
@@ -183,6 +186,9 @@ func createDevopsRoleBinding(workspace string, projectId string, user string, ro
if err != nil || resp.StatusCode > 200 {
glog.Warning(fmt.Sprintf("create devops role binding failed %s,%s,%s,%s", workspace, project, user, role))
}
if resp != nil {
resp.Body.Close()
}
}
}
@@ -679,7 +685,7 @@ func ListDevopsProjectsByUser(username string, workspace string, keyword string,
}
if len(devOpsProjects) < offset {
return len(devOpsProjects), devOpsProjects, nil
return len(devOpsProjects), make([]DevopsProject, 0), nil
} else if len(devOpsProjects) < limit+offset {
return len(devOpsProjects), devOpsProjects[offset:], nil
} else {
@@ -842,9 +848,15 @@ func Roles(workspace *Workspace) ([]*v1.ClusterRole, error) {
return roles, nil
}
func GetWorkspaceMembers(workspace string) ([]iam.User, error) {
func GetWorkspaceMembers(workspace string, keyword string) ([]iam.User, error) {
result, err := http.Get(fmt.Sprintf("http://%s/apis/account.kubesphere.io/v1alpha1/groups/%s/users", constants.AccountAPIServer, workspace))
url := fmt.Sprintf("http://%s/apis/account.kubesphere.io/v1alpha1/workspaces/%s/members", constants.AccountAPIServer, workspace)
if keyword != "" {
url = url + "?keyword=" + keyword
}
result, err := http.Get(url)
if err != nil {
return nil, err