mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-19 04:26:45 +00:00
feat: upstream enterprise preview --------- Signed-off-by: Oliver Baehler <oliver@sudo-i.net> Co-authored-by: CorentinPtrl <pitrel.corentin@gmail.com>
47 lines
1.2 KiB
Go
47 lines
1.2 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 = (&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
|
|
}
|