agent: Fix clippy single_match

Fix `single_match` clippy warning as suggested by rust 1.85.1.

```console
warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/image.rs:241:9
    |
241 | /         match oci.annotations() {
242 | |             Some(a) => {
243 | |                 if ImageService::is_sandbox(a) {
244 | |                     return ImageService::get_pause_image_process();
...   |
247 | |             None => {}
248 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try
    |
241 ~         if let Some(a) = oci.annotations() {
242 +             if ImageService::is_sandbox(a) {
243 +                 return ImageService::get_pause_image_process();
244 +             }
245 +         }
    |
```

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
Ruoqing He 2025-05-23 11:27:47 +00:00
parent e99070afb4
commit 7ff34f00c2
2 changed files with 6 additions and 12 deletions

View File

@ -238,13 +238,10 @@ pub fn get_process(
} }
} }
if guest_pull { if guest_pull {
match oci.annotations() { if let Some(a) = oci.annotations() {
Some(a) => { if ImageService::is_sandbox(a) {
if ImageService::is_sandbox(a) { return ImageService::get_pause_image_process();
return ImageService::get_pause_image_process();
}
} }
None => {}
} }
} }
Ok(ocip.clone()) Ok(ocip.clone())

View File

@ -428,13 +428,10 @@ impl Sandbox {
pub fn setup_shared_mounts(&self, c: &LinuxContainer, mounts: &Vec<SharedMount>) -> Result<()> { pub fn setup_shared_mounts(&self, c: &LinuxContainer, mounts: &Vec<SharedMount>) -> Result<()> {
let mut src_ctrs: HashMap<String, i32> = HashMap::new(); let mut src_ctrs: HashMap<String, i32> = HashMap::new();
for shared_mount in mounts { for shared_mount in mounts {
match src_ctrs.get(&shared_mount.src_ctr) { if src_ctrs.get(&shared_mount.src_ctr) == None {
None => { if let Some(c) = self.find_container_by_name(&shared_mount.src_ctr) {
if let Some(c) = self.find_container_by_name(&shared_mount.src_ctr) { src_ctrs.insert(shared_mount.src_ctr.clone(), c.init_process_pid);
src_ctrs.insert(shared_mount.src_ctr.clone(), c.init_process_pid);
}
} }
Some(_) => {}
} }
} }