forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.go
37 lines (29 loc) · 913 Bytes
/
controller.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 usercontrollers
import (
"context"
"github.com/rancher/rancher/pkg/clustermanager"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
)
func Register(ctx context.Context, management *config.ManagementContext, manager *clustermanager.Manager) {
lifecycle := &ClusterLifecycle{
Manager: manager,
ctx: ctx,
}
clusterClient := management.Management.Clusters("")
clusterClient.AddLifecycle("cluster-agent-controller", lifecycle)
}
type ClusterLifecycle struct {
Manager *clustermanager.Manager
ctx context.Context
}
func (c *ClusterLifecycle) Create(obj *v3.Cluster) (*v3.Cluster, error) {
return nil, nil
}
func (c *ClusterLifecycle) Remove(obj *v3.Cluster) (*v3.Cluster, error) {
c.Manager.Stop(obj)
return nil, nil
}
func (c *ClusterLifecycle) Updated(obj *v3.Cluster) (*v3.Cluster, error) {
return nil, c.Manager.Start(c.ctx, obj)
}