Skip to content

Commit ba1f01f

Browse files
committed
Make Compose run command command use the original file path if environment is active
1 parent cc03e3c commit ba1f01f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

vdev/src/testing/integration.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl IntegrationTest {
136136
}
137137

138138
struct Compose {
139-
path: PathBuf,
139+
original_path: PathBuf,
140140
test_dir: PathBuf,
141141
env: Environment,
142142
#[cfg(unix)]
@@ -147,14 +147,14 @@ struct Compose {
147147

148148
impl Compose {
149149
fn new(test_dir: PathBuf, env: Environment, network: String) -> Result<Option<Self>> {
150-
let path: PathBuf = [&test_dir, Path::new("compose.yaml")].iter().collect();
150+
let original_path: PathBuf = [&test_dir, Path::new("compose.yaml")].iter().collect();
151151

152-
match path.try_exists() {
153-
Err(error) => Err(error).with_context(|| format!("Could not lookup {path:?}")),
152+
match original_path.try_exists() {
153+
Err(error) => Err(error).with_context(|| format!("Could not lookup {original_path:?}")),
154154
Ok(false) => Ok(None),
155155
Ok(true) => {
156156
#[cfg(unix)]
157-
let mut config = ComposeConfig::parse(&path)?;
157+
let mut config = ComposeConfig::parse(&original_path)?;
158158

159159
// Inject the networks block
160160
config.networks.insert(
@@ -178,7 +178,7 @@ impl Compose {
178178
)?;
179179

180180
Ok(Some(Self {
181-
path,
181+
original_path,
182182
test_dir,
183183
env,
184184
#[cfg(unix)]
@@ -209,11 +209,11 @@ impl Compose {
209209
// needs to use the calculated path from the integration name instead of the nonexistent
210210
// tempfile path. This is because `stop` doesn't go through the same logic as `start`
211211
// and doesn't create a new tempfile before calling docker compose.
212+
// If stop command needs to use some of the injected bits then we need to rebuild it
213+
command.arg("--file");
212214
if config.is_none() {
213-
command.arg("--file");
214-
command.arg(&self.path);
215+
command.arg(&self.original_path);
215216
} else {
216-
command.arg("--file");
217217
command.arg(self.temp_file.path());
218218
}
219219

0 commit comments

Comments
 (0)