37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
user.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
dax 提交于 2019-05-06 09:14 . Fix default admin stuck in removing
package clusterauthtoken
import (
clusterv3 "github.com/rancher/types/apis/cluster.cattle.io/v3"
managementv3 "github.com/rancher/types/apis/management.cattle.io/v3"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
)
type userHandler struct {
namespace string
clusterUserAttribute clusterv3.ClusterUserAttributeInterface
clusterUserAttributeLister clusterv3.ClusterUserAttributeLister
}
func (h *userHandler) Sync(key string, user *managementv3.User) (runtime.Object, error) {
if user == nil || user.DeletionTimestamp != nil {
return nil, nil
}
clusterUserAttribute, err := h.clusterUserAttributeLister.Get(h.namespace, user.Name)
if errors.IsNotFound(err) {
return nil, nil
}
if err != nil {
return nil, err
}
userEnabled := user.Enabled == nil || *user.Enabled
if clusterUserAttribute.Enabled == userEnabled {
return nil, nil
}
clusterUserAttribute.Enabled = userEnabled
_, err = h.clusterUserAttribute.Update(clusterUserAttribute)
return nil, err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.5

搜索帮助