1
1
use log:: { debug, error} ;
2
+ use std:: env;
2
3
use std:: path:: Path ;
3
4
use std:: process:: Command ;
4
5
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -51,6 +52,7 @@ fn setup_signal_handler() -> Result<Arc<AtomicBool>> {
51
52
}
52
53
#[ cfg( windows) ]
53
54
{
55
+ // Additional Windows termination logic here if needed.
54
56
use windows:: Win32 :: Foundation :: HANDLE ;
55
57
use windows:: Win32 :: System :: Threading :: { OpenProcess , TerminateProcess } ;
56
58
}
@@ -122,7 +124,10 @@ fn execute_terraform_command(
122
124
working_dir : & Path ,
123
125
running : Arc < AtomicBool > ,
124
126
) -> Result < bool > {
125
- let mut command = Command :: new ( "terraform" ) ;
127
+ // read `TERRAFORM_BINARY_NAME` env, fallback to "terraform"
128
+ let terraform_binary =
129
+ env:: var ( "TERRAFORM_BINARY_NAME" ) . unwrap_or_else ( |_| "terraform" . to_string ( ) ) ;
130
+ let mut command = Command :: new ( & terraform_binary) ;
126
131
command. arg ( operation. to_string ( ) ) . current_dir ( working_dir) ;
127
132
128
133
for target in target_options {
@@ -134,15 +139,16 @@ fn execute_terraform_command(
134
139
}
135
140
136
141
let command_str = format ! (
137
- "terraform {} {}{}" ,
142
+ "{} {} {}" ,
143
+ terraform_binary,
138
144
operation,
139
145
target_options. join( " " ) ,
140
- if matches!( operation, Operation :: Apply ) {
141
- " -auto-approve"
142
- } else {
143
- ""
144
- }
145
146
) ;
147
+ let command_str = if matches ! ( operation, Operation :: Apply ) {
148
+ format ! ( "{} -auto-approve" , command_str)
149
+ } else {
150
+ command_str
151
+ } ;
146
152
147
153
Display :: print_command ( & command_str) ;
148
154
debug ! (
0 commit comments