Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create: Ignore first argument if it is "no-entrypoint" #47

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/commands/create/custom_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,20 @@ pub struct CustomOptions {

impl CustomOptions {
pub fn from_spec(spec: &oci_spec::runtime::Spec, env: RuntimeEnv) -> Result<Self> {
let args = spec
let mut args: Vec<&String> = spec
.process()
.as_ref()
.unwrap()
.args()
.iter()
.flatten()
.filter(|arg| !arg.trim().is_empty());
.collect();

if let Some(&first_arg) = args.first() {
if first_arg.trim().is_empty() || first_arg == "no-entrypoint" {
args.remove(0);
}
}

// TODO: We currently assume that no entrypoint is given (either by being set by in the
// container image or through --entrypoint). Must somehow find whether the first arg is the
Expand Down
3 changes: 1 addition & 2 deletions tests/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ start)
--rm -dit \
-v "$temp_dir":/home/fedora/images:z \
-v "$repo_root/target":/home/fedora/target:z \
"$env_image" \
""
"$env_image"

# shellcheck disable=SC2317
__extra_cleanup() {
Expand Down
1 change: 1 addition & 0 deletions util/package-vm-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ image_path_in_container=/disk/$( basename "${vm_image_file}" )
podman image build --file=- --tag="${container_image_tag}" / <<EOF
FROM scratch
COPY ${abs_vm_image_file@Q} ${image_path_in_container@Q}
ENTRYPOINT ["no-entrypoint"]
EOF