mirror of
https://github.com/michael-yuji/xc.git
synced 2026-03-21 08:14:52 +01:00
fix osstring serialize/deserialize bugs
This commit is contained in:
@@ -28,7 +28,6 @@ use self::aux::Set;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
|
||||
pub const OCI_IMAGE_INDEX: &str = "application/vnd.oci.image.index.v1+json";
|
||||
pub const OCI_MANIFEST: &str = "application/vnd.oci.image.manifest.v1+json";
|
||||
@@ -181,7 +180,7 @@ pub struct OciInnerConfig {
|
||||
pub env: Option<Vec<String>>,
|
||||
pub tty: Option<bool>,
|
||||
pub working_dir: Option<String>,
|
||||
pub volumes: Option<Set<OsString>>,
|
||||
pub volumes: Option<Set<String>>,
|
||||
pub exposed_ports: Option<Set<String>>,
|
||||
pub user: Option<String>,
|
||||
pub labels: Option<HashMap<String, String>>,
|
||||
|
||||
@@ -192,7 +192,7 @@ impl PatchActions {
|
||||
destination: mount_point.to_path_buf(),
|
||||
required: *required,
|
||||
};
|
||||
config.mounts.insert(key, mountspec);
|
||||
config.mounts.insert(key.to_string_lossy().to_string(), mountspec);
|
||||
}
|
||||
PatchActions::ModAllow { allows } => {
|
||||
for allow in allows.iter() {
|
||||
|
||||
@@ -114,7 +114,7 @@ impl ConfigMod {
|
||||
}
|
||||
}
|
||||
Self::Volume(name, mount_spec) => {
|
||||
config.mounts.insert(name.clone(), mount_spec.clone());
|
||||
config.mounts.insert(name.to_string_lossy().to_string(), mount_spec.clone());
|
||||
}
|
||||
Self::WorkDir(entry_point, dir) => {
|
||||
let work_dir = dir.to_string();
|
||||
|
||||
@@ -255,15 +255,12 @@ impl ImageStore for SqliteImageStore {
|
||||
while let Ok(Some(row)) = rows.next() {
|
||||
let bytes: String = row.get(4)?;
|
||||
let manifest: JailImage = serde_json::from_str(&bytes)?;
|
||||
|
||||
let hn: String = row.get(0)?;
|
||||
|
||||
let image_reference = ImageReference {
|
||||
hostname: if hn.is_empty() { None } else { Some(hn) },
|
||||
name: row.get(1)?,
|
||||
tag: ImageTag::Tag(row.get(2)?),
|
||||
};
|
||||
|
||||
records.push(ImageRecord {
|
||||
image_reference,
|
||||
digest: row.get(3)?,
|
||||
|
||||
@@ -36,7 +36,6 @@ use oci_util::layer::ChainId;
|
||||
use oci_util::models::{FreeOciConfig, OciConfig, OciConfigRootFs, OciInnerConfig};
|
||||
use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer};
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::OsString;
|
||||
use varutil::string_interpolation::{InterpolatedString, Var};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
||||
@@ -153,7 +152,6 @@ pub struct JailConfig {
|
||||
/// The secure level this jail is required
|
||||
pub secure_level: i8,
|
||||
|
||||
// pub original_oci_config: Option<OciConfig>,
|
||||
/// is vnet required
|
||||
#[serde(default)]
|
||||
pub vnet: bool,
|
||||
@@ -184,7 +182,7 @@ pub struct JailConfig {
|
||||
|
||||
pub special_mounts: Vec<SpecialMount>,
|
||||
|
||||
pub mounts: HashMap<OsString, MountSpec>,
|
||||
pub mounts: HashMap<String, MountSpec>,
|
||||
|
||||
#[serde(default)]
|
||||
pub datasets: HashMap<String, DatasetSpec>,
|
||||
|
||||
@@ -201,7 +201,7 @@ impl AppliedInstantiateRequest {
|
||||
}
|
||||
}
|
||||
|
||||
mount_specs.remove(&req.dest);
|
||||
mount_specs.remove(req.dest.to_str().unwrap());
|
||||
}
|
||||
|
||||
for (key, spec) in mount_specs.iter() {
|
||||
@@ -442,7 +442,7 @@ impl InstantiateBlueprint {
|
||||
}
|
||||
};
|
||||
|
||||
let mount_spec = mount_specs.remove(&req.dest);
|
||||
let mount_spec = mount_specs.remove(req.dest.to_str().unwrap());
|
||||
|
||||
if mount_spec.is_some() {
|
||||
added_mount_specs.insert(&req.dest, mount_spec.clone().unwrap());
|
||||
|
||||
@@ -1170,7 +1170,7 @@ async fn create_volume(
|
||||
{
|
||||
Ok(image) => {
|
||||
let specs = image.manifest.jail_config().mounts;
|
||||
specs.get(&volume).cloned()
|
||||
specs.get(volume.to_str().unwrap()).cloned()
|
||||
}
|
||||
Err(ImageStoreError::ManifestNotFound(manifest)) => {
|
||||
return enoent(&format!("no such manifest {manifest}"))
|
||||
|
||||
Reference in New Issue
Block a user