()
| 69 | } |
| 70 | |
| 71 | func initLogging() { |
| 72 | debug := strings.TrimSpace(os.Getenv("CRUNCHY_DEBUG")) |
| 73 | |
| 74 | var verbosity int |
| 75 | if strings.EqualFold(debug, "true") { |
| 76 | verbosity = 1 |
| 77 | } else if i, err := strconv.Atoi(debug); err == nil && i > 0 { |
| 78 | verbosity = i |
| 79 | } |
| 80 | |
| 81 | // Configure a singleton that treats logging.Logger.V(1) as logrus.DebugLevel. |
| 82 | logging.SetLogSink(logging.Logrus(os.Stdout, versionString, 1, verbosity)) |
| 83 | |
| 84 | global := logging.FromContext(context.Background()) |
| 85 | runtime.SetLogger(global) |
| 86 | |
| 87 | // [k8s.io/client-go/tools/leaderelection] logs to the global [klog] instance. |
| 88 | // - https://github.com/kubernetes-sigs/controller-runtime/issues/2656 |
| 89 | klog.SetLoggerWithOptions(global, klog.ContextualLogger(true)) |
| 90 | } |
| 91 | |
| 92 | //+kubebuilder:rbac:groups="coordination.k8s.io",resources="leases",verbs={get,create,update,watch} |
| 93 | //+kubebuilder:rbac:groups="authentication.k8s.io",resources="tokenreviews",verbs={create} |
no test coverage detected