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