Skip to content

Commit f51b2c4

Browse files
committed
docker: Handle arbitrary extra arguments
implemented in the configuration file and parsed from environment variables.
1 parent ce617d5 commit f51b2c4

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/docker/local.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub(crate) fn run(
4141

4242
let mut docker = engine.subcommand("run");
4343
docker.add_userns();
44+
docker.add_extra_args(&options)?;
4445

4546
// Podman on macOS doesn't support selinux labels, see issue #756
4647
#[cfg(target_os = "macos")]

src/docker/remote.rs

+3
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ pub(crate) fn run(
758758
msg_info,
759759
)
760760
.wrap_err("could not determine mount points")?;
761+
docker
762+
.add_extra_args(&options)
763+
.wrap_err("could not determine additional container arguments")?;
761764

762765
docker
763766
.add_seccomp(engine.kind, target, &paths.metadata)

src/docker/shared.rs

+11
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ pub(crate) trait DockerCommandExt {
955955
target: &Target,
956956
metadata: &CargoMetadata,
957957
) -> Result<()>;
958+
fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()>;
958959
fn add_mounts(
959960
&mut self,
960961
options: &DockerOptions,
@@ -1164,6 +1165,16 @@ impl DockerCommandExt for Command {
11641165
Ok(())
11651166
}
11661167

1168+
fn add_extra_args(&mut self, options: &DockerOptions) -> Result<()> {
1169+
let extra_args = options.config.extra_args(&options.target)?;
1170+
if let Some(args) = extra_args {
1171+
args.iter().for_each(|arg| {
1172+
self.arg(arg);
1173+
});
1174+
}
1175+
Ok(())
1176+
}
1177+
11671178
fn add_mounts(
11681179
&mut self,
11691180
options: &DockerOptions,

0 commit comments

Comments
 (0)