Skip to content
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

Merged
merged 9 commits into from Jun 25, 2021

Conversation

pedronis
Copy link
Collaborator

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.

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
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
@pedronis pedronis added the Run nested The PR also runs tests inluded in nested suite label Jun 23, 2021
@pedronis pedronis requested a review from mvo5 June 23, 2021 19:59
@mvo5 mvo5 added this to the 2.51 milestone Jun 24, 2021
Copy link
Contributor

@mvo5 mvo5 left a 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 {
Copy link
Contributor

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}
Copy link
Contributor

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
Copy link
Contributor

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")
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Collaborator

@bboozzoo bboozzoo left a 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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@mvo5
Copy link
Contributor

mvo5 commented Jun 25, 2021

The failures are unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run nested The PR also runs tests inluded in nested suite
Projects
None yet
3 participants