Invokes canonical Compose with scenario-sensitive ambient variables removed.
(&self, args: &[&str], timeout: Duration)
| 426 | |
| 427 | /// Invokes canonical Compose with scenario-sensitive ambient variables removed. |
| 428 | pub async fn compose(&self, args: &[&str], timeout: Duration) -> Result<String> { |
| 429 | let env_file = self.output.join("private/compose.env"); |
| 430 | let mut command = Command::new("docker"); |
| 431 | command |
| 432 | .args(["compose", "--project-name", &self.project, "--env-file"]) |
| 433 | .arg(&env_file) |
| 434 | .arg("--file") |
| 435 | .arg(self.repo.join("etc/docker/docker-compose.yml")); |
| 436 | let ports = self.output.join("private/ports.yml"); |
| 437 | if ports.exists() { |
| 438 | command.arg("--file").arg(ports); |
| 439 | } |
| 440 | command.args(args).current_dir(&self.repo); |
| 441 | for line in fs::read_to_string(&env_file)?.lines() { |
| 442 | if let Some((key, _)) = line.split_once('=') { |
| 443 | command.env_remove(key.trim()); |
| 444 | } |
| 445 | } |
| 446 | for (key, _) in std::env::vars().filter(|(key, _)| { |
| 447 | key.starts_with("COMPOSE_") |
| 448 | || key.starts_with("L2_BASE_") |
| 449 | || key.starts_with("UPGRADE_SIGNAL_") |
| 450 | }) { |
| 451 | command.env_remove(key); |
| 452 | } |
| 453 | Self::command(&mut command, timeout) |
| 454 | .await |
| 455 | .map_err(|error| eyre::eyre!("{}", self.sanitize(&error.to_string()))) |
| 456 | } |
| 457 | |
| 458 | /// Executes a child with bounded retained output while draining both pipes. |
| 459 | pub async fn command(command: &mut Command, timeout: Duration) -> Result<String> { |