-
Notifications
You must be signed in to change notification settings - Fork 70
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
Feat/added toml supersim config closes #104 #295
base: main
Are you sure you want to change the base?
Feat/added toml supersim config closes #104 #295
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.
Thanks for the PR! Mostly looks great Left some comments
- Explicitly passed flags should always override file based config
- Not have separate type definitions for CLIConfig
- Some nit readme updates
### 3. Configure `supersim` (Optional) | ||
|
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.
this readme section is great but can we move it down to a separate section ## Configuration
after ## First Steps
. The Getting Started should stay as short as possible
type TOMLConfig struct { | ||
AdminPort uint64 `toml:"admin_port"` | ||
|
||
LogsDirectory: ctx.String(LogsDirectoryFlagName), | ||
L1Port uint64 `toml:"l1_port"` | ||
L2StartingPort uint64 `toml:"l2_starting_port"` | ||
|
||
L1Host: ctx.String(L1HostFlagName), | ||
L2Host: ctx.String(L2HostFlagName), | ||
} | ||
InteropAutoRelay bool `toml:"interop_autorelay"` | ||
InteropDelay uint64 `toml:"interop_delay"` | ||
|
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.
TOMLConfig and ForkTOMLConfig should be combined with the ForkCLIConfig and CLIConfig. I think we can just add struct tags to the CLIConfig and ForkCLIConfig.
*.toml | ||
!*.toml.template |
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.
can probably remove this - People primarily consume this package as a binary so it's rare that people will directly try to commit their toml to the repo
@@ -244,3 +254,87 @@ func validateHost(host string) error { | |||
|
|||
return nil | |||
} | |||
|
|||
func readTOMLConfig(cfg *CLIConfig) error { |
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.
nit: maybe rename to "applyTOMLConfig" since this does more than reading
return nil | ||
} | ||
|
||
func populateFromCLIContext(cfg *CLIConfig, ctx *cli.Context) { |
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.
RC: this function makes it so that if the TOML config is set, the cli flags can't override it. Should update it so that the explicit flags passed to CLI always take precedence. That would align better with the expected behavior of most CLIs (explicit flags override file base config)
We can just remove the checks for the default values (ie. cfg.L1Port == 0)
Description
This pull request implements significant improvements to the configuration handling of the application. The changes include the addition of a TOML configuration file that is parsed, allowing values to be passed in as command-line arguments. The configuration values from the TOML file take precedence over those provided via CLI flags, ensuring a more flexible and user-friendly configuration experience.
Tests
Comprehensive tests have been added to verify the correct parsing of the TOML file and the proper application of configuration values. The tests ensure that:
Additional context
These improvements address the need for a more robust configuration management system, allowing users to define their settings in a structured format while still providing the flexibility of command-line overrides. This change enhances usability and aligns with best practices for configuration management.
Metadata