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
many: pass device/model info to configcore via sysconfig.Device interface #10446
Conversation
introduce sysconfig.Device (similar to boot.Device) have sysconfig.ApplyFilesystemOnlyDefaults and sysconfig.ConfigureTargetSystem take the model and pass down a sysconfig.Device for these two we assume that mode is not run
adjust the affected code
the information is passed via sysconfig.Device now
this gives us more information more cleanly than the current approach reading the kernel command line directly
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 this, this looks super nice
c.Check(err, ErrorMatches, `cannot set "core.unknown.option": unsupported system option`) | ||
} | ||
|
||
type mockDev 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.
Nice!
} | ||
|
||
var ( | ||
coreDev = mockDev{classic: false} |
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.
Nice
sysconfig.ApplyFilesystemOnlyDefaultsImpl = func(rootDir string, defaults map[string]interface{}, options *sysconfig.FilesystemOnlyApplyOptions) error { | ||
return filesystemOnlyApply(rootDir, defaults, options) | ||
} | ||
sysconfig.ApplyFilesystemOnlyDefaultsImpl = filesystemOnlyApply |
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.
Nice simplification
defer restore() | ||
|
||
// mock the device as uc20 run mode | ||
mockCmdline := filepath.Join(dirs.GlobalRootDir, "cmdline") |
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.
Seeing how much less mocking is needed with this change is really nice
} | ||
|
||
func (di *deviceInfo) RunMode() bool { | ||
return false |
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.
(nipick) maybe a small comment here that this is false because in the sysconfig context where this is used we are never in RunMode ?
the functions using configedDevice are not used from run mode (thanks @mvo)
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.
LGTM
Classic() bool | ||
|
||
Kernel() string | ||
//Base() string |
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.
A TODO maybe depending on whether we actually need Base and Model?
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'll take care of this in a follow up one way or another. I want to cover at least one of the TODO I left in configcore. The one where we still read the kernel command line.
The failures are unrelated. |
This is similar to boot.Device.
Use this which is cleaner and delivers more information in the pi options code as well.
Leaves a couple of TODO about where this could also be leveraged as well.