MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / main

Function main

webhook/main.go:71–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71func main() {
72 logf.SetLogger(zap.New(zap.UseDevMode(config.GetDevModeEnabled())))
73
74 var metricsAddr string
75 flag.StringVar(&metricsAddr, "metrics-addr", ":9443", "The address the metric endpoint binds to.")
76 flag.Parse()
77
78 // Print versions
79 log.Info(fmt.Sprintf("Operator Version: %s", version.Version))
80 log.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
81 log.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
82 log.Info(fmt.Sprintf("Commit: %s", version.Commit))
83 log.Info(fmt.Sprintf("BuildTime: %s", version.BuildTime))
84
85 // Get a config to talk to the apiserver
86 cfg, err := clientconfig.GetConfig()
87 if err != nil {
88 log.Error(err, "")
89 os.Exit(1)
90 }
91
92 namespace, err := infrastructure.GetWatchNamespace()
93 if err != nil {
94 log.Error(err, "Failed to get watch namespace")
95 os.Exit(1)
96 }
97
98 cacheFunc, err := cache.GetWebhooksCacheFunc(namespace)
99 if err != nil {
100 log.Error(err, "failed to set up objects cache")
101 os.Exit(1)
102 }
103
104 webhookServer := webhook.NewServer(webhook.Options{
105 CertDir: server.WebhookServerCertDir,
106 Port: server.WebhookServerPort,
107 Host: server.WebhookServerHost,
108 })
109
110 // Create a new Cmd to provide shared dependencies and start components
111 mgr, err := ctrl.NewManager(cfg, ctrl.Options{
112 Scheme: scheme,
113 Metrics: metricsserver.Options{
114 BindAddress: metricsAddr,
115 FilterProvider: filters.WithAuthenticationAndAuthorization,
116 SecureServing: true,
117 },
118 WebhookServer: webhookServer,
119 HealthProbeBindAddress: ":6789",
120 NewCache: cacheFunc,
121 })
122 if err != nil {
123 log.Error(err, "Failed to create manager")
124 os.Exit(1)
125 }
126
127 err = createWebhooks(mgr)
128 if err != nil {

Callers

nothing calls this directly

Calls 4

GetWatchNamespaceFunction · 0.92
GetWebhooksCacheFuncFunction · 0.92
createWebhooksFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected