From 6f9f88e05557d40570a3885b6d3d3a6a24c06090 Mon Sep 17 00:00:00 2001 From: Nicolas St-Laurent Date: Thu, 22 Sep 2022 08:54:46 -0400 Subject: [PATCH] Replace deprecated File.exists? with File.exist?. --- lib/vagrant/util/install_cli_autocomplete.rb | 2 +- plugins/hosts/gentoo/host.rb | 2 +- plugins/hosts/slackware/host.rb | 2 +- plugins/provisioners/ansible/provisioner/host.rb | 2 +- plugins/provisioners/chef/config/chef_zero.rb | 2 +- test/unit/plugins/provisioners/ansible/provisioner_test.rb | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/util/install_cli_autocomplete.rb b/lib/vagrant/util/install_cli_autocomplete.rb index 9aaf61a1de2..119749e0f08 100644 --- a/lib/vagrant/util/install_cli_autocomplete.rb +++ b/lib/vagrant/util/install_cli_autocomplete.rb @@ -29,7 +29,7 @@ def shell_installed(home) @logger.info("Searching for config in home #{home}") @config_paths.each do |path| config_file = File.join(home, path) - if File.exists?(config_file) + if File.exist?(config_file) @logger.info("Found config file #{config_file}") return config_file end diff --git a/plugins/hosts/gentoo/host.rb b/plugins/hosts/gentoo/host.rb index ac7e019d045..6d8b88a6a35 100644 --- a/plugins/hosts/gentoo/host.rb +++ b/plugins/hosts/gentoo/host.rb @@ -4,7 +4,7 @@ module VagrantPlugins module HostGentoo class Host < Vagrant.plugin("2", :host) def detect?(env) - File.exists?("/etc/gentoo-release") + File.exist?("/etc/gentoo-release") end end end diff --git a/plugins/hosts/slackware/host.rb b/plugins/hosts/slackware/host.rb index ec3503ac02e..bea7cab7476 100644 --- a/plugins/hosts/slackware/host.rb +++ b/plugins/hosts/slackware/host.rb @@ -4,7 +4,7 @@ module VagrantPlugins module HostSlackware class Host < Vagrant.plugin("2", :host) def detect?(env) - return File.exists?("/etc/slackware-version") || + return File.exist?("/etc/slackware-version") || !Dir.glob("/usr/lib/setup/Plamo-*").empty? end end diff --git a/plugins/provisioners/ansible/provisioner/host.rb b/plugins/provisioners/ansible/provisioner/host.rb index 3e594b83c11..f2a57133c79 100644 --- a/plugins/provisioners/ansible/provisioner/host.rb +++ b/plugins/provisioners/ansible/provisioner/host.rb @@ -185,7 +185,7 @@ def ship_generated_inventory(inventory_content) inventory_file = Pathname.new(File.join(inventory_path, 'vagrant_ansible_inventory')) @@lock.synchronize do - if !File.exists?(inventory_file) or inventory_content != File.read(inventory_file) + if !File.exist?(inventory_file) or inventory_content != File.read(inventory_file) begin # ansible dir inventory will ignore files starting with '.' inventory_tmpfile = Tempfile.new('.vagrant_ansible_inventory', inventory_path) diff --git a/plugins/provisioners/chef/config/chef_zero.rb b/plugins/provisioners/chef/config/chef_zero.rb index c19485f882e..84ed08cf5b2 100644 --- a/plugins/provisioners/chef/config/chef_zero.rb +++ b/plugins/provisioners/chef/config/chef_zero.rb @@ -81,7 +81,7 @@ def validate(machine) errors << I18n.t("vagrant.config.chef.nodes_path_empty") else missing_paths = Array.new - nodes_path.each { |dir| missing_paths << dir[1] if !File.exists? dir[1] } + nodes_path.each { |dir| missing_paths << dir[1] if !File.exist? dir[1] } # If it exists at least one path on disk it's ok for Chef provisioning if missing_paths.size == nodes_path.size errors << I18n.t("vagrant.config.chef.nodes_path_missing", path: missing_paths.to_s) diff --git a/test/unit/plugins/provisioners/ansible/provisioner_test.rb b/test/unit/plugins/provisioners/ansible/provisioner_test.rb index 180f26869bb..f5828f14340 100644 --- a/test/unit/plugins/provisioners/ansible/provisioner_test.rb +++ b/test/unit/plugins/provisioners/ansible/provisioner_test.rb @@ -181,7 +181,7 @@ def self.it_should_create_and_use_generated_inventory(with_user = true) it "generates an inventory with all active machines" do expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args) { |*args| expect(config.inventory_path).to be_nil - expect(File.exists?(generated_inventory_file)).to be(true) + expect(File.exist?(generated_inventory_file)).to be(true) inventory_content = File.read(generated_inventory_file) _ssh = config.compatibility_mode == VagrantPlugins::Ansible::COMPATIBILITY_MODE_V2_0 ? "" : "_ssh" if with_user @@ -697,7 +697,7 @@ def ensure_that_config_is_valid it "generates an inventory with winrm connection settings" do expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args) { |*args| expect(config.inventory_path).to be_nil - expect(File.exists?(generated_inventory_file)).to be(true) + expect(File.exist?(generated_inventory_file)).to be(true) inventory_content = File.read(generated_inventory_file) expect(inventory_content).to include("machine1 ansible_connection=winrm ansible_ssh_host=127.0.0.1 ansible_ssh_port=55986 ansible_ssh_user='winner' ansible_ssh_pass='winword'\n") @@ -731,7 +731,7 @@ def ensure_that_config_is_valid expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args) { |*args| expect(args).to include("--inventory-file=#{existing_file}") expect(args).not_to include("--inventory-file=#{generated_inventory_file}") - expect(File.exists?(generated_inventory_file)).to be(false) + expect(File.exist?(generated_inventory_file)).to be(false) }.and_return(default_execute_result) end