37 Star 396 Fork 71

GVPrancher / rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
nodes.go 808 Bytes
一键复制 编辑 原始数据 按行查看 历史
package noderemove
import (
"github.com/rancher/types/apis/core/v1"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
)
type nodeRemove struct {
userNodes v1.NodeInterface
}
func Register(userContext *config.UserContext) {
nsh := &nodeRemove{
userNodes: userContext.Core.Nodes(""),
}
userContext.Management.Management.Nodes(userContext.ClusterName).AddClusterScopedLifecycle("user-node-remove", userContext.ClusterName, nsh)
}
func (n *nodeRemove) Create(obj *v3.Node) (*v3.Node, error) {
return obj, nil
}
func (n *nodeRemove) Remove(obj *v3.Node) (*v3.Node, error) {
if obj.Status.NodeName != "" {
n.userNodes.Delete(obj.Status.NodeName, nil)
}
return obj, nil
}
func (n *nodeRemove) Updated(obj *v3.Node) (*v3.Node, error) {
return obj, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.3-rc3

搜索帮助

344bd9b3 5694891 D2dac590 5694891