-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadd.go
More file actions
65 lines (56 loc) · 2.76 KB
/
add.go
File metadata and controls
65 lines (56 loc) · 2.76 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package controlplane
import (
"context"
extensionscontroller "github.com/gardener/gardener/extensions/pkg/controller"
"github.com/gardener/gardener/extensions/pkg/controller/controlplane"
"github.com/gardener/gardener/extensions/pkg/controller/controlplane/genericactuator"
"github.com/gardener/gardener/extensions/pkg/util"
extensionsv1alpha1 "github.com/gardener/gardener/pkg/apis/extensions/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/manager"
"github.com/stackitcloud/gardener-extension-provider-stackit/v2/imagevector"
"github.com/stackitcloud/gardener-extension-provider-stackit/v2/pkg/stackit"
)
var (
// DefaultAddOptions are the default AddOptions for AddToManager.
DefaultAddOptions = AddOptions{}
)
// AddOptions are options to apply when adding the OpenStack controlplane 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
// WebhookServerNamespace is the namespace in which the webhook server runs.
WebhookServerNamespace string
// ExtensionClass defines the extension class this extension is responsible for.
ExtensionClasses []extensionsv1alpha1.ExtensionClass
// CustomLabelDomain is the domain prefix for custom labels applied to STACKIT infrastructure resources.
CustomLabelDomain string
}
// 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(ctx context.Context, mgr manager.Manager, opts AddOptions) error {
genericActuator, err := genericactuator.NewActuator(mgr, stackit.Name,
secretConfigsFunc, shootAccessSecretsFunc,
configChart, controlPlaneChart, controlPlaneShootChart, controlPlaneShootCRDsChart, storageClassChart,
NewValuesProvider(mgr, opts.CustomLabelDomain), extensionscontroller.ChartRendererFactoryFunc(util.NewChartRendererForShoot),
imagevector.ImageVector(), "", nil, opts.WebhookServerNamespace)
if err != nil {
return err
}
return controlplane.Add(mgr, controlplane.AddArgs{
Actuator: genericActuator,
ControllerOptions: opts.Controller,
Predicates: controlplane.DefaultPredicates(ctx, mgr, opts.IgnoreOperationAnnotation),
Type: stackit.Type,
ExtensionClasses: opts.ExtensionClasses,
})
}
// AddToManager adds a controller with the default Options.
func AddToManager(ctx context.Context, mgr manager.Manager) error {
return AddToManagerWithOptions(ctx, mgr, DefaultAddOptions)
}