Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace http-port cli arg to http-addr #307

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,14 @@ const EnvNamePrefix = "HEGEL"

// RootCommandOptions encompasses all the configurability of the RootCommand.
type RootCommandOptions struct {
TrustedProxies string `mapstructure:"trusted-proxies"`

HTTPPort int `mapstructure:"http-port"`

Backend string `mapstructure:"backend"`

TrustedProxies string `mapstructure:"trusted-proxies"`
HTTPAddr string `mapstructure:"http-addr"`
Backend string `mapstructure:"backend"`
KubernetesAPIServer string `mapstructure:"kubernetes-apiserver"`
KubernetesKubeconfig string `mapstructure:"kubernetes-kubeconfig"`
KubernetesNamespace string `mapstructure:"kubernetes-namespace"`

FlatfilePath string `mapstructure:"flatfile-path"`

// Debug enables debug mode that maximizes logging.
Debug bool `mapstructure:"debug"`
FlatfilePath string `mapstructure:"flatfile-path"`
Debug bool `mapstructure:"debug"`

// Hidden CLI flags.
HegelAPI bool `mapstructure:"hegel-api"`
Expand Down Expand Up @@ -148,7 +142,7 @@ func (c *RootCommand) Run(cmd *cobra.Command, _ []string) error {
ctx, cancel := signal.NotifyContext(ctx, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
defer cancel()

return hegelhttp.Serve(ctx, logger, fmt.Sprintf(":%v", c.Opts.HTTPPort), router)
return hegelhttp.Serve(ctx, logger, c.Opts.HTTPAddr, router)
}

func (c *RootCommand) configureFlags() error {
Expand All @@ -158,7 +152,7 @@ func (c *RootCommand) configureFlags() error {
"A commma separated list of allowed peer IPs and/or CIDR blocks to replace with X-Forwarded-For",
)

c.Flags().Int("http-port", 50061, "Port to listen on for HTTP requests")
c.Flags().String("http-addr", ":50061", "Port to listen on for HTTP requests")

c.Flags().String("backend", "kubernetes", "Backend to use for metadata. Options: flatfile, kubernetes")

Expand Down