Merge pull request #11345 from Apokleos/fix-noise

protocols: Fix the noise caused by non-formatted codes in protocols
This commit is contained in:
RuoqingHe 2025-06-11 09:50:02 +08:00 committed by GitHub
commit 7916db9613
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View File

@ -9,6 +9,7 @@ pub mod agent;
pub mod agent_ttrpc;
#[cfg(feature = "async")]
pub mod agent_ttrpc_async;
pub mod api;
pub mod csi;
pub mod empty;
mod gogo;
@ -17,15 +18,14 @@ pub mod health_ttrpc;
#[cfg(feature = "async")]
pub mod health_ttrpc_async;
pub mod oci;
#[cfg(feature = "with-serde")]
mod serde_config;
pub mod trans;
pub mod types;
pub mod remote;
pub mod remote_ttrpc;
#[cfg(feature = "async")]
pub mod remote_ttrpc_async;
pub mod api;
#[cfg(feature = "with-serde")]
mod serde_config;
pub mod trans;
pub mod types;
#[cfg(feature = "with-serde")]
pub use serde_config::{

View File

@ -42,7 +42,9 @@ fn cap_vec2hashset(caps: Vec<String>) -> HashSet<oci::Capability> {
.map(|cap: &String| {
// cap might be JSON-encoded
let decoded: &str = serde_json::from_str(cap).unwrap_or(cap);
decoded.strip_prefix("CAP_").unwrap_or(decoded)
decoded
.strip_prefix("CAP_")
.unwrap_or(decoded)
.parse::<oci::Capability>()
.unwrap_or_else(|_| panic!("Failed to parse {:?} to Enum Capability", cap))
})
@ -1318,8 +1320,6 @@ mod tests {
#[test]
#[should_panic]
fn test_cap_vec2hashset_bad() {
cap_vec2hashset(vec![
"CAP_DOES_NOT_EXIST".to_string(),
]);
cap_vec2hashset(vec!["CAP_DOES_NOT_EXIST".to_string()]);
}
}