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

[-] fix --retry-num parameter handling, fixes #272 #280

Merged
merged 2 commits into from
Nov 19, 2024
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: 14 additions & 6 deletions vipconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ func defineFlags() {

pflag.String("consul-token", "", "Token for consul DCS endpoints.")

pflag.String("interval", "1000", "DCS scan interval in milliseconds.")
pflag.Int("interval", 1000, "DCS scan interval in milliseconds.")
pflag.String("manager-type", "basic", "Type of VIP-management to be used. Supported values: basic, hetzner.")

pflag.Int("retry-after", 250, "Time to wait before retrying interactions with outside components in milliseconds.")
pflag.Int("retry-num", 3, "Number of times interactions with outside components are retried.")

pflag.Bool("verbose", false, "Be verbose. Currently only implemented for manager-type=hetzner .")

pflag.CommandLine.SortFlags = false
Expand Down Expand Up @@ -153,12 +156,12 @@ func mapDeprecated() error {
}

func setDefaults() {
defaults := map[string]string{
"dcs-type": "etcd",
"interval": "1000",
defaults := map[string]any{
"hostingtype": "basic",
"retry-num": "3",
"retry-after": "250",
"dcs-type": "etcd",
"interval": 1000,
"retry-after": 250,
"retry-num": 3,
}

for k, v := range defaults {
Expand Down Expand Up @@ -200,6 +203,11 @@ func setDefaults() {
viper.Set("trigger-value", triggerValue)
}
}

// set retry-num to default if not set or set to zero
if retryNum := viper.GetInt("retry-num"); retryNum <= 0 {
viper.Set("retry-num", 3)
}
}

func checkSetting(name string) bool {
Expand Down
Loading