Skip to content

Commit

Permalink
Merge pull request #6 from Ant0wan/fix-var-file-position-issue
Browse files Browse the repository at this point in the history
Fix var file position issue
  • Loading branch information
Ant0wan authored Jun 4, 2023
2 parents e5d0fa9 + 1b573f0 commit 7498d62
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/exec.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::env;
use std::os::unix::process::ExitStatusExt;
use std::process::Command;
use std::process::ExitStatus;
Expand All @@ -9,18 +10,21 @@ use crate::workspace::get;

fn process_file(cmd: &Commands, file: &String) -> ExitStatus {
let workspace: String = get(file, &cmd.workspaceformat);
let mut tf_cli_args: String = format!("-var-file {file}");
if let Ok(variable) = env::var("TF_CLI_ARGS") {
tf_cli_args = format!("{variable} -var-file {file}");
}
println!(
"TF_WORKSPACE={} {} {} -var-file {:?}",
"TF_WORKSPACE={} TF_CLI_ARGS='{}' {} {} ",
workspace,
tf_cli_args,
cmd.bin,
cmd.tfargs.join(" "),
file
cmd.tfargs.join(" ")
);
Command::new(&cmd.bin)
.args(&cmd.tfargs)
.env("TF_WORKSPACE", workspace)
.arg("-var-file")
.arg(file)
.env("TF_CLI_ARGS", tf_cli_args)
.status()
.unwrap_or_else(|_| panic!("failed to execute {}", cmd.bin))
}
Expand Down

0 comments on commit 7498d62

Please sign in to comment.