36 Star 395 Fork 71

GVPrancher / rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cluster_user_attribute.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
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/runtime"
)
type ClusterUserAttributeHandler struct {
userAttribute managementv3.UserAttributeInterface
userAttributeLister managementv3.UserAttributeLister
}
func (h *ClusterUserAttributeHandler) Sync(key string, clusterUserAttribute *clusterv3.ClusterUserAttribute) (runtime.Object, error) {
if clusterUserAttribute == nil || clusterUserAttribute.DeletionTimestamp != nil {
return nil, nil
}
if !clusterUserAttribute.NeedsRefresh {
return nil, nil
}
userAttribute, err := h.userAttributeLister.Get("", clusterUserAttribute.Name)
if err != nil {
return nil, err
}
if userAttribute.NeedsRefresh {
return nil, nil
}
if userAttribute.LastRefresh != clusterUserAttribute.LastRefresh {
return nil, nil
}
userAttribute.NeedsRefresh = true
_, err = h.userAttribute.Update(userAttribute)
return nil, err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.2-rc7

搜索帮助

344bd9b3 5694891 D2dac590 5694891