-
Notifications
You must be signed in to change notification settings - Fork 773
feat: add default flag options #4044
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors flag registration to use an options pattern for default values, allowing tests to specify a default node count (and owner) when registering flags.
- Introduces
DefaultOptions
andDefaultOption
types withWithDefaultNodeCount
/WithDefaultOwner
helpers. - Replaces
RegisterFlags
andRegisterFlagsWithDefaultOwner
calls withRegisterFlagsWithOptions
. - Updates flag constructors to use the provided default node count.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/load2/main/main.go | Added defaultNodeCount constant and passed it via RegisterFlagsWithOptions |
tests/load/c/main/main.go | Switched from RegisterFlags to RegisterFlagsWithOptions |
tests/fixture/tmpnet/tmpnetctl/main.go | Supplied tmpnet.DefaultNodeCount into NewStartNetworkFlagSetVars |
tests/fixture/tmpnet/flags/start_network.go | Extended constructors to accept defaultNodeCount and wire it through |
tests/fixture/e2e/flags.go | Added options pattern, but RegisterFlagsWithDefaultOwner is misimplemented |
tests/e2e/e2e_test.go | Updated to call RegisterFlagsWithOptions(e2e.WithDefaultOwner(...)) |
tests/antithesis/config.go | Replaced RegisterFlags() with RegisterFlagsWithOptions() |
Comments suppressed due to low confidence (2)
tests/fixture/e2e/flags.go:162
- The
RegisterFlagsWithDefaultOwner
function is declared to return*FlagVars
but currently returns anint
. It should delegate toRegisterFlagsWithOptions
, e.g.:return RegisterFlagsWithOptions(WithDefaultOwner(defaultOwner))
.
}
tests/fixture/e2e/flags.go:155
- This return statement returns an
int
insideRegisterFlagsWithDefaultOwner
, but the function signature expects*FlagVars
. Update to return the result ofRegisterFlagsWithOptions
instead.
return d.nodeCount
return RegisterFlagsWithDefaultOwner("") | ||
type DefaultOption func(*DefaultOptions) | ||
|
||
type DefaultOptions struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(No action required) I still think this a pretty complicated alternative to using a struct.
type Defaults struct {
Owner string
NodeCount int
}
...
flags.RegisterFlags(flags.Defaults{})
Why this should be merged
As mentioned in #3996 (comment), test suites should ideally be able to set the default number of nodes for a test. Rather than extending the current
RegisterFlagsWithDefaultX()
pattern to support a default node count, this PR refactors setting the default flag values to use an options pattern.How this works
Registering a flags default values is now done via
RegisterFlagsWithOptions()
. Calling this function without any arguments is equivalent to previously callingRegisterFlags
.How this was tested
CI
Need to be documented in RELEASES.md?
N/A