forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.go
37 lines (29 loc) · 900 Bytes
/
nodes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package noderemove
import (
"context"
"k8s.io/apimachinery/pkg/runtime"
"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(ctx context.Context, userContext *config.UserContext) {
nsh := &nodeRemove{
userNodes: userContext.Core.Nodes(""),
}
userContext.Management.Management.Nodes(userContext.ClusterName).AddClusterScopedLifecycle(ctx, "user-node-remove", userContext.ClusterName, nsh)
}
func (n *nodeRemove) Create(obj *v3.Node) (runtime.Object, error) {
return obj, nil
}
func (n *nodeRemove) Remove(obj *v3.Node) (runtime.Object, error) {
if obj.Status.NodeName != "" {
n.userNodes.Delete(obj.Status.NodeName, nil)
}
return obj, nil
}
func (n *nodeRemove) Updated(obj *v3.Node) (runtime.Object, error) {
return obj, nil
}