forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enqueue.go
31 lines (27 loc) · 914 Bytes
/
enqueue.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
package multiclusterapp
import (
"context"
"github.com/rancher/rancher/pkg/namespace"
"github.com/rancher/types/apis/management.cattle.io/v3"
pv3 "github.com/rancher/types/apis/project.cattle.io/v3"
"github.com/rancher/types/config"
"k8s.io/apimachinery/pkg/runtime"
)
func StartMCAppEnqueueController(ctx context.Context, management *config.ManagementContext) {
m := MCAppEnqueueController{
mcApps: management.Management.MultiClusterApps(""),
}
management.Project.Apps("").AddHandler(ctx, "management-mcapp-enqueue-controller", m.sync)
}
type MCAppEnqueueController struct {
mcApps v3.MultiClusterAppInterface
}
func (m *MCAppEnqueueController) sync(key string, app *pv3.App) (runtime.Object, error) {
if app == nil {
return app, nil
}
if mcappName, ok := app.Labels[MultiClusterAppIDSelector]; ok {
m.mcApps.Controller().Enqueue(namespace.GlobalNamespace, mcappName)
}
return app, nil
}