-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync.rs
More file actions
53 lines (46 loc) · 1.81 KB
/
sync.rs
File metadata and controls
53 lines (46 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::path::Path;
use anyhow::Result;
use crate::commands::init::{
DevOverrides, copy_example_files, inject_dev_overrides, write_dev_variables_tf,
};
use crate::helpers::{ci_log_group, example_dir, project_root, read_tfvars};
/// Re-copies example .tf files into an existing test run directory,
/// overwriting the current versions. Useful for picking up local
/// changes to the terraform modules without re-initializing.
pub async fn phase_sync(dir: &Path) -> Result<()> {
ci_log_group("Sync", || async {
let tfvars = read_tfvars(dir)?;
let provider = tfvars.cloud_provider();
let common = tfvars.common();
let src = example_dir(provider)?;
let root = project_root()?;
println!(
"Syncing terraform files for test run: {}",
dir.file_name().unwrap().to_string_lossy()
);
println!(
" Source: {}",
src.strip_prefix(&root).unwrap_or(&src).display()
);
println!(
" Dest: {}",
dir.strip_prefix(&root).unwrap_or(dir).display()
);
println!("\nCopying terraform files...");
copy_example_files(&src, dir, provider).await?;
// Re-apply dev overrides that were set during init.
let overrides = DevOverrides {
local_chart: common.helm_chart.is_some() && common.use_local_chart == Some(true),
orchestratord_version: common.orchestratord_version.is_some(),
environmentd_version: common.environmentd_version.is_some(),
};
if overrides.any() {
println!("\nRe-applying dev overrides...");
write_dev_variables_tf(dir).await?;
inject_dev_overrides(dir, &overrides).await?;
}
println!("\nSync completed successfully.");
Ok(())
})
.await
}