()
| 75 | } |
| 76 | |
| 77 | func main() { |
| 78 | var metricsAddr string |
| 79 | var enableLeaderElection bool |
| 80 | var probeAddr string |
| 81 | var interval time.Duration |
| 82 | |
| 83 | flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") |
| 84 | flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") |
| 85 | flag.BoolVar(&enableLeaderElection, "leader-elect", false, |
| 86 | "Enable leader election for controller manager. "+ |
| 87 | "Enabling this will ensure there is only one active controller manager.") |
| 88 | flag.DurationVar(&interval, "builder-check-interval", time.Minute, "The interval used to check the expired builder") |
| 89 | |
| 90 | // Use `--zap-log-level=debug` to enable debug log. |
| 91 | opts := zap.Options{ |
| 92 | Development: true, |
| 93 | StacktraceLevel: zapcore.PanicLevel, |
| 94 | TimeEncoder: zapcore.RFC3339TimeEncoder, |
| 95 | } |
| 96 | opts.BindFlags(flag.CommandLine) |
| 97 | flag.Parse() |
| 98 | |
| 99 | ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) |
| 100 | |
| 101 | mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ |
| 102 | Scheme: scheme, |
| 103 | MetricsBindAddress: metricsAddr, |
| 104 | Port: 9443, |
| 105 | HealthProbeBindAddress: probeAddr, |
| 106 | LeaderElection: enableLeaderElection, |
| 107 | LeaderElectionID: "79f0111e.openfunction.io", |
| 108 | }) |
| 109 | if err != nil { |
| 110 | setupLog.Error(err, "unable to start manager") |
| 111 | os.Exit(1) |
| 112 | } |
| 113 | |
| 114 | eventsV1Client, err := typedeventsv1.NewForConfig(ctrl.GetConfigOrDie()) |
| 115 | if err != nil { |
| 116 | setupLog.Error(err, "unable to get events client") |
| 117 | os.Exit(1) |
| 118 | } |
| 119 | eventBroadcaster := events.NewBroadcaster(&events.EventSinkImpl{Interface: eventsV1Client}) |
| 120 | termCh := make(chan os.Signal, 1) |
| 121 | signal.Notify(termCh, os.Interrupt, syscall.SIGTERM) |
| 122 | stopCh := make(chan struct{}, 1) |
| 123 | go func() { |
| 124 | for { |
| 125 | select { |
| 126 | case <-termCh: |
| 127 | stopCh <- struct{}{} |
| 128 | return |
| 129 | } |
| 130 | } |
| 131 | }() |
| 132 | eventBroadcaster.StartRecordingToSink(stopCh) |
| 133 | eventRecorder := eventBroadcaster.NewRecorder(mgr.GetScheme(), "openfunction") |
| 134 |
nothing calls this directly
no test coverage detected