mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-02 21:00:55 +00:00
hypha: init will now print the command from the image config
This commit is contained in:
parent
a412f6e823
commit
1980e870ba
@ -1,4 +1,5 @@
|
||||
use crate::error::Result;
|
||||
use oci_spec::image::ImageConfiguration;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use sys_mount::{FilesystemType, Mount, MountFlags};
|
||||
@ -9,6 +10,8 @@ const CONFIG_BLOCK_DEVICE_PATH: &str = "/dev/xvdb";
|
||||
const IMAGE_MOUNT_PATH: &str = "/image";
|
||||
const CONFIG_MOUNT_PATH: &str = "/config";
|
||||
|
||||
const IMAGE_CONFIG_JSON_PATH: &str = "/config/image/config.json";
|
||||
|
||||
pub struct ContainerInit {}
|
||||
|
||||
impl Default for ContainerInit {
|
||||
@ -24,6 +27,12 @@ impl ContainerInit {
|
||||
|
||||
pub fn init(&mut self) -> Result<()> {
|
||||
self.prepare_mounts()?;
|
||||
let config = self.parse_image_config()?;
|
||||
if let Some(cfg) = config.config() {
|
||||
if let Some(cmd) = cfg.cmd() {
|
||||
println!("image command: {:?}", cmd);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -35,6 +44,12 @@ impl ContainerInit {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_image_config(&mut self) -> Result<ImageConfiguration> {
|
||||
let image_config_path = Path::new(IMAGE_CONFIG_JSON_PATH);
|
||||
let config = ImageConfiguration::from_file(image_config_path)?;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
fn mount_squashfs(&mut self, from: &Path, to: &Path) -> Result<()> {
|
||||
if !to.is_dir() {
|
||||
fs::create_dir(to)?;
|
||||
|
Loading…
Reference in New Issue
Block a user