Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix var file position issue #6

Merged
merged 5 commits into from
Jun 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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