Updates chef_installed variable names to be more functional

Signed-off-by: Collin McNeese <cmcneese@chef.io>
This commit is contained in:
Collin McNeese 2021-10-24 12:32:37 -05:00
parent 692cb1ae34
commit 0085124cd8
No known key found for this signature in database
GPG Key ID: 9FA182748DD18914
4 changed files with 15 additions and 15 deletions

View File

@ -7,12 +7,12 @@ module VagrantPlugins
# @return [true, false]
def self.chef_installed(machine, product, version)
product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef'
product_binary = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
test_binary = "/opt/#{product_name}/bin/#{product_binary}"
command = "test -x #{test_binary}"
verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
verify_path = "/opt/#{product_name}/bin/#{verify_bin}"
command = "test -x #{verify_path}"
if version != :latest
command << "&& #{test_binary} --version | grep '#{version}'"
command << "&& #{verify_path} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -7,12 +7,12 @@ module VagrantPlugins
# @return [true, false]
def self.chef_installed(machine, product, version)
product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef'
product_binary = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
test_binary = "/opt/#{product_name}/bin/#{product_binary}"
command = "test -x #{test_binary}"
verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
verify_path = "/opt/#{product_name}/bin/#{verify_bin}"
command = "test -x #{verify_path}"
if version != :latest
command << "&& #{test_binary} --version | grep '#{version}'"
command << "&& #{verify_path} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -8,12 +8,12 @@ module VagrantPlugins
# @return [true, false]
def self.chef_installed(machine, product, version)
product_name = product == 'chef-workstation' ? 'chef-workstation' : 'chef'
product_binary = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
test_binary = "/opt/#{product_name}/bin/#{product_binary}"
command = "test -x #{test_binary}"
verify_bin = product_name == 'chef-workstation' ? 'chef' : 'chef-client'
verify_path = "/opt/#{product_name}/bin/#{verify_bin}"
command = "test -x #{verify_path}"
if version != :latest
command << "&& #{test_binary} --version | grep '#{version}'"
command << "&& #{verify_path} --version | grep '#{version}'"
end
machine.communicate.test(command, sudo: true)

View File

@ -6,11 +6,11 @@ module VagrantPlugins
# Check if Chef is installed at the given version.
# @return [true, false]
def self.chef_installed(machine, product, version)
test_binary = product == 'chef-workstation' ? 'chef' : 'chef-client'
verify_bin = product == 'chef-workstation' ? 'chef' : 'chef-client'
if version != :latest
command = 'if ((&' + test_binary + ' --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }'
command = 'if ((&' + verify_bin + ' --version) -Match "' + version.to_s + '"){ exit 0 } else { exit 1 }'
else
command = 'if ((&' + test_binary + ' --version) -Match "Chef*"){ exit 0 } else { exit 1 }'
command = 'if ((&' + verify_bin + ' --version) -Match "Chef*"){ exit 0 } else { exit 1 }'
end
machine.communicate.test(command, sudo: true)
end