MCPcopy
hub / github.com/operator-framework/operator-sdk / Add

Function Add

internal/helm/controller/controller.go:60–96  ·  view source on GitHub ↗

Add creates a new helm operator controller and adds it to the manager

(mgr manager.Manager, options WatchOptions)

Source from the content-addressed store, hash-verified

58
59// Add creates a new helm operator controller and adds it to the manager
60func Add(mgr manager.Manager, options WatchOptions) error {
61 controllerName := fmt.Sprintf("%v-controller", strings.ToLower(options.GVK.Kind))
62
63 r := &HelmOperatorReconciler{
64 Client: mgr.GetClient(),
65 EventRecorder: mgr.GetEventRecorderFor(controllerName),
66 GVK: options.GVK,
67 ManagerFactory: options.ManagerFactory,
68 ReconcilePeriod: options.ReconcilePeriod,
69 OverrideValues: options.OverrideValues,
70 SuppressOverrideValues: options.SuppressOverrideValues,
71 DryRunOption: options.DryRunOption,
72 }
73
74 c, err := controller.New(controllerName, mgr, controller.Options{
75 Reconciler: r,
76 MaxConcurrentReconciles: options.MaxConcurrentReconciles,
77 })
78 if err != nil {
79 return err
80 }
81
82 o := &unstructured.Unstructured{}
83 o.SetGroupVersionKind(options.GVK)
84
85 if err := c.Watch(source.Kind(mgr.GetCache(), client.Object(o), &libhandler.InstrumentedEnqueueRequestForObject[client.Object]{})); err != nil {
86 return err
87 }
88
89 if options.WatchDependentResources {
90 watchDependentResources(mgr, r, c)
91 }
92
93 log.Info("Watching resource", "apiVersion", options.GVK.GroupVersion(), "kind",
94 options.GVK.Kind, "reconcilePeriod", options.ReconcilePeriod.String())
95 return nil
96}
97
98// watchDependentResources adds a release hook function to the HelmOperatorReconciler
99// that adds watches for resources in released Helm charts.

Callers 1

runFunction · 0.92

Calls 3

watchDependentResourcesFunction · 0.85
WatchMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected