mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
增加climc policy-admin-capable命令
This commit is contained in:
@@ -184,6 +184,18 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyAdminCapableOptions struct {
|
||||
}
|
||||
R(&PolicyAdminCapableOptions{}, "policy-admin-capable", "Check admin capable", func(s *mcclient.ClientSession, args *PolicyAdminCapableOptions) error {
|
||||
auth.InitFromClientSession(s)
|
||||
policy.EnableGlobalRbac(15*time.Second, 15*time.Second)
|
||||
|
||||
capable := policy.PolicyManager.IsAdminCapable(s.GetToken())
|
||||
fmt.Printf("%v\n", capable)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
type PolicyExplainOptions struct {
|
||||
Request []string `help:"explain request, in format of key:is_admin:service:resource:action:extra"`
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
)
|
||||
|
||||
func EnableGlobalRbac(refreshInterval time.Duration, retryInterval time.Duration) {
|
||||
consts.EnableRbac()
|
||||
PolicyManager.start(refreshInterval, retryInterval)
|
||||
if !consts.IsRbacEnabled() {
|
||||
consts.EnableRbac()
|
||||
PolicyManager.start(refreshInterval, retryInterval)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,8 +200,8 @@ type TaskManager struct {
|
||||
func NewTaskManager(stopCh <-chan struct{}) *TaskManager {
|
||||
return &TaskManager{
|
||||
taskExecutorQueueManager: NewTaskExecutorQueueManager(stopCh),
|
||||
stopCh: stopCh,
|
||||
lock: sync.Mutex{},
|
||||
stopCh: stopCh,
|
||||
lock: sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user