feat: stamp the build commit, add --version and zap flags, rename module

- module path is now gitea.home.hrajfrisbee.cz/kacerr/gatewayapi-certificates-operator
- internal/version resolves the commit from ldflags or Go build info;
  --version prints it and the first log line carries it
- --metrics-bind-address is passed to the manager instead of being dropped
- Dockerfile takes GIT_COMMIT, honours TARGETARCH, labels the image revision

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 20:34:49 +02:00
co-authored by Claude Opus 5.5
parent 0eb588e8bd
commit 3766e94b35
9 changed files with 195 additions and 23 deletions
+17 -7
View File
@@ -2,7 +2,9 @@ package main
import (
"flag"
"fmt"
"os"
goruntime "runtime"
cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
gozap "go.uber.org/zap"
@@ -12,9 +14,11 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
"github.com/example/gateway-cert-operator/internal/controller"
"gitea.home.hrajfrisbee.cz/kacerr/gatewayapi-certificates-operator/internal/controller"
"gitea.home.hrajfrisbee.cz/kacerr/gatewayapi-certificates-operator/internal/version"
)
var scheme = runtime.NewScheme()
@@ -28,21 +32,27 @@ func init() {
func main() {
var metricsAddr string
var probeAddr string
var showVersion bool
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.BoolVar(&showVersion, "version", false, "Print the commit this binary was built from and exit.")
opts := zap.Options{Development: true, ZapOpts: []gozap.Option{gozap.AddCaller()}}
opts.BindFlags(flag.CommandLine)
flag.Parse()
ctrl.SetLogger(zap.New(
zap.UseDevMode(true),
func(o *zap.Options) {
o.ZapOpts = append(o.ZapOpts, gozap.AddCaller())
},
))
if showVersion {
fmt.Println(version.Resolve())
return
}
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
log := ctrl.Log.WithName("setup")
log.Info("starting gateway-cert-operator", "commit", version.Resolve(), "goVersion", goruntime.Version())
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
})
if err != nil {