Skip to content

Commit

Permalink
Support ENABLE_WEBHOOKS env which cloud disable webhook server locally (
Browse files Browse the repository at this point in the history
OT-CONTAINER-KIT#617)

* Support ENABLE_WEBHOOKS env which cloud disable webhook server on locally

Signed-off-by: drivebyer <[email protected]>

* Add related flag

Signed-off-by: drivebyer <[email protected]>

---------

Signed-off-by: drivebyer <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
  • Loading branch information
drivebyer authored and mattrobinsonsre committed Jul 11, 2024
1 parent 90d7f49 commit 0ca71da
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func main() {
var metricsAddr string
var enableLeaderElection bool
var probeAddr string
var enableWebhooks bool
flag.BoolVar(&enableWebhooks, "enable-webhooks", os.Getenv("ENABLE_WEBHOOKS") != "false", "Enable webhooks")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
Expand Down Expand Up @@ -122,21 +124,24 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "RedisSentinel")
os.Exit(1)
}
if err = (&redisv1beta2.Redis{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Redis")
os.Exit(1)
}
if err = (&redisv1beta2.RedisCluster{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisCluster")
os.Exit(1)
}
if err = (&redisv1beta2.RedisReplication{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisReplication")
os.Exit(1)
}
if err = (&redisv1beta2.RedisSentinel{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisSentinel")
os.Exit(1)

if enableWebhooks {
if err = (&redisv1beta2.Redis{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "Redis")
os.Exit(1)
}
if err = (&redisv1beta2.RedisCluster{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisCluster")
os.Exit(1)
}
if err = (&redisv1beta2.RedisReplication{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisReplication")
os.Exit(1)
}
if err = (&redisv1beta2.RedisSentinel{}).SetupWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "RedisSentinel")
os.Exit(1)
}
}
// +kubebuilder:scaffold:builder

Expand Down

0 comments on commit 0ca71da

Please sign in to comment.