Skip to content

Commit

Permalink
Handle incomplete container path
Browse files Browse the repository at this point in the history
At present in order to load a container the full file name must be specified.
In an automated setup where the container is delivered by a source such as
an RPM package and then loaded by another process the exact filename may
not be known. We expect that the user provide the path to the tarball
including the beginning of the archive name. If multiple archives match the
highest file based on alpha-numeric sorting is used to load as a container.
  • Loading branch information
rjschwei committed Nov 26, 2024
1 parent dce435a commit 750baae
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions flake-ctl/src/podman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::fs;
use std::env;
use std::path::Path;
use std::process::Command;
use glob::glob;
use crate::defaults;
use crate::{app, app_config};
use flakes::container::Container;
Expand Down Expand Up @@ -74,13 +75,26 @@ pub fn load(oci: &String) -> i32 {
/*!
Call podman load with the provided oci tar file
!*/
let mut container_archive: String = oci.to_string();

info!("Loading OCI image...");
info!("podman load -i {}", oci);

if !Path::new(oci).exists() {
let container_archives = oci.to_owned() + "*";
// glob puts things in alpha sorted order which is expected to give
// us the highest version of the archive
for entry in glob(&container_archives)
.expect("Failed to read glob pattern") {
match entry {
Ok(path) => container_archive = path.display().to_string(),
Err(_) => {},
}
}
}
info!("podman load -i {}", container_archive);
let mut call = setup_podman_call("any");
call.arg("load")
.arg("-i")
.arg(oci);
.arg(container_archive);
let status = match call.status() {
Ok(status) => {
if status.success() {
Expand Down

0 comments on commit 750baae

Please sign in to comment.