mirror of
				https://github.com/edera-dev/krata.git
				synced 2025-11-03 07:19:37 +00:00 
			
		
		
		
	hypha: init will now print the command from the image config
This commit is contained in:
		@ -1,4 +1,5 @@
 | 
				
			|||||||
use crate::error::Result;
 | 
					use crate::error::Result;
 | 
				
			||||||
 | 
					use oci_spec::image::ImageConfiguration;
 | 
				
			||||||
use std::fs;
 | 
					use std::fs;
 | 
				
			||||||
use std::path::Path;
 | 
					use std::path::Path;
 | 
				
			||||||
use sys_mount::{FilesystemType, Mount, MountFlags};
 | 
					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 IMAGE_MOUNT_PATH: &str = "/image";
 | 
				
			||||||
const CONFIG_MOUNT_PATH: &str = "/config";
 | 
					const CONFIG_MOUNT_PATH: &str = "/config";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const IMAGE_CONFIG_JSON_PATH: &str = "/config/image/config.json";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub struct ContainerInit {}
 | 
					pub struct ContainerInit {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Default for ContainerInit {
 | 
					impl Default for ContainerInit {
 | 
				
			||||||
@ -24,6 +27,12 @@ impl ContainerInit {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    pub fn init(&mut self) -> Result<()> {
 | 
					    pub fn init(&mut self) -> Result<()> {
 | 
				
			||||||
        self.prepare_mounts()?;
 | 
					        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(())
 | 
					        Ok(())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -35,6 +44,12 @@ impl ContainerInit {
 | 
				
			|||||||
        Ok(())
 | 
					        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<()> {
 | 
					    fn mount_squashfs(&mut self, from: &Path, to: &Path) -> Result<()> {
 | 
				
			||||||
        if !to.is_dir() {
 | 
					        if !to.is_dir() {
 | 
				
			||||||
            fs::create_dir(to)?;
 | 
					            fs::create_dir(to)?;
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user