()
| 48 | } |
| 49 | |
| 50 | func main() { |
| 51 | var metricsAddr string |
| 52 | var enableLeaderElection bool |
| 53 | var probeAddr string |
| 54 | flag.StringVar(&metricsAddr, "metrics-bind-address", ":8081", "The address the metric endpoint binds to.") |
| 55 | flag.StringVar(&probeAddr, "health-probe-bind-address", ":8082", "The address the probe endpoint binds to.") |
| 56 | flag.BoolVar(&enableLeaderElection, "leader-elect", false, |
| 57 | "Enable leader election for controller manager. "+ |
| 58 | "Enabling this will ensure there is only one active controller manager.") |
| 59 | opts := zap.Options{ |
| 60 | Development: true, |
| 61 | } |
| 62 | opts.BindFlags(flag.CommandLine) |
| 63 | flag.Parse() |
| 64 | |
| 65 | ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) |
| 66 | |
| 67 | setupLog.Info("starting handler") |
| 68 | |
| 69 | telemetryClient, _ := telemetry.NewClient( |
| 70 | getEnvBool("DISABLE_TELEMETRY"), |
| 71 | os.Getenv("CYCLOPS_VERSION"), |
| 72 | os.Getenv("INSTALL_MANAGER"), |
| 73 | setupLog, |
| 74 | ) |
| 75 | telemetryClient.InstanceStart() |
| 76 | |
| 77 | watchNamespace := getWatchNamespace() |
| 78 | helmWatchNamespace := getHelmWatchNamespace() |
| 79 | moduleTargetNamespace := getModuleTargetNamespace() |
| 80 | |
| 81 | k8sClient, err := k8sclient.New( |
| 82 | watchNamespace, |
| 83 | helmWatchNamespace, |
| 84 | moduleTargetNamespace, |
| 85 | zap.New(zap.UseFlagOptions(&opts)), |
| 86 | ) |
| 87 | if err != nil { |
| 88 | fmt.Println("error bootstrapping Kubernetes client", err) |
| 89 | panic(err) |
| 90 | } |
| 91 | |
| 92 | credsResolver := auth.NewTemplatesResolver(k8sClient) |
| 93 | |
| 94 | templatesRepo := template.NewRepo( |
| 95 | credsResolver, |
| 96 | cache.NewInMemoryTemplatesCache(), |
| 97 | ) |
| 98 | |
| 99 | monitor, err := prometheus.NewMonitor(setupLog) |
| 100 | if err != nil { |
| 101 | setupLog.Error(err, "failed to set up prom monitor") |
| 102 | } |
| 103 | |
| 104 | renderer := render.NewRenderer(k8sClient) |
| 105 | |
| 106 | prometheus.StartCacheMetricsUpdater(&monitor, templatesRepo.ReturnCache(), 10*time.Second, setupLog) |
| 107 |
nothing calls this directly
no test coverage detected
searching dependent graphs…