Skip to content

Commit

Permalink
substitute vars in run name
Browse files Browse the repository at this point in the history
  • Loading branch information
flawiddsouza committed Nov 14, 2024
1 parent 3dea9fd commit 418a6d1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let deploy_file_dir = deploy_file_path.parent().unwrap_or(Path::new("."));

for dep in deployments {
println!("{}", format!("Starting deployment: {}\n", dep.name).green());
let dep_name = utils::replace_placeholders(&dep.name, &vars_map);
println!("{}", format!("Starting deployment: {}\n", dep_name).green());

let hosts: Vec<&str> = dep.hosts.split(',').map(|s| s.trim()).collect();

Expand Down
2 changes: 2 additions & 0 deletions test-ymls/use-vars-in-run-name.vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run_name: Test 1
run_name_2: Test 2
7 changes: 7 additions & 0 deletions test-ymls/use-vars-in-run-name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- name: Deployment {{ run_name }}
hosts: test
tasks:

- name: Deployment {{ run_name_2 }}
hosts: test
tasks:
4 changes: 4 additions & 0 deletions test-ymls/use-vars-in-run-name.yml.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Starting deployment: Deployment Test 1

Starting deployment: Deployment Test 2

10 changes: 10 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,13 @@ fn use_vars_in_task_name() {
setup();
run_tests_for_both_inventories("test-ymls/use-vars-in-task-name.yml", false, "");
}

#[test]
fn use_vars_in_run_name() {
setup();
run_tests_for_both_inventories(
"test-ymls/use-vars-in-run-name.yml",
false,
"@test-ymls/use-vars-in-run-name.vars.yml",
);
}

0 comments on commit 418a6d1

Please sign in to comment.