in enclave_build/src/docker.rs [276:358]
fn inspect_image(&self) -> Result<(Vec<String>, Vec<String>), DockerError> {
// First try to find CMD parameters (together with potential ENV bindings)
let act_cmd = async {
match self.docker.images().get(&self.docker_image).inspect().await {
Ok(image) => image.config.cmd.ok_or(DockerError::UnsupportedEntryPoint),
Err(e) => {
error!("{:?}", e);
Err(DockerError::InspectError)
}
}
};
let act_env = async {
match self.docker.images().get(&self.docker_image).inspect().await {
Ok(image) => image.config.env.ok_or(DockerError::UnsupportedEntryPoint),
Err(e) => {
error!("{:?}", e);
Err(DockerError::InspectError)
}
}
};
let check_cmd_runtime = Runtime::new()
.map_err(|_| DockerError::RuntimeError)?
.block_on(act_cmd);
let check_env_runtime = Runtime::new()
.map_err(|_| DockerError::RuntimeError)?
.block_on(act_env);
// If no CMD instructions are found, try to locate an ENTRYPOINT command
if check_cmd_runtime.is_err() || check_env_runtime.is_err() {
let act_entrypoint = async {
match self.docker.images().get(&self.docker_image).inspect().await {
Ok(image) => image
.config
.entrypoint
.ok_or(DockerError::UnsupportedEntryPoint),
Err(e) => {
error!("{:?}", e);
Err(DockerError::InspectError)
}
}
};
let check_entrypoint_runtime = Runtime::new()
.map_err(|_| DockerError::RuntimeError)?
.block_on(act_entrypoint);
if check_entrypoint_runtime.is_err() {
return Err(DockerError::UnsupportedEntryPoint);
}
let act = async {
match self.docker.images().get(&self.docker_image).inspect().await {
Ok(image) => Ok((
image.config.entrypoint.unwrap(),
image.config.env.ok_or_else(Vec::<String>::new).unwrap(),
)),
Err(e) => {
error!("{:?}", e);
Err(DockerError::InspectError)
}
}
};
let runtime = Runtime::new().map_err(|_| DockerError::RuntimeError)?;
return runtime.block_on(act);
}
let act = async {
match self.docker.images().get(&self.docker_image).inspect().await {
Ok(image) => Ok((image.config.cmd.unwrap(), image.config.env.unwrap())),
Err(e) => {
error!("{:?}", e);
Err(DockerError::InspectError)
}
}
};
let runtime = Runtime::new().map_err(|_| DockerError::RuntimeError)?;
runtime.block_on(act)
}