Skip to content

Commit

Permalink
Merge pull request #47 from containers/no-entrypoint
Browse files Browse the repository at this point in the history
create: Ignore first argument if it is "no-entrypoint"
  • Loading branch information
albertofaria authored Apr 15, 2024
2 parents d1d54e6 + 46628d8 commit 1efbd7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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

0 comments on commit 1efbd7d

Please sign in to comment.