Files
gatewayapi-certificates-ope…/main.go
T
kacerrandClaude Opus 5.5 0eb588e8bd chore: add Makefile with check gate, golangci-lint config, dockerignore
- make check runs lint + vet + test-short; lint is pinned to the go.mod
  toolchain so it works when the host Go is newer than golangci-lint's
- gofumpt main.go and patch.go; drop unused gatewayGroup/gatewayKind vars

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 20:32:53 +02:00

73 lines
1.9 KiB
Go

package main
import (
"flag"
"os"
cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
gozap "go.uber.org/zap"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
"github.com/example/gateway-cert-operator/internal/controller"
)
var scheme = runtime.NewScheme()
func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(cmv1.AddToScheme(scheme))
utilruntime.Must(gwapiv1.Install(scheme))
}
func main() {
var metricsAddr string
var probeAddr string
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metrics endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.Parse()
ctrl.SetLogger(zap.New(
zap.UseDevMode(true),
func(o *zap.Options) {
o.ZapOpts = append(o.ZapOpts, gozap.AddCaller())
},
))
log := ctrl.Log.WithName("setup")
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
HealthProbeBindAddress: probeAddr,
})
if err != nil {
log.Error(err, "unable to create manager")
os.Exit(1)
}
if err := controller.SetupCertificateReconciler(mgr); err != nil {
log.Error(err, "unable to setup certificate controller")
os.Exit(1)
}
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
log.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
log.Error(err, "unable to set up ready check")
os.Exit(1)
}
log.Info("starting manager")
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
log.Error(err, "problem running manager")
os.Exit(1)
}
}