Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Fix Connection#execute bug on Windows (#502)
Browse files Browse the repository at this point in the history
Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com>
  • Loading branch information
aaron-lane and Aaron Lane authored Mar 11, 2023
1 parent 8043771 commit d6f1303
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions lib/kitchen/terraform/transport/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ module Transport
# The shell out environment includes the TF_IN_AUTOMATION environment variable as specified by the
# {https://www.terraform.io/guides/running-terraform-in-automation.html#controlling-terraform-output-in-automation Running Terraform in Automation guide}.
class Connection < ::Kitchen::Transport::Exec::Connection
# #run_command executes a Terraform CLI command in a subshell on the local running system.
# #execute executes a Terraform CLI command on the local host.
#
# @param command [String] the Terraform command to be executed locally.
# @raise [Kitchen::TransportFailed] if the command does not exit successfully.
def execute(command)
super "#{client} #{command}"
end

# #run_command executes a command in a subshell on the local running system.
#
# @param command [String] the command to be executed locally.
# @param options [Hash] additional configuration of the command.
# @return [String] the standard output of the command.
# @raise [Kitchen::ShellOut::ShellCommandFailed] if the command fails.
# @raise [Kitchen::StandardError] for all other unexpected exceptions.
def run_command(command, options = {})
super "#{client} #{command}", options.merge(
super command, options.merge(
cwd: root_module_directory,
environment: environment.merge("LC_ALL" => nil, "TF_IN_AUTOMATION" => "true"),
timeout: command_timeout,
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/kitchen/terraform/transport/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
instance_double ::String
end

describe "#run_command" do
describe "#execute" do
let :command do
instance_double ::String
end
Expand All @@ -80,7 +80,7 @@
})
).and_return shell_out

expect(subject.run_command(command)).to eq :superclass
expect(subject.execute(command)).to eq :superclass
end
end
end

0 comments on commit d6f1303

Please sign in to comment.