blob: cf218d4651a3ab9faa89483f4f228832fcac3cc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
use serde::{Deserialize, Serialize};
use std::{ffi::OsString, process::Command};
pub use error::{Error, Result};
pub mod error;
#[derive(Serialize, Deserialize, Clone)]
pub struct Container {
pub machine: OsString,
pub class: OsString,
pub service: OsString,
pub os: OsString,
pub version: OsString,
pub addresses: OsString,
}
/// Uses Command to call to machinectl list -o json
pub fn get_containers() -> Result<Vec<Container>> {
Command::new("machinectl")
.arg("list")
.args(["-o", "json"])
.output()
.map(|o| serde_json::from_slice(o.stdout.as_slice()))?
.map_err(Error::from)
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}
|