diff --git a/rust/src/treefile.rs b/rust/src/treefile.rs index 22dcc2cd..4fae2288 100644 --- a/rust/src/treefile.rs +++ b/rust/src/treefile.rs @@ -207,11 +207,9 @@ pub struct Rojig { pub description: Option, } -// https://github.com/serde-rs/serde/issues/368 -fn serde_true() -> bool { - true -} - +// Because of how we handle includes, *everything* here has to be +// Option. The defaults live in the code (e.g. machineid-compat defaults +// to `true`). #[derive(Serialize, Deserialize, Debug)] #[serde(deny_unknown_fields)] pub struct TreeComposeConfig { @@ -272,20 +270,21 @@ pub struct TreeComposeConfig { pub initramfs_args: Option>, // Tree layout options - #[serde(default)] - pub boot_location: BootLocation, - #[serde(default)] + #[serde(skip_serializing_if = "Option::is_none")] + pub boot_location: Option, + #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "tmp-is-dir")] - pub tmp_is_dir: bool, + pub tmp_is_dir: Option, // systemd #[serde(skip_serializing_if = "Option::is_none")] pub units: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub default_target: Option, - #[serde(default = "serde_true")] + #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "machineid-compat")] - pub machineid_compat: bool, + // Defaults to `true` + pub machineid_compat: Option, // versioning #[serde(skip_serializing_if = "Option::is_none")] @@ -419,6 +418,7 @@ packages-s390x: let tf = &t.tf; assert!(tf.parsed.rojig.is_none()); assert!(tf.rojig_spec.is_none()); + assert!(tf.parsed.machineid_compat.is_none()); } #[test] diff --git a/tests/compose-tests/test-machineid-compat.sh b/tests/compose-tests/test-machineid-compat.sh index d2661aea..4ada0075 100755 --- a/tests/compose-tests/test-machineid-compat.sh +++ b/tests/compose-tests/test-machineid-compat.sh @@ -19,8 +19,14 @@ assert_file_has_content_literal err.txt \ "'units' directive is incompatible with machineid-compat = false" echo "ok conflict with units" +# In this test we also want to test that include: +# correctly handles machineid-compat. prepare_compose_test "machineid-compat" pysetjsonmember "machineid-compat" 'False' +cat > composedata/fedora-machineid-compat-includer.yaml <