mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-12 14:48:13 +00:00
kata-type: Relax Mandatory source Field Check in Guest-Pull Mode
Previously, the source field was subject to mandatory checks. However, in guest-pull mode, this field doesn't consistently provide useful information. Our practical experience has shown that relying on this field for critical data isn't always necessary. In other aspect, not all cases need mandatory check for KataVirtualVolume. based on this fact, we'd better to make from_base64 do only one thing and remove the validate(). Of course, We also keep the previous capability to make it easy for possible cases which use such method and we rename it clearly with from_base64_and_validate. This commit relaxes the mandatory checks on the KataVirtualVolume specifically for guest-pull mode, acknowledging its diminished utility in this context. Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
This commit is contained in:
parent
8f8b196705
commit
2b95facc6f
@ -387,7 +387,15 @@ impl KataVirtualVolume {
|
|||||||
pub fn from_base64(value: &str) -> Result<Self> {
|
pub fn from_base64(value: &str) -> Result<Self> {
|
||||||
let json = base64::decode(value)?;
|
let json = base64::decode(value)?;
|
||||||
let volume: KataVirtualVolume = serde_json::from_slice(&json)?;
|
let volume: KataVirtualVolume = serde_json::from_slice(&json)?;
|
||||||
|
|
||||||
|
Ok(volume)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decode and deserialize a virtual volume object from base64 encoded json string and validate it.
|
||||||
|
pub fn from_base64_and_validate(value: &str) -> Result<Self> {
|
||||||
|
let volume = Self::from_base64(value)?;
|
||||||
volume.validate()?;
|
volume.validate()?;
|
||||||
|
|
||||||
Ok(volume)
|
Ok(volume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +658,8 @@ mod tests {
|
|||||||
volume.direct_volume = Some(DirectAssignedVolume { metadata });
|
volume.direct_volume = Some(DirectAssignedVolume { metadata });
|
||||||
|
|
||||||
let value = volume.to_base64().unwrap();
|
let value = volume.to_base64().unwrap();
|
||||||
let volume2: KataVirtualVolume = KataVirtualVolume::from_base64(value.as_str()).unwrap();
|
let volume2: KataVirtualVolume =
|
||||||
|
KataVirtualVolume::from_base64_and_validate(value.as_str()).unwrap();
|
||||||
assert_eq!(volume.volume_type, volume2.volume_type);
|
assert_eq!(volume.volume_type, volume2.volume_type);
|
||||||
assert_eq!(volume.source, volume2.source);
|
assert_eq!(volume.source, volume2.source);
|
||||||
assert_eq!(volume.fs_type, volume2.fs_type);
|
assert_eq!(volume.fs_type, volume2.fs_type);
|
||||||
|
Loading…
Reference in New Issue
Block a user