Skip to content

Commit 8c85110

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
Update OSInfo resource to return _name
1 parent 18fd542 commit 8c85110

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

osinfo/src/config.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub struct OsInfo {
2424
/// Defines the processor architecture as reported by `uname -m` on the operating system.
2525
#[serde(skip_serializing_if = "Option::is_none")]
2626
architecture: Option<String>,
27+
#[serde(rename = "_name", skip_serializing_if = "Option::is_none")]
28+
name: Option<String>,
2729
}
2830

2931
/// Defines whether the operating system is a 32-bit or 64-bit operating system.
@@ -64,14 +66,22 @@ impl OsInfo {
6466
os_info::Bitness::X64 => Bitness::Bit64,
6567
_ => Bitness::Unknown,
6668
};
69+
let version = os_info.version().to_string();
70+
let name = Some(format!(
71+
"{:?} {} {}",
72+
family,
73+
version,
74+
architecture.as_deref().unwrap_or("")
75+
));
6776
Self {
6877
id: ID.to_string(),
6978
family,
70-
version: os_info.version().to_string(),
79+
version,
7180
edition,
7281
codename,
7382
bitness: bits,
7483
architecture,
84+
name,
7585
}
7686
}
7787
}

osinfo/tests/osinfo.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ Describe 'osinfo resource tests' {
5252
elseif ($IsMacOS) {
5353
$out.resources[0].properties.family | Should -BeExactly 'macOS'
5454
}
55+
$out.resources[0].name | Should -BeExactly "$($out.resources[0].properties.family) $($out.resources[0].properties.version) $($out.resources[0].properties.architecture)"
5556
}
5657
}

0 commit comments

Comments
 (0)