Skip to content

Commit

Permalink
create: Allow empty strings anywhere in the container command
Browse files Browse the repository at this point in the history
Users should always be allowed to include an empty "" argument,
regardless of whether the container image sets an entrypoint.

Signed-off-by: Alberto Faria <[email protected]>
  • Loading branch information
albertofaria committed Apr 16, 2024
1 parent 1efbd7d commit 565ec60
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/commands/create/custom_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@ impl CustomOptions {
.args()
.iter()
.flatten()
.filter(|a| !a.trim().is_empty())
.collect();

if let Some(&first_arg) = args.first() {
if first_arg.trim().is_empty() || first_arg == "no-entrypoint" {
if 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
// entrypoint and ignore it in that case.
if let Some(&first_arg) = args.first() {
ensure!(
first_arg.starts_with("-"),
"unexpected entrypoint '{first_arg}' found; use an image without an entrypoint or with entrypoint \"no-entrypoint\", and/or pass in an empty \"\" entrypoint on the command line"
);
}

let mut options = CustomOptions::parse_from(
iter::once(&"podman run [<podman-opts>] <image>".to_string()).chain(args),
);
Expand Down

0 comments on commit 565ec60

Please sign in to comment.