mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-21 05:26:56 +00:00
* feat: replicating resources upon namespace creation This feature enhances the (Global)TenantResource replication by triggering a replication of resources upon a Namespace creation: this speeds up the replication of resources without waiting for the resyncPeriod that could be delayed for several reasons. Signed-off-by: Dario Tranchitella <dario@tranchitella.eu> * fix: addressing fix from github copilot Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Dario Tranchitella <dario@tranchitella.eu> --------- Signed-off-by: Dario Tranchitella <dario@tranchitella.eu> Co-authored-by: Oliver Bähler <26610571+oliverbaehler@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
// Copyright 2020-2026 Project Capsule Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package resources
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-logr/logr"
|
|
"sigs.k8s.io/controller-runtime/pkg/manager"
|
|
|
|
"github.com/projectcapsule/capsule/internal/cache"
|
|
"github.com/projectcapsule/capsule/internal/controllers/utils"
|
|
"github.com/projectcapsule/capsule/internal/metrics"
|
|
"github.com/projectcapsule/capsule/pkg/runtime/configuration"
|
|
)
|
|
|
|
func Add(
|
|
log logr.Logger,
|
|
mgr manager.Manager,
|
|
configuration configuration.Configuration,
|
|
opts utils.ControllerOptions,
|
|
cache *cache.ImpersonationCache,
|
|
) (err error) {
|
|
if err = (&NamespaceTrigger{
|
|
log: log.WithName("Global"),
|
|
configuration: configuration,
|
|
impersonation: cache,
|
|
}).SetupWithManager(mgr, opts); err != nil {
|
|
return fmt.Errorf("unable to create watcher controller: %w", err)
|
|
}
|
|
|
|
if err = (&globalResourceController{
|
|
log: log.WithName("Global"),
|
|
configuration: configuration,
|
|
metrics: metrics.MustMakeGlobalTenantResourceRecorder(),
|
|
|
|
impersonation: cache,
|
|
}).SetupWithManager(mgr, opts); err != nil {
|
|
return fmt.Errorf("unable to create global controller: %w", err)
|
|
}
|
|
|
|
if err = (&namespacedResourceController{
|
|
log: log.WithName("Namespaced"),
|
|
configuration: configuration,
|
|
metrics: metrics.MustMakeTenantResourceRecorder(),
|
|
|
|
impersonation: cache,
|
|
}).SetupWithManager(mgr, opts); err != nil {
|
|
return fmt.Errorf("unable to create namespaced controller: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|