mirror of
https://github.com/kyverno/kyverno.git
synced 2025-01-20 18:52:16 +00:00
835f5551b7
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
31 lines
892 B
Go
31 lines
892 B
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-logr/logr"
|
|
"github.com/kyverno/kyverno/pkg/metrics"
|
|
)
|
|
|
|
func shutdown(logger logr.Logger, sdowns ...context.CancelFunc) context.CancelFunc {
|
|
return func() {
|
|
for i := range sdowns {
|
|
if sdowns[i] != nil {
|
|
logger.Info("shutting down...")
|
|
defer sdowns[i]()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func Setup(name string) (context.Context, logr.Logger, metrics.MetricsConfigManager, context.CancelFunc) {
|
|
logger := SetupLogger()
|
|
ShowVersion(logger)
|
|
sdownMaxProcs := SetupMaxProcs(logger)
|
|
SetupProfiling(logger)
|
|
client := CreateKubernetesClient(logger)
|
|
ctx, sdownSignals := SetupSignals(logger)
|
|
metricsManager, sdownMetrics := SetupMetrics(ctx, logger, client)
|
|
sdownTracing := SetupTracing(logger, name, client)
|
|
return ctx, logger, metricsManager, shutdown(logger.WithName("shutdown"), sdownMaxProcs, sdownMetrics, sdownTracing, sdownSignals)
|
|
}
|