Skip to content

Commit

Permalink
inject-connect: fixup cli flag handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemorris committed Jun 1, 2023
1 parent 6f0ecdc commit a06abe3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions control-plane/subcommand/inject-connect/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/controllers/endpoints"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/controllers/peering"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/lifecycle"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/metrics"
"github.com/hashicorp/consul-k8s/control-plane/connect-inject/webhook"
"github.com/hashicorp/consul-k8s/control-plane/controllers"
Expand Down Expand Up @@ -87,9 +88,11 @@ type Command struct {
flagDefaultEnvoyProxyConcurrency int

// Proxy lifecycle settings.
flagDefaultEnableProxyLifecycle bool
flagDefaultProxyShutdownDrainListeners bool
flagDefaultProxyShutdownGracePeriod int
flagDefaultEnableSidecarProxyLifecycle bool
flagDefaultEnableSidecarProxyLifecycleShutdownDrainListeners bool
flagDefaultSidecarProxyLifecycleShutdownGracePeriodSeconds int
flagDefaultSidecarProxyLifecycleGracefulPort string
flagDefaultSidecarProxyLifecycleGracefulShutdownPath string

// Metrics settings.
flagDefaultEnableMetrics bool
Expand Down Expand Up @@ -226,9 +229,11 @@ func (c *Command) init() {
c.flagSet.StringVar(&c.flagDefaultSidecarProxyMemoryLimit, "default-sidecar-proxy-memory-limit", "", "Default sidecar proxy memory limit.")

// Proxy lifecycle setting flags.
c.flagSet.BoolVar(&c.flagDefaultEnableProxyLifecycle, "default-enable-proxy-lifecycle", false, "Default for enabling connect proxy lifecycle management.")
c.flagSet.BoolVar(&c.flagDefaultEnableProxyDrainListeners, "default-enable-proxy-shutdown-drain-listeners", false, "Default for enabling connect proxy listener draining of inbound connections during shutdown.")
c.flagSet.BoolVar(&c.flagDefaultEnableProxyLifecycle, "default-enable-proxy-shutdown-grace-period", false, "Default for enabling connect proxy shutdown grace period.")
c.flagSet.BoolVar(&c.flagDefaultEnableSidecarProxyLifecycle, "default-enable-sidecar-proxy-lifecycle", false, "Default for enabling sidecar proxy lifecycle management.")
c.flagSet.BoolVar(&c.flagDefaultEnableSidecarProxyLifecycleShutdownDrainListeners, "default-enable-sidecar-proxy-lifecycle-shutdown-drain-listeners", false, "Default for enabling sidecar proxy listener draining of inbound connections during shutdown.")
c.flagSet.IntVar(&c.flagDefaultSidecarProxyLifecycleShutdownGracePeriodSeconds, "default-sidecar-proxy-lifecycle-shutdown-grace-period-seconds", 0, "Default sidecar proxy shutdown grace period in seconds.")
c.flagSet.StringVar(&c.flagDefaultSidecarProxyLifecycleGracefulPort, "default-sidecar-proxy-lifecycle-graceful-port", "", "Default port for sidecar proxy lifecycle management HTTP endpoints.")
c.flagSet.StringVar(&c.flagDefaultSidecarProxyLifecycleGracefulShutdownPath, "default-sidecar-proxy-lifecycle-graceful-shutdown-path", "/graceful_shutdown", "Default sidecar proxy lifecycle management graceful shutdown path.")

// Metrics setting flags.
c.flagSet.BoolVar(&c.flagDefaultEnableMetrics, "default-enable-metrics", false, "Default for enabling connect service metrics.")
Expand Down Expand Up @@ -433,9 +438,11 @@ func (c *Command) Run(args []string) int {
}

lifecycleConfig := lifecycle.Config{
DefaultEnableProxyLifecycle: c.flagDefaultEnableProxyLifecycle,
DefaultEnableProxyShutdownDrainListeners: c.flagDefaultEnableProxyShutdownDrainListeners,
DefaultEnableProxyShutdownGracePeriod: c.flagDefaultEnableProxyShutdownGracePeriod,
DefaultEnableProxyLifecycle: c.flagDefaultEnableSidecarProxyLifecycle,
DefaultEnableShutdownDrainListeners: c.flagDefaultEnableSidecarProxyLifecycleShutdownDrainListeners,
DefaultShutdownGracePeriodSeconds: c.flagDefaultSidecarProxyLifecycleShutdownGracePeriodSeconds,
DefaultGracefulPort: c.flagDefaultSidecarProxyLifecycleGracefulPort,
DefaultGracefulShutdownPath: c.flagDefaultSidecarProxyLifecycleGracefulShutdownPath,
}

metricsConfig := metrics.Config{
Expand All @@ -453,7 +460,6 @@ func (c *Command) Run(args []string) int {
ConsulServerConnMgr: watcher,
AllowK8sNamespacesSet: allowK8sNamespaces,
DenyK8sNamespacesSet: denyK8sNamespaces,
LifecycleConfig: lifecycleConfig,
MetricsConfig: metricsConfig,
EnableConsulPartitions: c.flagEnablePartitions,
EnableConsulNamespaces: c.flagEnableNamespaces,
Expand Down

0 comments on commit a06abe3

Please sign in to comment.