This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new 595e167 Fix #2315: Add leader-election flag to Operator command
595e167 is described below
commit 595e167b7ed57eb3e72141cbc0069f73dc5ca874
Author: John Poth <[email protected]>
AuthorDate: Fri May 21 12:01:16 2021 +0200
Fix #2315: Add leader-election flag to Operator command
---
pkg/cmd/operator.go | 4 +++-
pkg/cmd/operator/operator.go | 4 +---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/pkg/cmd/operator.go b/pkg/cmd/operator.go
index f3d758e..a6af5f4 100644
--- a/pkg/cmd/operator.go
+++ b/pkg/cmd/operator.go
@@ -39,6 +39,7 @@ func newCmdOperator() (*cobra.Command, *operatorCmdOptions) {
cmd.Flags().Int32("health-port", 8081, "The port of the health
endpoint")
cmd.Flags().Int32("monitoring-port", 8080, "The port of the metrics
endpoint")
+ cmd.Flags().Bool("leader-election", true, "Use leader election")
return &cmd, &options
}
@@ -46,8 +47,9 @@ func newCmdOperator() (*cobra.Command, *operatorCmdOptions) {
type operatorCmdOptions struct {
HealthPort int32 `mapstructure:"health-port"`
MonitoringPort int32 `mapstructure:"monitoring-port"`
+ LeaderElection bool `mapstructure:"leader-election"`
}
func (o *operatorCmdOptions) run(_ *cobra.Command, _ []string) {
- operator.Run(o.HealthPort, o.MonitoringPort)
+ operator.Run(o.HealthPort, o.MonitoringPort, o.LeaderElection)
}
diff --git a/pkg/cmd/operator/operator.go b/pkg/cmd/operator/operator.go
index c64f503..d10bd66 100644
--- a/pkg/cmd/operator/operator.go
+++ b/pkg/cmd/operator/operator.go
@@ -65,7 +65,7 @@ func printVersion() {
}
// Run starts the Camel K operator
-func Run(healthPort, monitoringPort int32) {
+func Run(healthPort, monitoringPort int32, leaderElection bool) {
rand.Seed(time.Now().UTC().UnixNano())
flag.Parse()
@@ -102,8 +102,6 @@ func Run(healthPort, monitoringPort int32) {
log.Info("Event broadcasting is disabled because of missing
permissions to create Events")
}
- leaderElection := true
-
operatorNamespace := platform.GetOperatorNamespace()
if operatorNamespace == "" {
// Fallback to using the watch namespace when the operator is
not in-cluster.