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

fix(docker): Corrected systemd-nspawn identification #5943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions src/modules/container.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use super::{Context, Module};
use std::fs;

Check failure on line 2 in src/modules/container.rs

View workflow job for this annotation

GitHub Actions / Clippy [Linter] (macOS-latest)

[clippy] reported by reviewdog 🐶 error: unused import: `std::fs` --> src/modules/container.rs:2:5 | 2 | use std::fs; | ^^^^^^^ | = note: `-D unused-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_imports)]` Raw Output: src/modules/container.rs:2:5:e:error: unused import: `std::fs` --> src/modules/container.rs:2:5 | 2 | use std::fs; | ^^^^^^^ | = note: `-D unused-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_imports)]` __END__

#[cfg(not(target_os = "linux"))]
pub fn module<'a>(_context: &'a Context) -> Option<Module<'a>> {
Expand All @@ -20,10 +21,17 @@
// OpenVZ
return Some("OpenVZ".into());
}

if context_path(context, "/run/host/container-manager").exists() {
// OCI
return Some("OCI".into());
match fs::read_to_string("/run/host/container-manager"){
Ok(content) => {
if content.contains("systemd-nspawn"){

Check warning on line 27 in src/modules/container.rs

View check run for this annotation

Codecov / codecov/patch

src/modules/container.rs#L27

Added line #L27 was not covered by tests
return Some("nspawn".into())
} else{
return Some("OCI".into())
}
},
Err(_) => return None,
}
}

let container_env_path = context_path(context, "/run/.containerenv");
Expand Down
Loading