|
1 | 1 | package run
|
2 | 2 |
|
3 | 3 | import (
|
| 4 | + "github.com/dapr-sandbox/dapr-kubernetes-operator/pkg/resources" |
| 5 | + "github.com/pkg/errors" |
4 | 6 | "github.com/spf13/cobra"
|
| 7 | + admregv1 "k8s.io/api/admissionregistration/v1" |
| 8 | + appsv1 "k8s.io/api/apps/v1" |
| 9 | + corev1 "k8s.io/api/core/v1" |
| 10 | + rbacv1 "k8s.io/api/rbac/v1" |
| 11 | + rtcache "sigs.k8s.io/controller-runtime/pkg/cache" |
| 12 | + rtclient "sigs.k8s.io/controller-runtime/pkg/client" |
5 | 13 | "sigs.k8s.io/controller-runtime/pkg/manager"
|
6 | 14 |
|
7 | 15 | "github.com/dapr-sandbox/dapr-kubernetes-operator/pkg/controller"
|
@@ -38,13 +46,34 @@ func NewRunCmd() *cobra.Command {
|
38 | 46 | Use: "run",
|
39 | 47 | Short: "run",
|
40 | 48 | RunE: func(cmd *cobra.Command, args []string) error {
|
| 49 | + selector, err := daprCtl.ReleaseSelector() |
| 50 | + if err != nil { |
| 51 | + return errors.Wrap(err, "unable to compute cache's watch selector") |
| 52 | + } |
| 53 | + |
| 54 | + controllerOpts.WatchSelectors = map[rtclient.Object]rtcache.ByObject{ |
| 55 | + // k8s |
| 56 | + &rbacv1.ClusterRole{}: {Label: selector}, |
| 57 | + &rbacv1.ClusterRoleBinding{}: {Label: selector}, |
| 58 | + &rbacv1.Role{}: {Label: selector}, |
| 59 | + &rbacv1.RoleBinding{}: {Label: selector}, |
| 60 | + &admregv1.MutatingWebhookConfiguration{}: {Label: selector}, |
| 61 | + &corev1.Secret{}: {Label: selector}, |
| 62 | + &corev1.Service{}: {Label: selector}, |
| 63 | + &corev1.ServiceAccount{}: {Label: selector}, |
| 64 | + &appsv1.StatefulSet{}: {Label: selector}, |
| 65 | + &appsv1.Deployment{}: {Label: selector}, |
| 66 | + // dapr |
| 67 | + resources.UnstructuredFor("dapr.io", "v1alpha1", "Configuration"): {Label: selector}, |
| 68 | + } |
| 69 | + |
41 | 70 | return controller.Start(controllerOpts, func(manager manager.Manager, opts controller.Options) error {
|
42 | 71 | _, err := daprCtl.NewReconciler(cmd.Context(), manager, helmOpts)
|
43 | 72 | if err != nil {
|
44 |
| - return err |
| 73 | + return errors.Wrap(err, "unable to set-up DaprControlPlane reconciler") |
45 | 74 | }
|
46 | 75 |
|
47 |
| - return err |
| 76 | + return nil |
48 | 77 | })
|
49 | 78 | },
|
50 | 79 | }
|
|
0 commit comments