Skip to content

Commit

Permalink
Fix client doctor path resolution (#521)
Browse files Browse the repository at this point in the history
* Fix client doctor path resolution

* Update CHANGELOG

---------

Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com>
  • Loading branch information
aaron-lane and Aaron Lane committed Apr 19, 2023
1 parent 805d8fc commit fb2db9f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to

## [Unreleased][unreleased]

### Fixed

- The doctor check for the `client` attribute uses the PATH to validate
the value.

## [7.0.0] - 2023-04-09

### Added
Expand Down
8 changes: 2 additions & 6 deletions lib/kitchen/terraform/config_attribute/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ def config_client_default_value
def doctor_config_client
errors = false

if !::File.exist? config_client
if !::TTY::Which.exist? config_client
errors = true
logger.error "client '#{config_client}' does not exist"
end
if !::File.executable? config_client
errors = true
logger.error "client '#{config_client}' is not executable"
logger.error "client '#{config_client}' is not executable or does not exist"
end

errors
Expand Down
4 changes: 4 additions & 0 deletions spec/lib/kitchen/transport/terraform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
end

describe "#doctor" do
let :config do
{client: "/nonexistent/client"}
end

specify "should return true" do
subject.finalize_config! kitchen_instance

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
file = ::Tempfile.new ["client", ".exe"]
file.chmod 0777

file
::File.absolute_path file
end

specify "should return false" do
Expand Down

0 comments on commit fb2db9f

Please sign in to comment.