pub async fn pull_bytecode(image: BytecodeImage) -> Result<()>Expand description
Pulls an OCI-compliant image containing eBPF bytecode from a remote container registry.
§Arguments
image- ABytecodeImagestruct that contains information about the bytecode image to be pulled, including its URL, pull policy, username, and password.
§Returns
This function returns an anyhow::Result<()> which, on success,
contains an empty tuple (). On failure, it returns an
anyhow::Error encapsulating the cause of the failure.
§Errors
This function can return the following errors:
SetupError- If thesetup()function fails to initialise correctly.ImageManagerInitializationError- If there is an error initialising the image manager withinit_image_manager().RegistryAuthenticationError- If there is an authentication failure while accessing the container registry.NetworkError- If there are network issues while pulling the image from the container registry.ImagePullError- If there is a problem pulling the image due to invalid image URL, unsupported image format, or other image-specific issues.
§Examples
use bpfman::pull_bytecode;
use bpfman::types::{BytecodeImage, ImagePullPolicy};
#[tokio::main]
async fn main() {
let image = BytecodeImage {
image_url: "example.com/myrepository/myimage:latest".to_string(),
image_pull_policy: ImagePullPolicy::IfNotPresent,
// Optional username/password for authentication.
username: Some("username".to_string()),
password: Some("password".to_string()),
};
match pull_bytecode(image).await {
Ok(_) => println!("Image pulled successfully."),
Err(e) => eprintln!("Failed to pull image: {}", e),
}
}§Asynchronous Operation
This function is asynchronous and should be awaited in an asynchronous context.