mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
8f6c3e648c
* feat: add dynamic client support to internal cmd package Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * Update cmd/internal/client.go Signed-off-by: shuting <shutting06@gmail.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: shuting <shutting06@gmail.com> Co-authored-by: shuting <shutting06@gmail.com>
28 lines
782 B
Go
28 lines
782 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 {
|
|
logger.Info("shuting down...")
|
|
defer sdowns[i]()
|
|
}
|
|
}
|
|
}
|
|
|
|
func Setup() (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)
|
|
return ctx, logger, metricsManager, shutdown(logger.WithName("shutdown"), sdownMaxProcs, sdownMetrics, sdownSignals)
|
|
}
|