forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd.go
More file actions
56 lines (48 loc) · 1.94 KB
/
add.go
File metadata and controls
56 lines (48 loc) · 1.94 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
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package controllerinstallation
import (
"context"
"fmt"
"sigs.k8s.io/controller-runtime/pkg/cluster"
"sigs.k8s.io/controller-runtime/pkg/manager"
gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
"github.com/gardener/gardener/pkg/client/kubernetes"
gardenletconfigv1alpha1 "github.com/gardener/gardener/pkg/gardenlet/apis/config/v1alpha1"
"github.com/gardener/gardener/pkg/gardenlet/controller/controllerinstallation/care"
"github.com/gardener/gardener/pkg/gardenlet/controller/controllerinstallation/controllerinstallation"
"github.com/gardener/gardener/pkg/gardenlet/controller/controllerinstallation/required"
)
// AddToManager adds all ControllerInstallation controllers to the given manager.
func AddToManager(
ctx context.Context,
mgr manager.Manager,
gardenCluster cluster.Cluster,
seedCluster cluster.Cluster,
seedClientSet kubernetes.Interface,
cfg gardenletconfigv1alpha1.GardenletConfiguration,
identity *gardencorev1beta1.Gardener,
gardenClusterIdentity string,
) error {
if err := (&care.Reconciler{
Config: *cfg.Controllers.ControllerInstallationCare,
}).AddToManager(mgr, gardenCluster, seedCluster); err != nil {
return fmt.Errorf("failed adding care reconciler: %w", err)
}
if err := (&controllerinstallation.Reconciler{
SeedClientSet: seedClientSet,
Config: cfg,
Identity: identity,
GardenClusterIdentity: gardenClusterIdentity,
}).AddToManager(ctx, mgr, gardenCluster); err != nil {
return fmt.Errorf("failed adding main reconciler: %w", err)
}
if err := (&required.Reconciler{
Config: *cfg.Controllers.ControllerInstallationRequired,
SeedName: cfg.SeedConfig.SeedTemplate.Name,
}).AddToManager(mgr, gardenCluster, seedCluster); err != nil {
return fmt.Errorf("failed adding required reconciler: %w", err)
}
return nil
}