From fb2db9f3c4dadc70a40a0e245379c63af9a06bcc Mon Sep 17 00:00:00 2001 From: Aaron Lane <10655063+aaron-lane@users.noreply.github.com> Date: Tue, 18 Apr 2023 22:16:58 -0400 Subject: [PATCH] Fix client doctor path resolution (#521) * Fix client doctor path resolution * Update CHANGELOG --------- Co-authored-by: Aaron Lane <2400330-aaron-lane@users.noreply.gitlab.com> --- CHANGELOG.md | 5 +++++ lib/kitchen/terraform/config_attribute/client.rb | 8 ++------ spec/lib/kitchen/transport/terraform_spec.rb | 4 ++++ .../kitchen/terraform/config_attribute/client_examples.rb | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff8b960a..2a9f56baa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/kitchen/terraform/config_attribute/client.rb b/lib/kitchen/terraform/config_attribute/client.rb index 0cf6bae83..4303cea53 100644 --- a/lib/kitchen/terraform/config_attribute/client.rb +++ b/lib/kitchen/terraform/config_attribute/client.rb @@ -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 diff --git a/spec/lib/kitchen/transport/terraform_spec.rb b/spec/lib/kitchen/transport/terraform_spec.rb index f62adbf24..6c77fc8d0 100644 --- a/spec/lib/kitchen/transport/terraform_spec.rb +++ b/spec/lib/kitchen/transport/terraform_spec.rb @@ -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 diff --git a/spec/support/kitchen/terraform/config_attribute/client_examples.rb b/spec/support/kitchen/terraform/config_attribute/client_examples.rb index 613aef814..d7db5d9d3 100644 --- a/spec/support/kitchen/terraform/config_attribute/client_examples.rb +++ b/spec/support/kitchen/terraform/config_attribute/client_examples.rb @@ -91,7 +91,7 @@ file = ::Tempfile.new ["client", ".exe"] file.chmod 0777 - file + ::File.absolute_path file end specify "should return false" do