-
Notifications
You must be signed in to change notification settings - Fork 472
fix(txsim): pollTime CLI flag should override environment variable #5268
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
2847f7d
c4864cb
48a7919
8538597
53c5c6a
b6b3315
3b05ac0
ce54b0c
521715e
523561a
e3ad00c
04aa19f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,11 +177,10 @@ account that can act as the master account. The command runs until all sequences | |
} | ||
} | ||
|
||
if os.Getenv(TxsimPoll) != "" && pollTime != user.DefaultPollTime { | ||
pollTime, err = time.ParseDuration(os.Getenv(TxsimPoll)) | ||
if err != nil { | ||
return fmt.Errorf("parsing poll time: %w", err) | ||
} | ||
// set pollTime: flag has priority, then env var, then default | ||
pollTime, err = getPollTime(pollTime, os.Getenv(TxsimPoll), user.DefaultPollTime) | ||
if err != nil { | ||
return fmt.Errorf("parsing poll time: %w", err) | ||
rootulp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
opts := txsim.DefaultOptions(). | ||
|
@@ -296,3 +295,19 @@ func parseUpgradeSchedule(schedule string) (map[int64]uint64, error) { | |
} | ||
return scheduleMap, nil | ||
} | ||
|
||
// getPollTime returns the correct pollTime value based on CLI flag, environment variable, and default. | ||
rootulp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// Priority: flag > env > default. | ||
func getPollTime(flagValue time.Duration, envValue string, defaultValue time.Duration) (time.Duration, error) { | ||
if flagValue != defaultValue { | ||
|
||
return flagValue, nil | ||
} | ||
if envValue != "" { | ||
val, err := time.ParseDuration(envValue) | ||
if err != nil { | ||
return 0, err | ||
rootulp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
return val, nil | ||
} | ||
return defaultValue, nil | ||
} |
Uh oh!
There was an error while loading. Please reload this page.