Skip to content

Commit

Permalink
Avoid to access instance.name when the instance is a nil
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuniwak committed Feb 13, 2017
1 parent e37a353 commit 3a60651
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,13 @@ def local_kitchen_cache
# instance's Vagrantfile
# @api private
def vagrant_root
root = File.join(config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
)
@vagrant_root ||= instance.nil? ? nil : root
if !@vagrant_root && !instance.nil?
@vagrant_root = File.join(
config[:kitchen_root], %w{.kitchen kitchen-vagrant},
"kitchen-#{File.basename(config[:kitchen_root])}-#{instance.name}"
)
end
@vagrant_root
end

# @param type [Symbol] either `:ssh` or `:winrm`
Expand Down

0 comments on commit 3a60651

Please sign in to comment.