From 1ab2a1464d9bb7702e49823b7149bb8ccf48ba5b Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 27 Apr 2024 07:18:17 +0100 Subject: [PATCH] Fix Invalid leader election ID generated when domain is empty --- pkg/plugins/golang/v4/scaffolds/internal/templates/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go index a5b99189678..308bd92c76a 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/main.go @@ -279,7 +279,11 @@ func main() { WebhookServer: webhookServer, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, - LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}", + {{- if not .Domain }} + LeaderElectionID: "{{ hashFNV .Repo }}", + {{- else }} + LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}", + {{- end }} // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily // when the Manager ends. This requires the binary to immediately end when the // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly