(
&self,
image_ref: &str,
)
| 1951 | } |
| 1952 | |
| 1953 | async fn resolve_local_container_image( |
| 1954 | &self, |
| 1955 | image_ref: &str, |
| 1956 | ) -> Result<Option<(Docker, String)>, Status> { |
| 1957 | let required_local_image = is_openshell_local_build_image_ref(image_ref); |
| 1958 | let engine = match connect_local_container_engine().await { |
| 1959 | Some(engine) => engine, |
| 1960 | None if required_local_image => { |
| 1961 | return Err(Status::failed_precondition(format!( |
| 1962 | "no container engine (Docker/Podman) available for locally built sandbox image '{image_ref}'" |
| 1963 | ))); |
| 1964 | } |
| 1965 | None => { |
| 1966 | warn!( |
| 1967 | image_ref = %image_ref, |
| 1968 | "vm driver: no local container engine available, falling back to registry" |
| 1969 | ); |
| 1970 | return Ok(None); |
| 1971 | } |
| 1972 | }; |
| 1973 | |
| 1974 | match engine.inspect_image(image_ref).await { |
| 1975 | Ok(inspect) => { |
| 1976 | if let Some(message) = local_image_platform_mismatch( |
| 1977 | image_ref, |
| 1978 | inspect.os.as_deref(), |
| 1979 | inspect.architecture.as_deref(), |
| 1980 | ) { |
| 1981 | if required_local_image { |
| 1982 | return Err(Status::failed_precondition(message)); |
| 1983 | } |
| 1984 | warn!( |
| 1985 | image_ref = %image_ref, |
| 1986 | %message, |
| 1987 | "vm driver: local container image platform mismatch, falling back to registry" |
| 1988 | ); |
| 1989 | return Ok(None); |
| 1990 | } |
| 1991 | |
| 1992 | let image_identity = inspect.id.filter(|id| !id.trim().is_empty()).ok_or_else( |
| 1993 | || { |
| 1994 | Status::failed_precondition(format!( |
| 1995 | "local container image '{image_ref}' inspect response has no image ID" |
| 1996 | )) |
| 1997 | }, |
| 1998 | )?; |
| 1999 | info!( |
| 2000 | image_ref = %image_ref, |
| 2001 | image_identity = %image_identity, |
| 2002 | "vm driver: resolved image from local container engine" |
| 2003 | ); |
| 2004 | Ok(Some((engine, image_identity))) |
| 2005 | } |
| 2006 | Err(err) if is_docker_not_found_error(&err) && required_local_image => { |
| 2007 | Err(Status::failed_precondition(format!( |
| 2008 | "locally built sandbox image '{image_ref}' is not present in the local container engine" |
| 2009 | ))) |
| 2010 | } |
no test coverage detected