1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-01-20 18:52:16 +00:00
kyverno/cmd/internal/setup.go
Charles-Edouard Brétéché 835f5551b7
fix: tracing attributes length and tracer name (#6117)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-01-26 09:39:52 +00:00

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)
}