/
add.go
38 lines (32 loc) · 1.34 KB
/
add.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
38
package infrastructure
import (
"github.com/gardener/gardener/extensions/pkg/controller/infrastructure"
"github.com/metal-stack/gardener-extension-provider-metal/pkg/metal"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
var (
// DefaultAddOptions are the default AddOptions for AddToManager.
DefaultAddOptions = AddOptions{}
)
// AddOptions are options to apply when adding the metal infrastructure controller to the manager.
type AddOptions struct {
// Controller are the controller.Options.
Controller controller.Options
// IgnoreOperationAnnotation specifies whether to ignore the operation annotation or not.
IgnoreOperationAnnotation bool
}
// AddToManagerWithOptions adds a controller with the given Options to the given manager.
// The opts.Reconciler is being set with a newly instantiated actuator.
func AddToManagerWithOptions(mgr manager.Manager, opts AddOptions) error {
return infrastructure.Add(mgr, infrastructure.AddArgs{
Actuator: NewActuator(),
ControllerOptions: opts.Controller,
Predicates: infrastructure.DefaultPredicates(opts.IgnoreOperationAnnotation),
Type: metal.Type,
})
}
// AddToManager adds a controller with the default Options.
func AddToManager(mgr manager.Manager) error {
return AddToManagerWithOptions(mgr, DefaultAddOptions)
}