-
Notifications
You must be signed in to change notification settings - Fork 168
install: support configuring sysroot.bls-append-except-default #1909
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
Open
joelcapitao
wants to merge
1
commit into
bootc-dev:main
Choose a base branch
from
joelcapitao:feat-grubusers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,15 @@ pub(crate) struct BasicFilesystems { | |
| // pub(crate) esp: Option<FilesystemCustomization>, | ||
| } | ||
|
|
||
| /// Configuration for ostree repository | ||
| #[derive(Debug, Clone, Serialize, Deserialize, Default)] | ||
| #[serde(rename_all = "kebab-case", deny_unknown_fields)] | ||
| pub(crate) struct Ostree { | ||
| /// Boot Loader Spec entries that should append arguments only for non-default entries | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub(crate) bls_append_except_default: Option<String>, | ||
| } | ||
|
|
||
| /// The serialized [install] section | ||
| #[derive(Debug, Clone, Serialize, Deserialize, Default)] | ||
| #[serde(rename = "install", rename_all = "kebab-case", deny_unknown_fields)] | ||
|
|
@@ -73,6 +82,8 @@ pub(crate) struct InstallConfiguration { | |
| pub(crate) kargs: Option<Vec<String>>, | ||
| /// Supported architectures for this configuration | ||
| pub(crate) match_architectures: Option<Vec<String>>, | ||
| /// Ostree repository configuration | ||
| pub(crate) ostree: Option<Ostree>, | ||
| } | ||
|
|
||
| fn merge_basic<T>(s: &mut Option<T>, o: Option<T>, _env: &EnvProperties) { | ||
|
|
@@ -119,6 +130,13 @@ impl Mergeable for BasicFilesystems { | |
| } | ||
| } | ||
|
|
||
| impl Mergeable for Ostree { | ||
| /// Apply any values in other, overriding any existing values in `self`. | ||
| fn merge(&mut self, other: Self, env: &EnvProperties) { | ||
| merge_basic(&mut self.bls_append_except_default, other.bls_append_except_default, env) | ||
| } | ||
| } | ||
|
|
||
| impl Mergeable for InstallConfiguration { | ||
| /// Apply any values in other, overriding any existing values in `self`. | ||
| fn merge(&mut self, other: Self, env: &EnvProperties) { | ||
|
|
@@ -133,6 +151,7 @@ impl Mergeable for InstallConfiguration { | |
| #[cfg(feature = "install-to-disk")] | ||
| merge_basic(&mut self.block, other.block, env); | ||
| self.filesystem.merge(other.filesystem, env); | ||
| self.ostree.merge(other.ostree, env); | ||
| if let Some(other_kargs) = other.kargs { | ||
| self.kargs | ||
| .get_or_insert_with(Default::default) | ||
|
|
@@ -572,4 +591,44 @@ root-fs-type = "xfs" | |
| ) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_parse_ostree() { | ||
| let env = EnvProperties { | ||
| sys_arch: "x86_64".to_string(), | ||
| }; | ||
| let c: InstallConfigurationToplevel = toml::from_str( | ||
| r##"[install.ostree] | ||
| bls-append-except-default = "console=ttyS0" | ||
| "##, | ||
| ) | ||
| .unwrap(); | ||
| let install = c.install.unwrap(); | ||
| assert_eq!( | ||
| install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(), | ||
| "console=ttyS0" | ||
| ); | ||
|
|
||
| // Test merging ostree config | ||
| let c: InstallConfigurationToplevel = toml::from_str( | ||
| r##"[install.ostree] | ||
| bls-append-except-default = "console=ttyS0" | ||
| "##, | ||
| ) | ||
| .unwrap(); | ||
| let mut install = c.install.unwrap(); | ||
| let other = InstallConfigurationToplevel { | ||
| install: Some(InstallConfiguration { | ||
| ostree: Some(Ostree { | ||
| bls_append_except_default: Some("console=tty0".to_string()), | ||
| }), | ||
| ..Default::default() | ||
| }), | ||
| }; | ||
| install.merge(other.install.unwrap(), &env); | ||
| assert_eq!( | ||
| install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(), | ||
| "console=tty0" | ||
| ); | ||
| } | ||
|
Comment on lines
+596
to
+633
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test can be simplified by removing the duplicated TOML parsing. The fn test_parse_ostree() {
let env = EnvProperties {
sys_arch: "x86_64".to_string(),
};
let c: InstallConfigurationToplevel = toml::from_str(
r##"[install.ostree]
bls-append-except-default = "console=ttyS0"
"##,
)
.unwrap();
let mut install = c.install.unwrap();
assert_eq!(
install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(),
"console=ttyS0"
);
// Test merging ostree config
let other = InstallConfigurationToplevel {
install: Some(InstallConfiguration {
ostree: Some(Ostree {
bls_append_except_default: Some("console=tty0".to_string()),
}),
..Default::default()
}),
};
install.merge(other.install.unwrap(), &env);
assert_eq!(
install.ostree.as_ref().unwrap().bls_append_except_default.as_ref().unwrap(),
"console=tty0"
);
} |
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The nested
if letchain can be flattened usingand_thenfor better readability and to be more idiomatic.