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

Fixes #23573: Make sources compatible with Windows #5097

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions policies/minifusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ quick-xml = { version = "0.30.0", features = ["serialize"] }
sysinfo = "0.29.4"
serde = { version = "1", features = ["derive"] }
hostname = "0.3"
uname-rs = "0.1"
anyhow = "1"
clap = { version = "4.3.11", features = ["derive"] }
chrono = "0.4"
regex = "1"

[target.'cfg(unix)'.dependencies]
uname-rs = "0.1"

[dev-dependencies]
pretty_assertions = "1"
pretty_assertions = "1"
8 changes: 8 additions & 0 deletions policies/minifusion/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use os_release::OsRelease;
use quick_xml::se::Serializer;
use serde::Serialize;
use sysinfo::{CpuExt, ProcessExt, System, SystemExt, UserExt};
#[cfg(unix)]
use uname_rs::Uname;

pub const AGENT_CERT_PATH: &str = "/opt/rudder/etc/ssl/agent.cert";
Expand Down Expand Up @@ -133,6 +134,7 @@ pub struct User {

impl Inventory {
pub fn new() -> Result<Self> {
#[cfg(unix)]
let uts = Uname::new()?;
let hostname = hostname::get()?
.into_string()
Expand Down Expand Up @@ -197,12 +199,15 @@ impl Inventory {
operating_system: OperatingSystem {
arch,
boot_time: "".to_string(),
#[cfg(unix)]
dns_domain: uts.domainname,
// FIXME not fqdn
fqdn: hostname.clone(),
full_name: os_release.pretty_name,
host_id: "".to_string(),
#[cfg(unix)]
kernel_name: uts.sysname.to_lowercase(),
#[cfg(unix)]
kernel_version: uts.release,
name: os_release.name,
version: os_release.version,
Expand Down Expand Up @@ -233,6 +238,7 @@ pub struct OperatingSystem {
// <BOOT_TIME>2023-06-29 15:04:23</BOOT_TIME>
boot_time: String,
// <DNS_DOMAIN>rudder.local</DNS_DOMAIN>
#[cfg(unix)]
dns_domain: String,
// <FQDN>server.rudder.local</FQDN>
fqdn: String,
Expand All @@ -242,8 +248,10 @@ pub struct OperatingSystem {
#[serde(rename = "HOSTID")]
host_id: String,
// <KERNEL_NAME>linux</KERNEL_NAME>
#[cfg(unix)]
kernel_name: String,
// <KERNEL_VERSION>4.18.0-365.el8.x86_64</KERNEL_VERSION>
#[cfg(unix)]
kernel_version: String,
// <NAME>CentOS</NAME>
name: String,
Expand Down
1 change: 1 addition & 0 deletions policies/rudderc/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const TEST_LIB: &str = "tests/lib/common";
const TEST_METHODS: &str = "tests/lib/common/30_generic_methods";

/// Compile and tests all files in `cases/test`. This tests the testing feature itself.
#[cfg(unix)]
#[test_resources("tests/cases/test/*/*.yml")]
fn test(filename: &str) {
let technique_dir = Path::new(filename).parent().unwrap();
Expand Down