36 Star 395 Fork 71

GVPrancher / rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
user_attribute_handler.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 2019-06-12 13:38 . goimport linting changes
package auth
import (
"github.com/rancher/rancher/pkg/auth/providerrefresh"
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
"k8s.io/apimachinery/pkg/runtime"
)
const (
userAttributeController = "mgmt-auth-userattributes-controller"
)
type UserAttributeController struct {
userAttributes v3.UserAttributeInterface
}
func newUserAttributeController(mgmt *config.ManagementContext) *UserAttributeController {
ua := &UserAttributeController{
userAttributes: mgmt.Management.UserAttributes(""),
}
return ua
}
//sync is called periodically and on real updates
func (ua *UserAttributeController) sync(key string, obj *v3.UserAttribute) (runtime.Object, error) {
if obj == nil || obj.DeletionTimestamp != nil {
return nil, nil
}
if !obj.NeedsRefresh {
return obj, nil
}
obj, err := providerrefresh.RefreshAttributes(obj)
if err != nil {
return nil, err
}
updated, err := ua.userAttributes.Update(obj)
if err != nil {
return nil, err
}
return updated, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891