Skip to content

Commit

Permalink
docker: Handle arbitrary extra arguments
Browse files Browse the repository at this point in the history
implemented in the configuration file and parsed from environment
variables.
  • Loading branch information
har7an committed Aug 21, 2023
1 parent ce617d5 commit f51b2c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/docker/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub(crate) fn run(

let mut docker = engine.subcommand("run");
docker.add_userns();
docker.add_extra_args(&options)?;

// Podman on macOS doesn't support selinux labels, see issue #756
#[cfg(target_os = "macos")]
Expand Down
3 changes: 3 additions & 0 deletions src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ pub(crate) fn run(
msg_info,
)
.wrap_err("could not determine mount points")?;
docker
.add_extra_args(&options)
.wrap_err("could not determine additional container arguments")?;

docker
.add_seccomp(engine.kind, target, &paths.metadata)
Expand Down
11 changes: 11 additions & 0 deletions src/docker/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ pub(crate) trait DockerCommandExt {
target: &Target,
metadata: &CargoMetadata,
) -> Result<()>;
fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()>;
fn add_mounts(
&mut self,
options: &DockerOptions,
Expand Down Expand Up @@ -1164,6 +1165,16 @@ impl DockerCommandExt for Command {
Ok(())
}

fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()> {
let extra_args = options.config.extra_args(&options.target)?;
if let Some(args) = extra_args {
args.iter().for_each(|arg| {
self.arg(arg);
});
}
Ok(())
}

fn add_mounts(
&mut self,
options: &DockerOptions,
Expand Down

0 comments on commit f51b2c4

Please sign in to comment.