-
Notifications
You must be signed in to change notification settings - Fork 60
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
Implementation of Builder pattern for Config #59
Implementation of Builder pattern for Config #59
Conversation
A prototype pull request for the Builder pattern for config request. This does not affect the |
14c1c3b
to
4653300
Compare
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.
I personally like the approach, I have a few comments on the code level, but I'll add them once other people chime in to see if we should move forward with this.
@lauralt @aghecenco @alexandruag what do you say?
The only thing that I find a bit out of hand is that in the builder we need to provide a default for KernelConfig
. This could be avoided with some duplication, but we need to see if it is really important.
I like the proposal too.
Would be nice if we can avoid the |
4653300
to
ce8a922
Compare
ce8a922
to
97421ee
Compare
97421ee
to
78638bf
Compare
`TryFrom` implementations for all the `*Config` structs were using `String` as a parameter, instead of String, because likeley we'll be having an `&str` already from the command line etc. Signed-off-by: Abhijit Gadgil <[email protected]>
Implemented Builder for VMMConfig (WIP). Removed derive(Default) from MemoryConfig, KernelConfig and VcpuConfig and added sensible defaults (memory = 256M, vcpu=1) (derive default will trivially initialize this to 0 and hence we are required to take a memory coniguration as user input). Brought these changes to api (CLI) to demonstrate a use. Removed required from 'memory' and 'vcpu' config. Signed-off-by: Abhijit Gadgil <[email protected]>
34d2140
to
f029d56
Compare
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.
Just a couple of nits. The code looks good to me 👍
Added Documentation and unit tests for config `Builder`. Signed-off-by: Abhijit Gadgil <[email protected]>
We were using the network config param as `network_config` inside the `VMMConfig`, but the actual CLI parameter was called `net`. There were a few places where this inconsistency was there. Now consistently using `net_config` everywhere so that the CLI parem `--net` makes sense Signed-off-by: Abhijit Gadgil <[email protected]>
f029d56
to
057ac47
Compare
Implemented
Builder
forVMMConfig
. (Note: This is an earlyimplementation, more like prototype. But almost all functionality is
present.)
Removed
derive(Default)
fromMemoryConfig
,KernelConfig
andVcpuConfig
and added sensible defaults (memory = 256M, vcpu=1) (derivedefault will trivially initialize this to 0 and hence we are required to
take a memory coniguration from CLI launcher).
Brought these changes to
api
(CLI
) to demonstrate a use.Removed
required
from 'memory' and 'vcpu' config.Changed
TryFrom<String>
toTryFrom<&str>
. Believe this is betterbecause it's quite possible to get
&str
fromString
than other wayround and in fact often we'll get
&str
from CLI parsing etc. But theother way round is painful.
Right now passes all 'existing' tests (
cargo test --all
, except onewhich likely fails because the right kernel image is not available to
test.)
TODO: Documentation with examples for using the
Builder
and Test casesfor the
Builder
.