Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
21c2e492
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
21c2e492
编写于
5月 06, 2019
作者:
R
runzexia
提交者:
zryfish
5月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete user in devops
上级
7748ad8f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
1 deletion
+54
-1
cmd/ks-iam/app/server.go
cmd/ks-iam/app/server.go
+13
-0
pkg/gojenkins/jenkins.go
pkg/gojenkins/jenkins.go
+16
-0
pkg/models/iam/im.go
pkg/models/iam/im.go
+24
-0
pkg/simple/client/devops_mysql/mysql.go
pkg/simple/client/devops_mysql/mysql.go
+1
-1
未找到文件。
cmd/ks-iam/app/server.go
浏览文件 @
21c2e492
...
...
@@ -29,6 +29,8 @@ import (
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/iam"
"kubesphere.io/kubesphere/pkg/signals"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"kubesphere.io/kubesphere/pkg/utils/jwtutil"
"log"
"net/http"
...
...
@@ -69,6 +71,9 @@ func Run(s *options.ServerRunOptions) error {
waitForResourceSync
()
initializeAdminJenkins
()
initializeDevOpsDatabase
()
err
=
iam
.
Init
(
s
.
AdminEmail
,
s
.
AdminPassword
,
expireTime
)
jwtutil
.
Setup
(
s
.
JWTSecret
)
...
...
@@ -119,3 +124,11 @@ func waitForResourceSync() {
ksInformerFactory
.
WaitForCacheSync
(
stopChan
)
log
.
Println
(
"resources sync success"
)
}
func
initializeAdminJenkins
()
{
admin_jenkins
.
Client
()
}
func
initializeDevOpsDatabase
()
{
devops_mysql
.
OpenDatabase
()
}
pkg/gojenkins/jenkins.go
浏览文件 @
21c2e492
...
...
@@ -1034,6 +1034,22 @@ func (j *Jenkins) AddProjectRole(roleName string, pattern string, ids ProjectPer
return
responseRole
,
nil
}
func
(
j
*
Jenkins
)
DeleteUserInProject
(
username
string
)
error
{
param
:=
map
[
string
]
string
{
"type"
:
PROJECT_ROLE
,
"sid"
:
username
,
}
responseString
:=
""
response
,
err
:=
j
.
Requester
.
Post
(
"/role-strategy/strategy/deleteSid"
,
nil
,
&
responseString
,
param
)
if
err
!=
nil
{
return
err
}
if
response
.
StatusCode
!=
http
.
StatusOK
{
return
errors
.
New
(
strconv
.
Itoa
(
response
.
StatusCode
))
}
return
nil
}
func
(
j
*
Jenkins
)
GetQueueItem
(
number
int64
)
(
*
QueueItemResponse
,
error
)
{
responseItem
:=
&
QueueItemResponse
{}
response
,
err
:=
j
.
Requester
.
GetJSON
(
fmt
.
Sprintf
(
"/queue/item/%s"
,
strconv
.
FormatInt
(
number
,
10
)),
...
...
pkg/models/iam/im.go
浏览文件 @
21c2e492
...
...
@@ -23,10 +23,14 @@ import (
"fmt"
"io/ioutil"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/db"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/devops"
"kubesphere.io/kubesphere/pkg/models/kubeconfig"
"kubesphere.io/kubesphere/pkg/models/kubectl"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/simple/client/admin_jenkins"
"kubesphere.io/kubesphere/pkg/simple/client/devops_mysql"
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
"kubesphere.io/kubesphere/pkg/simple/client/redis"
"kubesphere.io/kubesphere/pkg/utils/k8sutil"
...
...
@@ -545,7 +549,27 @@ func DeleteUser(username string) error {
glog
.
Errorln
(
"delete user terminal pod failed"
,
username
,
err
)
}
devopsDb
:=
devops_mysql
.
OpenDatabase
()
jenkinsClient
:=
admin_jenkins
.
Client
()
_
,
err
=
devopsDb
.
DeleteFrom
(
devops
.
DevOpsProjectMembershipTableName
)
.
Where
(
db
.
And
(
db
.
Eq
(
devops
.
DevOpsProjectMembershipUsernameColumn
,
username
),
))
.
Exec
()
if
err
!=
nil
{
glog
.
Errorf
(
"%+v"
,
err
)
return
err
}
err
=
jenkinsClient
.
DeleteUserInProject
(
username
)
if
err
!=
nil
{
glog
.
Errorf
(
"%+v"
,
err
)
return
err
}
return
nil
}
func
deleteRoleBindings
(
username
string
)
error
{
...
...
pkg/simple/client/devops_mysql/mysql.go
浏览文件 @
21c2e492
...
...
@@ -30,7 +30,7 @@ var (
)
func
init
()
{
flag
.
StringVar
(
&
dsn
,
"devops-database-connection"
,
"root
@tcp(127.0.0.1
:3306)/devops"
,
"data source name"
)
flag
.
StringVar
(
&
dsn
,
"devops-database-connection"
,
"root
:password@tcp(openpitrix-db.openpitrix-system.svc
:3306)/devops"
,
"data source name"
)
}
var
defaultEventReceiver
=
db
.
EventReceiver
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录